Attachment 'mygcc.patch'

Download

   1 diff -ur src.orig/configure src/configure
   2 --- src.orig/configure	Sun Apr 15 00:10:13 2007
   3 +++ src/configure	Wed Dec 19 00:25:04 2007
   4 @@ -3412,13 +3412,13 @@
   5    CFLAGS=$ac_save_CFLAGS
   6  elif test $ac_cv_prog_cc_g = yes; then
   7    if test "$GCC" = yes; then
   8 -    CFLAGS="-g -O2"
   9 +    CFLAGS="-g3"
  10    else
  11 -    CFLAGS="-g"
  12 +    CFLAGS="-g3"
  13    fi
  14  else
  15    if test "$GCC" = yes; then
  16 -    CFLAGS="-O2"
  17 +    CFLAGS=""
  18    else
  19      CFLAGS=
  20    fi
  21 @@ -3919,13 +3919,13 @@
  22    CXXFLAGS=$ac_save_CXXFLAGS
  23  elif test $ac_cv_prog_cxx_g = yes; then
  24    if test "$GXX" = yes; then
  25 -    CXXFLAGS="-g -O2"
  26 +    CXXFLAGS="-g3"
  27    else
  28 -    CXXFLAGS="-g"
  29 +    CXXFLAGS="-g3"
  30    fi
  31  else
  32    if test "$GXX" = yes; then
  33 -    CXXFLAGS="-O2"
  34 +    CXXFLAGS=""
  35    else
  36      CXXFLAGS=
  37    fi
  38 Only in src/: configure~
  39 diff -ur src.orig/gcc/Makefile.in src/gcc/Makefile.in
  40 --- src.orig/gcc/Makefile.in	Sun Apr 15 00:14:12 2007
  41 +++ src/gcc/Makefile.in	Wed Dec 19 00:25:34 2007
  42 @@ -531,7 +531,7 @@
  43  # Options to use when compiling libgcc2.a.
  44  #
  45  LIBGCC2_DEBUG_CFLAGS = -g
  46 -LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(TARGET_LIBGCC2_CFLAGS) \
  47 +LIBGCC2_CFLAGS =  $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(TARGET_LIBGCC2_CFLAGS) \
  48  		 $(LIBGCC2_DEBUG_CFLAGS) $(GTHREAD_FLAGS) \
  49  		 -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED \
  50  		 $(INHIBIT_LIBC_CFLAGS)
  51 @@ -544,7 +544,7 @@
  52  TARGET_LIBGCC2_CFLAGS =
  53  
  54  # Options to use when compiling crtbegin/end.
  55 -CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
  56 +CRTSTUFF_CFLAGS =  $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
  57    -finhibit-size-directive -fno-inline-functions -fno-exceptions \
  58    -fno-zero-initialized-in-bss -fno-toplevel-reorder \
  59    $(INHIBIT_LIBC_CFLAGS)
  60 Only in src/gcc: Makefile.in~
  61 diff -ur src.orig/gcc/condate.y src/gcc/condate.y
  62 --- src.orig/gcc/condate.y	Sun Apr 15 00:14:55 2007
  63 +++ src/gcc/condate.y	Sun Jan 13 16:49:20 2008
  64 @@ -49,7 +49,10 @@
  65    #include "tree-match.h"
  66    int yylex (void);
  67    void yyerror (char const *);
  68 -
  69 +  pattern frompat, topat, avoidpat, matchpat, functionpat, followpat;
  70 +  char *types;
  71 +  static int line = 0;
  72 +  static int fromappearatleastonce = 0;
  73  %}
  74  
  75  /* Bison declarations.  */
  76 @@ -57,29 +60,58 @@
  77  %token CONDATE
  78  %token FROM
  79  %token TO
  80 +%token FOLLOW
  81  %token AVOID
  82 +%token MATCH
  83  %token IDENT
  84  %right OR
  85  %token STR
  86  %token CCODE
  87  %token WARNING
  88 +%token TYPES
  89 +%token FUNCTIONS
  90 +%token FROMAPPEARONCE
  91  
  92  %% /* The grammar follows.  */
  93  start: /* empty */
  94 -| start condate {/* print_cond($2); */
  95 -		 normalize_condate($2);
  96 -		 name_condate($2);
  97 -		 add_condate($2);};
  98 +| start {frompat = topat = functionpat = avoidpat = matchpat = followpat = NULL;
  99 +	 fromappearatleastonce = 0; types = NULL;}condate {
 100 +		 normalize_condate($3);
 101 +		 name_condate($3);
 102 +		 add_condate($3);};
 103  
 104  condate: CONDATE IDENT '{' crq '}' 
 105           WARNING '(' STR ')' ';' {$$ = $4; 
 106  	   ((condate)$$)->name = $2; ((condate)$$)->msg = $8;}
 107  | crq ';' {$$ = $1;};
 108  
 109 -/* Constraint Reachability Queries */
 110 -crq: patexp {$$ = mkcond(NULL, $1, NULL, NULL, NULL, NULL);}
 111 -| FROM patexp TO patexp {$$ = mkcond(NULL, $2, $4, NULL, NULL, NULL);}
 112 -| FROM patexp TO patexp AVOID patexp {$$ = mkcond(NULL, $2, $4, $6, NULL, NULL);};
 113 +crq: crqelements 
 114 +{if (frompat == NULL || topat == NULL) 
 115 +	fprintf(stderr, "You should at least supply from pattern and to pattern\n");
 116 + $$ = mkcond (NULL, frompat,  topat,  avoidpat, NULL, NULL, matchpat, types, functionpat,
 117 +		followpat, fromappearatleastonce);};
 118 +	
 119 +crqelements:
 120 +|crqelements crqelement;
 121 +
 122 +crqelement:
 123 +FROM patexp { if(frompat)fprintf(stderr,"%s:%d duplicate from pattern!\n",tree_check_file,line);
 124 +		else frompat = $2; }
 125 +|TO patexp { if(topat)fprintf(stderr,"%s:%d duplicate to pattern\n",tree_check_file,line);
 126 +		else topat = $2;}
 127 +|AVOID patexp{if(avoidpat)fprintf(stderr,"%s:%d duplicate avoid pattern\n",tree_check_file,line);
 128 +		else avoidpat = $2;}
 129 +|MATCH patexp {if(matchpat)fprintf(stderr,"%s:%d duplicate match pattern\n",tree_check_file,line);
 130 +		else matchpat = $2;}
 131 +|FOLLOW patexp {if(followpat)fprintf(stderr,"%s:%d duplicate match pattern\n",tree_check_file,line); else followpat = $2;}
 132 +|TYPES STR { if(types)fprintf(stderr,"%s:%d duplicate types declaration\n",tree_check_file,line);
 133 +		else types = $2;}
 134 +|FUNCTIONS patexp 
 135 +	{if(functionpat)fprintf(stderr,"%s:%d duplicate function pattern\n",tree_check_file,line);
 136 +	else functionpat = $2;}
 137 +|FROMAPPEARONCE {fromappearatleastonce = 1;}
 138 +;
 139 +
 140  
 141  patexp: edgepat {$$ = $1;}
 142  | patexp OR patexp {$$ = pat_or($1, $3);}
 143 @@ -124,14 +156,19 @@
 144    /* Skip white space and comments. */
 145    do 
 146      {
 147 -      while (c == ' ' || c == '\t' || c == '\n') 
 148 +      while (c == ' ' || c == '\t' || c == '\n') {
 149 +        if (c == '\n')
 150 + 	  line++;
 151  	c = getc (checkfile);
 152 +      }
 153        if(c == '#') 
 154  	{
 155  	  while ((c = getc (checkfile)) != '\n' && c != EOF)
 156  	    ;
 157 -	  if (c == '\n') 
 158 +	  if (c == '\n') {
 159 +	    line++;
 160  	    c = getc (checkfile);
 161 +	  }
 162  	}
 163      } while(c == ' ' || c == '\t' || c == '#' || c == '\n');
 164  
 165 @@ -205,12 +242,22 @@
 166  	return FROM;
 167        else if (!strcmp (buf, "to"))
 168  	return TO;
 169 +      else if (!strcmp (buf, "match"))
 170 +	return MATCH;
 171 +      else if (!strcmp (buf, "follow"))
 172 +	return FOLLOW;
 173        else if (!strcmp (buf, "avoid"))
 174  	return AVOID;
 175        else if (!strcmp (buf, "or"))
 176  	return OR;
 177        else if (!strcmp (buf, "warning"))
 178  	return WARNING;
 179 +      else if (!strcmp (buf, "types"))
 180 +	return TYPES;
 181 +      else if (!strcmp (buf, "functions"))
 182 +	return FUNCTIONS;
 183 +      else if (!strcmp (buf, "fromappearatleastonce"))
 184 +	return FROMAPPEARONCE;
 185        /* identifier */
 186        yylval = xstrdup (buf);
 187        return IDENT;
 188 @@ -228,8 +275,8 @@
 189    char buf[32];
 190    fprintf (stderr, "%s: %s\n", tree_check_file, s);
 191    fgets (buf, 32, checkfile);
 192 -  fprintf (stderr, "%s: before or near: \"%s\"\n", 
 193 -	   tree_check_file, buf);
 194 +  fprintf (stderr, "%s: before or near: \"%s\" on line %d\n", 
 195 +	   tree_check_file, buf, line);
 196  }
 197  
 198  struct split_pattern_s split_pattern(pattern p);
 199 Only in src/gcc: condate.y.back
 200 Only in src/gcc: condate.y~
 201 diff -ur src.orig/gcc/diagnostic.h src/gcc/diagnostic.h
 202 --- src.orig/gcc/diagnostic.h	Sun Apr 15 00:13:07 2007
 203 +++ src/gcc/diagnostic.h	Thu Jan  3 11:09:23 2008
 204 @@ -217,6 +217,8 @@
 205  extern void print_generic_decl (FILE *, tree, int);
 206  
 207  extern VEC (tree_chunk, heap) *lazy_dump_generic_node (tree, int, bool);
 208 +extern VEC (tree_chunk, heap) *nolazy_dump_generic_node (tree, int, bool);
 209 +
 210  extern void lazy_print_generic_expr (FILE *file, tree t, int flags);
 211  
 212  extern void debug_generic_expr (tree);
 213 Only in src/gcc: diagnostic.h~
 214 diff -ur src.orig/gcc/passes.c src/gcc/passes.c
 215 --- src.orig/gcc/passes.c	Sun Apr 15 00:14:19 2007
 216 +++ src/gcc/passes.c	Mon Dec 24 09:45:29 2007
 217 @@ -451,7 +451,7 @@
 218    NEXT_PASS (pass_lower_cf);
 219    NEXT_PASS (pass_lower_eh);
 220    NEXT_PASS (pass_build_cfg);
 221 -  NEXT_PASS (pass_check);
 222 +//  NEXT_PASS (pass_check);
 223    NEXT_PASS (pass_lower_complex_O0);
 224    NEXT_PASS (pass_lower_vector);
 225    NEXT_PASS (pass_warn_function_return);
 226 @@ -645,6 +645,7 @@
 227        NEXT_PASS (pass_mark_used_blocks);
 228        NEXT_PASS (pass_cleanup_cfg_post_optimizing);
 229      }
 230 +  NEXT_PASS (pass_check);
 231    NEXT_PASS (pass_warn_function_noreturn);
 232    NEXT_PASS (pass_free_datastructures);
 233    NEXT_PASS (pass_mudflap_2);
 234 Only in src/gcc: passes.c~
 235 Only in src/gcc: tree-cfg.c~
 236 diff -ur src.orig/gcc/tree-check.c src/gcc/tree-check.c
 237 --- src.orig/gcc/tree-check.c	Sun Apr 15 00:14:58 2007
 238 +++ src/gcc/tree-check.c	Sat Jan 19 15:03:21 2008
 239 @@ -120,25 +120,153 @@
 240      return 1; /* follow_all */
 241  }
 242  
 243 +static int 
 244 +check_node1 (cfg_node node, condate cond) 
 245 +{
 246 +   tree stmt = cfg_node_stmt (node);
 247 + 
 248 +   if (!stmt || TREE_VISITED (stmt))
 249 +     return 0;
 250 + 
 251 +   TREE_VISITED (stmt) = 1;
 252 + 
 253 +     
 254 +   if (tree_match_disj (stmt, cond->to, node))
 255 +     {
 256 +       return 2;  /* follow_none */
 257 +     }
 258 + 
 259 +
 260 +   if (cond->avoid && tree_match_disj (stmt, cond->avoid, node))
 261 +     {
 262 +/*       tree_check_warning (cond, stmt, OPT_ftree_checks_);*/
 263 +       return -1; /* follow_none */;
 264 +     }
 265 +   else
 266 +     return 1; /* follow_all */
 267 +}
 268 +
 269 +
 270 +static int 
 271 +check_node2 (cfg_node node, condate cond, int matchstage) 
 272 +{
 273 +   tree stmt = cfg_node_stmt (node);
 274 + 
 275 +   if (!stmt || TREE_VISITED (stmt))
 276 +     return 0;
 277 + 
 278 +
 279 +   TREE_VISITED (stmt) = 1;
 280 + 
 281 +     
 282 +   if (tree_match_disj (stmt, cond->to, node))
 283 +     {
 284 +	VEC (cfg_node, heap) *follow = VEC_alloc (cfg_node, heap, 100);
 285 +	VEC (tree, heap) *stmts = VEC_alloc(tree, heap, 200);
 286 +	VEC_safe_push(cfg_node, heap, follow, node);
 287 +	TREE_VISITED(stmt) = 0;
 288 +	int followmatch = 0;
 289 +	while (VEC_length (cfg_node, follow) != 0) {
 290 +		tree stmt1;
 291 +		cfg_node node1, succ_node;
 292 +		node1 = VEC_pop (cfg_node, follow);
 293 +		stmt1 = cfg_node_stmt (node1);
 294 +		if (!stmt1 || stmt1->base.spare == 2)
 295 +			continue;
 296 +		VEC_safe_push(tree, heap, stmts, (tree)stmt1->base.spare);
 297 +		VEC_safe_push(tree, heap, stmts, stmt1);
 298 +		stmt1->base.spare = 2;
 299 +
 300 +		if (tree_match_disj (stmt1, cond->follow, node1))
 301 +		{
 302 +		  	if (cond->fromappearatleastonce == 0 && !matchstage)
 303 +			      tree_check_warning (cond, stmt, OPT_ftree_checks_);
 304 +			followmatch = 1;
 305 +			break;
 306 +		}
 307 +		if (node1->next == NULL)
 308 +	    	{
 309 +			edge e;
 310 +			edge_iterator ei;
 311 +			basic_block bb;
 312 +			bb = bb_for_stmt (stmt1);
 313 +			FOR_EACH_EDGE (e, ei, bb->succs)
 314 +		        {
 315 +			if (e->dest == EXIT_BLOCK_PTR) 
 316 +				continue;
 317 +			succ_node = bb_1st_cfg_node (e->dest);
 318 +			VEC_safe_push (cfg_node, heap, follow, succ_node);
 319 +			}
 320 +		} else {
 321 +			succ_node = node1->next;
 322 +			VEC_safe_push (cfg_node, heap, follow, succ_node);
 323 +		}
 324 +	}
 325 +	while (VEC_length (tree, stmts) != 0) {
 326 +		tree stmt1;
 327 +		stmt1 = VEC_pop (tree, stmts);
 328 +		stmt1->base.spare = (int )VEC_pop(tree, stmts);
 329 +	}
 330 +   	if (!matchstage)
 331 +		TREE_VISITED(stmt) = 1;
 332 +	VEC_free (cfg_node, heap, follow);
 333 +	VEC_free (tree, heap, stmts);
 334 +	if (followmatch)
 335 +		return 2;  
 336 +	else 
 337 +		return 0;
 338 +     }
 339 +
 340 +   if (matchstage)
 341 +	return 0;
 342 +
 343 +   if (cond->avoid && tree_match_disj (stmt, cond->avoid, node))
 344 +     {
 345 +       return -1; /* follow_none */;
 346 +     }
 347 +   else
 348 +     return 1; /* follow_all */
 349 +}
 350 +
 351 +
 352 +
 353  /* Check a condate instance over the CFG of the current function.  */
 354  
 355 -static void 
 356 +static int
 357  tree_check_instance (condate cond)
 358  {
 359    VEC (cfg_node, heap) *stack = VEC_alloc (cfg_node, heap, 100);
 360    basic_block bb;
 361    cfg_node node;
 362    tree stmt;
 363 +  int checkedonce = 0;
 364 +
 365  
 366    PP_TRACE (TRACE_CHECK, {
 367      fprintf (stderr, "checking condate instance:\n");
 368      print_global_holes ();
 369    });
 370  
 371 +
 372    /* Push from nodes on the stack.  */
 373    PP_TRACE (TRACE_CHECK, fprintf (stderr, "searching src pat %s\n", 
 374  				  cond->from->format_spec));
 375 +  if (!strncmp(cond->from->format_spec, "entry", 5)){
 376 +	edge e;
 377 +	edge_iterator ei;
 378 +	FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
 379 +	{
 380 +	      if (e->dest == EXIT_BLOCK_PTR) 
 381 +		continue;
 382 +		node = bb_1st_cfg_node (e->dest);
 383 +		stmt = cfg_node_stmt (node);
 384 +		if (stmt)
 385 +        	        TREE_VISITED (stmt) = 1;
 386 +		VEC_safe_push (cfg_node, heap, stack, node);
 387 +	}
 388  
 389 +  } else {
 390 +  
 391    FOR_EACH_BB (bb)
 392      {
 393        block_stmt_iterator bsi;
 394 @@ -172,10 +300,62 @@
 395  		print_generic_expr (stderr, stmt, 0);
 396  		fprintf (stderr, "\n");
 397  	      });
 398 -	    }
 399 +	    }  else if (bsi_cfg_node (bsi)->next == NULL && 
 400 +			TREE_CODE(stmt) == COND_EXPR) {
 401 +		edge e;
 402 +		edge_iterator ei;
 403 +		basic_block bb;
 404 +		bb = bb_for_stmt(stmt);
 405 +		node = bsi_cfg_node (bsi);
 406 +
 407 +		FOR_EACH_EDGE(e, ei, bb->succs)
 408 +		 {
 409 +			if (e->flags&EDGE_TRUE_VALUE) {
 410 +				pattern patttmp = patt;
 411 +				while (patttmp) {
 412 +					if (patttmp->sign == 1 && 
 413 +						(tree_match_prevstmt(COND_EXPR_COND (stmt),
 414 +	                                                         patttmp->format_spec, node)||
 415 +						 tree_match(COND_EXPR_COND(stmt), 
 416 +								patttmp->format_spec, node))) 
 417 +					{
 418 +					      tree stmt1;
 419 +					      cfg_node succ_node;
 420 +	                                      succ_node = bb_1st_cfg_node (e->dest);
 421 +					      stmt1 = cfg_node_stmt (succ_node);
 422 +  					      VEC_safe_push (cfg_node, heap, stack, succ_node);
 423 +					      if (stmt1) 
 424 +						TREE_VISITED (stmt1) = 1;
 425 +					}
 426 +					patttmp = patttmp->next;
 427 +				}
 428 +			}
 429 +			if (e->flags&EDGE_FALSE_VALUE) {
 430 +				pattern patttmp = patt;
 431 +				while (patttmp) {
 432 +					if (patttmp->sign == -1 && 
 433 +						(tree_match_prevstmt(COND_EXPR_COND (stmt),
 434 +	                                                         patttmp->format_spec, node)||
 435 +						 tree_match(COND_EXPR_COND(stmt), 
 436 +								patttmp->format_spec, node))) 
 437 +					{
 438 +					      tree stmt1;
 439 +					      cfg_node succ_node;
 440 +	                                      succ_node = bb_1st_cfg_node (e->dest);
 441 +					      stmt1 = cfg_node_stmt (succ_node);
 442 +  					      VEC_safe_push (cfg_node, heap, stack, succ_node);
 443 +					      if (stmt1) 
 444 +						TREE_VISITED (stmt1) = 1;
 445 +					}
 446 +					patttmp = patttmp->next;
 447 +				}
 448 +			}
 449 +				
 450 +		}
 451  	}
 452 -    }
 453 -
 454 +     }
 455 +   }
 456 +  }
 457    PP_TRACE (TRACE_CHECK, fprintf (stderr, "%d src stmts found\n", 
 458  				  (unsigned) VEC_length (cfg_node, stack)));
 459  
 460 @@ -201,43 +381,119 @@
 461  		continue;
 462  
 463  	      if (TREE_CODE (stmt) == COND_EXPR
 464 -		  && (e->flags & EDGE_TRUE_VALUE && cond->avoid_then
 465 -		      && tree_match_disj (COND_EXPR_COND (stmt), cond->avoid_then, 
 466 -					  node)))
 467 +		  && (e->flags & EDGE_TRUE_VALUE && cond->avoid_then))
 468  		{
 469 -		  PP_TRACE (TRACE_CHECK, 
 470 -			    fprintf (stderr, "via-then edge, skipping\n"));
 471 -		  continue;
 472 +		     if( tree_match_disj (COND_EXPR_COND (stmt), cond->avoid_then, 
 473 +					  node))
 474 +			{
 475 +		  		PP_TRACE (TRACE_CHECK, 
 476 +				    fprintf (stderr, "via-then edge, skipping\n"));
 477 +				  continue;
 478 +			} else if (node->prev &&  tree_match_prevstmt_disj(COND_EXPR_COND (stmt),
 479 +							cond->avoid_then, node))
 480 +			{		
 481 +		  		PP_TRACE (TRACE_CHECK, 
 482 +				    fprintf (stderr, "via-then edge, skipping\n"));
 483 +				  continue;
 484 +			}
 485  		}
 486 +		      
 487  
 488  	      if (TREE_CODE (stmt) == COND_EXPR
 489 -		  && (e->flags & EDGE_FALSE_VALUE && cond->avoid_else
 490 -		      && tree_match_disj (COND_EXPR_COND (stmt), cond->avoid_else, 
 491 -					  node)))
 492 +		  && (e->flags & EDGE_FALSE_VALUE && cond->avoid_else))
 493  		{
 494 -		  PP_TRACE (TRACE_CHECK, 
 495 +			if (tree_match_disj (COND_EXPR_COND (stmt), cond->avoid_else, 
 496 +					  node))
 497 +			{
 498 +			  PP_TRACE (TRACE_CHECK, 
 499  			    fprintf (stderr, "via-else edge, skipping\n"));
 500 -		  continue;
 501 +			  continue;
 502 +			} else if (node->prev &&  tree_match_prevstmt_disj(COND_EXPR_COND (stmt),
 503 +							cond->avoid_else, node))
 504 +			{		
 505 +		  		PP_TRACE (TRACE_CHECK, 
 506 +				    fprintf (stderr, "via-then edge, skipping\n"));
 507 +				  continue;
 508 +			}
 509  		}
 510  
 511  	      succ_node = bb_1st_cfg_node (e->dest);
 512 -	      push_it = check_node (succ_node, cond);
 513  
 514 -	      if (push_it)
 515 -		VEC_safe_push (cfg_node, heap, stack, succ_node);
 516 -	    }
 517 +	      if (cond->fromappearatleastonce == 0 && cond->follow == NULL) {
 518 +		      push_it = check_node (succ_node, cond);
 519 +		      if (push_it) 
 520 +			VEC_safe_push (cfg_node, heap, stack, succ_node);
 521 +	      }else if (cond->follow == NULL) {
 522 +		      switch (check_node1(succ_node, cond)) 
 523 +			{
 524 +				case 1:
 525 +					VEC_safe_push (cfg_node, heap, stack, succ_node);
 526 +					break;
 527 +				case 2:
 528 +					checkedonce = 1;
 529 +					goto out;
 530 +				default:
 531 +					break;
 532 +			}
 533 +
 534 +	      }else {
 535 +		     switch (check_node2(succ_node, cond, 0))
 536 +			{
 537 +				case 1:
 538 +					VEC_safe_push (cfg_node, heap, stack, succ_node);
 539 +					break;
 540 +				case 2:
 541 +					if (cond->fromappearatleastonce != 0){
 542 +						checkedonce = 1;
 543 +						goto out;
 544 +					}
 545 +				default:
 546 +					break;
 547 +			}
 548 +	      }
 549 +	 }
 550  	}
 551        else
 552  	{
 553  	  succ_node = node->next;
 554 -	  push_it = check_node (succ_node, cond);
 555  
 556 -	  if (push_it)
 557 -	    VEC_safe_push (cfg_node, heap, stack, succ_node);
 558 +	  if (cond->fromappearatleastonce == 0 && cond->follow == NULL) {
 559 +		   push_it = check_node (succ_node, cond);
 560 +		   if (push_it) 
 561 +		      VEC_safe_push (cfg_node, heap, stack, succ_node);
 562 +          }else if (cond->follow == NULL) {
 563 +	      switch (check_node1(succ_node, cond)) 
 564 +		{
 565 +			case 1:
 566 +				VEC_safe_push (cfg_node, heap, stack, succ_node);
 567 +				break;
 568 +			case 2: 
 569 +				checkedonce = 1;
 570 +				goto out;
 571 +			default:
 572 +	  			break;
 573 +		}
 574 +
 575 +         }else {
 576 +		     switch (check_node2(succ_node, cond, 0))
 577 +			{
 578 +				case 1:
 579 +					VEC_safe_push (cfg_node, heap, stack, succ_node);
 580 +					break;
 581 +				case 2:
 582 +					if (cond->fromappearatleastonce != 0){
 583 +						checkedonce = 1;
 584 +						goto out;
 585 +					}
 586 +				default:
 587 +					break;
 588 +			}
 589 +	      }
 590  	}
 591      }
 592 -
 593 +out:
 594    VEC_free (cfg_node, heap, stack);
 595 +  return checkedonce;
 596  }
 597  
 598  /* Collect new condate instances.  An instance is new if the
 599 @@ -303,7 +559,11 @@
 600  {
 601    VEC (hole_p, heap) *stack;
 602    pattern patt = cond->from;
 603 +  pattern patt1 = cond->to;
 604 +  pattern patt2 = cond->function;
 605    basic_block bb;
 606 +  int checkedonce = 0;
 607 +  argument_holes = 0;
 608  
 609    /* Check for trivial condates.  */
 610    if (!cond->to)
 611 @@ -311,15 +571,86 @@
 612        tree_scan (cond);
 613        return;
 614      }
 615 +  
 616 +  if (patt2) {
 617 +     int i=0;
 618 +     char *savedstr = xstrdup(patt2->format_spec);
 619 +     while (savedstr[i] != ' ' && savedstr[i] != '(' && savedstr[i] != 0)
 620 +	i++;
 621 +     savedstr[i] = 0;
 622 +     while (patt2) {
 623 +	if (!strcmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)),savedstr))
 624 +	{
 625 +		break;
 626 +	}
 627 +	patt2 = patt2->next;
 628 +    }
 629 +    free(savedstr);
 630 +    if (!patt2)
 631 +	return;
 632 +  }
 633  
 634    /* Allocate stack for collecting condate instances.  */
 635    stack = VEC_alloc (hole_p, heap, 10);
 636    patt = cond->from;
 637 +
 638 +  tree_clean_typenames();
 639 +
 640 +  if (cond->types) 
 641 +	tree_parse_typenames(cond->types);
 642 +  
 643 +  patt1 = cond->to;
 644 +
 645    
 646    PP_TRACE (TRACE_CHECK, 
 647  	    fprintf (stderr, "searching src pat %s\n", 
 648  		     patt->format_spec));
 649  
 650 +  if (patt2){
 651 +	char * argstart;
 652 +	int j = 1;
 653 +	//patt_info patt;
 654 +	int res = 0;
 655 +	char arg[3] = {'%','_',0} ;
 656 +	tree p, parms;
 657 +	int i = strlen(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
 658 +	argstart = patt2->format_spec;
 659 +	while (argstart[i] != '(' && argstart[i] != 0)
 660 +	  i++;
 661 +	if (argstart[i] == 0)
 662 +		goto cont;	
 663 +	reset_global_holes ();
 664 +	i++;
 665 +	while (argstart[i] == ' ')
 666 +		i++;
 667 +	parms = DECL_ARGUMENTS(current_function_decl);
 668 +	for (p = parms; p; p = TREE_CHAIN(p)){
 669 +		if (argstart[i] != '%'){
 670 +			fprintf(stderr, "expect a hole description\n");	
 671 +			goto cont;
 672 +		}
 673 +		i++;
 674 +		arg[1] = argstart[i];
 675 +		res = tree_match (p, arg, 0);
 676 +//		res = match_tree_pattinfo (p, &patt, "", 0, 0, 0);
 677 +		if (!res) {
 678 +			fprintf(stderr, "error matching %dth argument\n", j);
 679 +			goto cont;
 680 +		}
 681 +		while (argstart[i] != ',' && argstart[i] != ')')
 682 +			i++;
 683 +		if (argstart[i] == ')'){
 684 +			argument_holes = save_global_holes();
 685 +			break;
 686 +		}	
 687 +		i++;
 688 +		while (argstart[i] == ' ')
 689 +			i++;
 690 +		j++;
 691 +	}
 692 +  }
 693 +cont:
 694 +
 695    FOR_EACH_BB (bb)
 696      {
 697        block_stmt_iterator bsi;
 698 @@ -327,8 +658,8 @@
 699  
 700        for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
 701  	{
 702 +	  cfg_node node = bsi_cfg_node(bsi);
 703  	  stmt = bsi_stmt (bsi);
 704 -
 705  	  PP_TRACE (TRACE_MATCH, {
 706  	    lazy_print_generic_expr (stderr, stmt, 0);
 707  	    fprintf (stderr, "= ");
 708 @@ -336,8 +667,100 @@
 709  	    fprintf (stderr, "\n");
 710  	  });
 711  
 712 -	  if (!patt || tree_match_disj (stmt, patt, bsi_cfg_node (bsi)))
 713 -	    push_global_holes_if_new (stack);
 714 +	  if (patt && patt->format_spec && !strncmp(patt->format_spec, "entry", 5)) {
 715 +		if (tree_match_disj (stmt, patt1, bsi_cfg_node (bsi))) {
 716 +			if (cond->match ) {
 717 +			    cfg_node node1 = bsi_cfg_node(bsi)->prev;
 718 +			    while(node1){
 719 +				if (tree_match_disj (cfg_node_stmt(node1), cond->match, node1))
 720 +					break;
 721 +				node1 = node1->prev;
 722 +        	            }
 723 +			    if (node1) {
 724 +				if (cond->follow) {
 725 +				  if ( check_node2(bsi_cfg_node(bsi), cond, 1) == 2)
 726 +			                push_global_holes_if_new (stack);
 727 +				}else 
 728 +		                push_global_holes_if_new (stack);
 729 +			    }	
 730 +			} else 	if (cond->follow) {
 731 +			  if ( check_node2(bsi_cfg_node(bsi), cond, 1) == 2)
 732 +		                push_global_holes_if_new (stack);
 733 +			}else
 734 +	                push_global_holes_if_new (stack);
 735 +			
 736 +		}
 737 +          
 738 +	  }else if (!patt || tree_match_disj (stmt, patt, bsi_cfg_node (bsi))){
 739 +		if (cond->match ) {
 740 +		    cfg_node node1 = bsi_cfg_node(bsi)->prev;
 741 +		    while(node1){
 742 +			if (tree_match_disj (cfg_node_stmt(node1), cond->match, node1))
 743 +				break;
 744 +			node1 = node1->prev;
 745 +        	    }
 746 +		    if (node1)
 747 +		               push_global_holes_if_new (stack);
 748 +		} else 
 749 +		push_global_holes_if_new (stack);
 750 +	  }
 751 +	   else if (node->next == NULL && 
 752 +			TREE_CODE(stmt) == COND_EXPR) {
 753 +		edge e;
 754 +		edge_iterator ei;
 755 +		basic_block bb;
 756 +		bb = bb_for_stmt(stmt);
 757 +		FOR_EACH_EDGE(e, ei, bb->succs)
 758 +		 {
 759 +			if (e->flags&EDGE_TRUE_VALUE) {
 760 +				pattern patttmp = patt;
 761 +				while (patttmp) {
 762 +					if (patttmp->sign == 1 && 
 763 +						(tree_match_prevstmt(COND_EXPR_COND (stmt),
 764 +	                                                         patttmp->format_spec, node)||
 765 +						 tree_match(COND_EXPR_COND(stmt), 
 766 +								patttmp->format_spec, node))) {
 767 +		        	  		if (cond->match ) {
 768 +						    cfg_node node1 = bsi_cfg_node(bsi)->prev;
 769 +						    while(node1){
 770 +							if (tree_match_disj (cfg_node_stmt(node1), cond->match, node1))
 771 +								break;
 772 +							node1 = node1->prev;
 773 +				        	    }
 774 +						    if (node1)
 775 +					               push_global_holes_if_new (stack);
 776 +						} else 
 777 +  						push_global_holes_if_new (stack);
 778 +					}
 779 +					patttmp = patttmp->next;
 780 +				}
 781 +			}
 782 +			if (e->flags&EDGE_FALSE_VALUE) {
 783 +				pattern patttmp = patt;
 784 +				while (patttmp) {
 785 +					if (patttmp->sign == -1 && 
 786 +						(tree_match_prevstmt(COND_EXPR_COND (stmt),
 787 +	                                                         patttmp->format_spec, node)||
 788 +						 tree_match(COND_EXPR_COND(stmt), 
 789 +								patttmp->format_spec, node))) {
 790 +		        	  		if (cond->match ) {
 791 +						    cfg_node node1 = bsi_cfg_node(bsi)->prev;
 792 +						    while(node1){
 793 +							if (tree_match_disj (cfg_node_stmt(node1), cond->match, node1))
 794 +								break;
 795 +							node1 = node1->prev;
 796 +				        	    }
 797 +						    if (node1)
 798 +					               push_global_holes_if_new (stack);
 799 +						} else 
 800 +  						push_global_holes_if_new (stack);
 801 +					}
 802 +					patttmp = patttmp->next;
 803 +				}
 804 +			}
 805 +				
 806 +		}
 807 +	   }  
 808  	}
 809      }
 810  
 811 @@ -349,11 +772,16 @@
 812        hole_p h = VEC_pop (hole_p, stack);
 813  
 814        restore_global_holes (h);
 815 -      tree_check_instance (cond);
 816 +      checkedonce = tree_check_instance (cond);
 817        PP_TRACE (TRACE_CHECK, fprintf (stderr, "recounting stmts\n"));
 818 -      tree_check_init (); /* clear visited flag */
 819 +      tree_check_init ();
 820      }
 821  
 822 +  if (cond->fromappearatleastonce && !checkedonce) {
 823 +      tree_check_warning (cond, bsi_stmt(bsi_start(ENTRY_BLOCK_PTR->next_bb)), OPT_ftree_checks_);
 824 +  }
 825 +  free(argument_holes);
 826 +  argument_holes = 0;
 827    VEC_free (hole_p, heap, stack);
 828  }
 829  
 830 @@ -393,6 +821,7 @@
 831  
 832      tree_check (cond);
 833    }
 834 +
 835  }
 836  
 837  condate conds[CONDMAX];  /* list of condated to check */
 838 @@ -481,7 +910,7 @@
 839        if (!current_check_string) 
 840  	{
 841  	  condate cond = mkcond (tree_check_string, mkpat (tree_check_string), 
 842 -				 NULL, NULL, NULL, NULL);
 843 +				 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0);
 844  	  add_condate (cond);
 845  	  current_check_string = tree_check_string;
 846  	}
 847 Only in src/gcc: tree-check.c.back
 848 Only in src/gcc: tree-check.c~
 849 Only in src/gcc: tree-inline.c~
 850 diff -ur src.orig/gcc/tree-match.c src/gcc/tree-match.c
 851 --- src.orig/gcc/tree-match.c	Sun Apr 15 00:14:13 2007
 852 +++ src/gcc/tree-match.c	Wed Jan 16 11:15:23 2008
 853 @@ -45,7 +45,7 @@
 854  
 855  hole global_holes[GLOBAL_MAX];
 856  hole local_holes[LOCAL_MAX];
 857 -
 858 +hole *argument_holes;
 859  /* Check whether a variable is a temporary introduced by the compiler.  */
 860  
 861  static bool 
 862 @@ -270,23 +270,28 @@
 863    return s[0];
 864  }
 865  
 866 -static bool match_tree_pattinfo (tree, patt_info *, const char *, cfg_node);
 867 +static bool match_tree_pattinfo (tree, patt_info *, const char *, cfg_node, int i, tree tsave1);
 868  
 869  /* Worker function for match_tree_pattinfo.  Matches a lazy list with
 870     a pattern.  */
 871  
 872  static bool 
 873  match_chunks_pattinfo (VEC (tree_chunk, heap) *chunks, patt_info *patt,
 874 -		       const char *delim, cfg_node ctx_node)
 875 +		       const char *delim, cfg_node ctx_node, int j, tree tsave)
 876  {
 877    unsigned int i;
 878    tree_chunk chunk;
 879 +  
 880 +  if (j > 20)
 881 +	return 0;
 882  
 883    for (i = 0; VEC_iterate (tree_chunk, chunks, i, chunk); i++)
 884      {
 885        if (chunk->t)
 886  	{
 887  	  /* Compute delimiter for t.  */
 888 +	  if (chunk->t == tsave)
 889 +		return 0;
 890  	  char next_char = (i + 1 == VEC_length (tree_chunk, chunks) ?
 891  			    *delim : 
 892  			    chunk_1st_char (chunks_lookahead (chunks, i + 1)));
 893 @@ -299,7 +304,7 @@
 894  	    fprintf (stderr, ", \"%s\") ", patt->format_spec);
 895  	  });
 896  
 897 -	if (!match_tree_pattinfo (chunk->t, patt, &next_char, ctx_node))
 898 +	if (!match_tree_pattinfo (chunk->t, patt, &next_char, ctx_node, ++j, tsave))
 899  	  {
 900  	    PP_TRACE (TRACE_MATCH_STEPS,
 901  		      fprintf (stderr, "=> fail tree chunk} "));
 902 @@ -385,10 +390,11 @@
 903     you have a pattern with named holes.  The ctx_node (if non-null)
 904     indicates the cfg_node where the tree is supposed to occur, in case
 905     some tmp vars are to be searched for from this point backwards.  */
 906 +struct entry_type *type_chain = 0;
 907  
 908  static bool
 909  match_tree_pattinfo (tree t, patt_info *patt, const char *delim, 
 910 -		     cfg_node ctx_node)
 911 +		     cfg_node ctx_node, int i, tree tsave1)
 912  {
 913    tree *pt;
 914    hole *ph = NULL;
 915 @@ -422,9 +428,17 @@
 916  	    { 
 917  	      /* var hole */
 918  	      /* refuse to catch a tmpvar def */
 919 -	      if (is_tmp_var (t) && ctx_node &&
 920 -		  (tree_scanf (cfg_node_stmt (ctx_node), "%t = %_", NULL, &t)
 921 -		   || tree_scanf (cfg_node_stmt (ctx_node), "%t = (%_)%_",
 922 +		struct entry_type *entry_type;	 
 923 +		int typesize, j, i = 0;
 924 +		VEC (tree_chunk, heap) *chunks;
 925 +		tree_chunk chunk;
 926 +
 927 +		tree tmp;
 928 +		if (is_tmp_var(t) && patt->format_spec[1] == 'T')
 929 +			goto settmp;
 930 +		if (is_tmp_var (t) && ctx_node &&
 931 +			(tree_scanf (cfg_node_stmt (ctx_node), "%t = %_", NULL, &t)
 932 +			|| tree_scanf (cfg_node_stmt (ctx_node), "%t = (%_)%_",
 933  				  NULL, &t)))
 934  		{
 935  		  PP_TRACE (TRACE_MATCH_STEPS, 
 936 @@ -432,12 +446,67 @@
 937  				     "refusing to assign tmpvar def to global hole"));
 938  		  return 0;
 939  		}
 940 -
 941 -	      PP_TRACE (TRACE_MATCH_STEPS, 
 942 +	      
 943 +	      
 944 +		PP_TRACE (TRACE_MATCH_STEPS, 
 945  			fprintf (stderr, "assign tree chunk to hole"));
 946 -	      *pt = t;
 947 -	      if (ph)
 948 -		ph->ctx = ctx_node;
 949 +settmp:
 950 +
 951 +	        entry_type = type_chain;
 952 +
 953 +		while (entry_type) {
 954 +			if (*entry_type->holename == patt->format_spec[1])
 955 +				break;
 956 +			entry_type = entry_type->next;
 957 +		}
 958 +	      		
 959 +			
 960 +		if (!entry_type)
 961 +			goto setit;
 962 +		
 963 +
 964 +		if (!TREE_TYPE(t))
 965 +			goto out;
 966 +
 967 +		tmp = TREE_TYPE(t);
 968 +		maybe_init_pretty_print(stdout);
 969 +		chunks = nolazy_dump_generic_node(tmp, 0, false);
 970 +		
 971 +		typesize = strlen(entry_type->typename);
 972 +		for (j = 0; VEC_iterate (tree_chunk, chunks, j, chunk); j++)
 973 +		{
 974 +			if (chunk->s)
 975 +			{
 976 +				if (memcmp(entry_type->typename + i, chunk->s ,
 977 +					strlen(chunk->s))) {
 978 +					pp_free_list(chunks);
 979 +					goto out;
 980 +				}
 981 +				i += strlen(chunk->s);
 982 +			} else {
 983 +				if (chunk->c == ' ')
 984 +				{
 985 +					while (entry_type->typename[i] == ' ')
 986 +						i++;
 987 +				} else if (chunk->c != entry_type->typename[i])
 988 +				{
 989 +					pp_free_list(chunks);
 990 +					goto out;
 991 +				}else 
 992 +				i++;
 993 +			}
 994 +		}
 995 +		pp_free_list(chunks);
 996 +		goto setit;
 997 +
 998 +	      out:				
 999 +		return 0;
1000 +
1001 +	      setit:
1002 +	      	*pt = t;
1003 +		if (ph)
1004 +			ph->ctx = ctx_node;
1005 +
1006  	    }
1007  	  else
1008  	    {
1009 @@ -460,7 +529,9 @@
1010      {
1011        /* Can't swallow a whole tree, must recurse on it.  */
1012        VEC (tree_chunk, heap) *chunks;
1013 -
1014 +      tree tsave;
1015 +      int j;
1016 +      tree_chunk chunk;
1017        PP_TRACE (TRACE_MATCH_STEPS, fprintf (stderr, "check chunks vs patt"));
1018  
1019        /* Check an eventual pattern-only '(' to be skipped.  */
1020 @@ -472,16 +543,27 @@
1021  
1022        /* On a tmpvar or a cast, there is no point to recurse directly (they
1023  	 cannot be in the pattern), so substitute it before.  */
1024 +      tsave = 0;
1025        while ((val = substitute_tmp_var (t, ctx_node, false)) != NULL
1026  	     || (val = substitute_cast_expr (t)) != NULL)
1027  	{
1028  	  PP_TRACE (TRACE_MATCH_STEPS, fprintf (stderr, "succeed subst tmp"));
1029 +	  tsave = t;
1030  	  t = val;
1031  	}
1032  
1033        maybe_init_pretty_print (stdout);
1034        chunks = lazy_dump_generic_node (t, 0, false);
1035 -      res = match_chunks_pattinfo (chunks, patt, delim, ctx_node);
1036 +      for (j = 0; VEC_iterate (tree_chunk, chunks, j, chunk); j++)
1037 +      {
1038 +        if (chunk->t && chunk->t == tsave1) {
1039 +		res = 0;
1040 +		goto out1;
1041 +	}
1042 +      }
1043 +      res = match_chunks_pattinfo (chunks, patt, delim, ctx_node, ++i, tsave);
1044 +
1045 +out1:
1046        pp_free_list (chunks);
1047        PP_TRACE (TRACE_MATCH_STEPS, fprintf (stderr, "%s chunks vs patt",
1048  					    (res? "succeed": "fail")));
1049 @@ -538,6 +620,13 @@
1050        global_holes[i].tree = NULL;
1051        global_holes[i].ctx = NULL;
1052      }
1053 +  if (argument_holes) {
1054 +   for (i=0; i<GLOBAL_MAX; i++) 
1055 +    {
1056 +      global_holes[i].tree = argument_holes[i].tree;
1057 +      global_holes[i].ctx = NULL;
1058 +    }
1059 +  }
1060  }
1061  
1062  /* Unbind all local variables.  */
1063 @@ -649,7 +738,7 @@
1064        print_generic_expr (stderr, t, 0); 
1065        fprintf (stderr, ", \"%s\") ", fmt);
1066      });
1067 -  res = match_tree_pattinfo (t, &patt, "", ctx_node);
1068 +  res = match_tree_pattinfo (t, &patt, "", ctx_node, 0, 0);
1069    PP_TRACE (TRACE_MATCH_STEPS, fprintf (stderr, "} "));
1070    va_end (ap);
1071  
1072 @@ -667,12 +756,24 @@
1073  {
1074    patt_info patt;
1075    bool res;
1076 -  hole *old_global_holes = save_global_holes ();
1077 +  const char *c;	
1078 +  hole *old_global_holes;
1079 + 
1080 +  c = fmt;
1081 +  if (!c)
1082 +	return false;
1083 +
1084 +  while (*c != 0) {	
1085 +	if (*c == ';')
1086 +		return false;
1087 +	c++;
1088 +  }
1089  
1090 +  old_global_holes  = save_global_holes ();
1091    patt.args_ptr = NULL;
1092    patt.format_spec = fmt;
1093    reset_local_holes (); 
1094 -  res = match_tree_pattinfo (t, &patt, "", ctx_node);
1095 +  res = match_tree_pattinfo (t, &patt, "", ctx_node, 0, 0);
1096    PP_TRACE (TRACE_MATCH_STEPS, 
1097  	    fprintf (stderr, "=>match returned %d, and fmt='%s'\n", 
1098  		     res, patt.format_spec));
1099 @@ -697,4 +798,180 @@
1100  
1101    return (tree_match (t, patt->format_spec, ctx_node) 
1102  	  || (patt->next && tree_match_disj (t, patt->next, ctx_node)));
1103 +}
1104 +
1105 +bool 
1106 +tree_match_prevstmt (tree t, const char *fmt, cfg_node ctx_node)
1107 +{
1108 +
1109 +  patt_info patt;
1110 +  bool res;
1111 +  char *c, *c1;	
1112 +  char *fmt1;
1113 +  hole *old_global_holes;
1114 +  cfg_node node_prev; 
1115 +  tree prev_stmt;
1116 +  fmt1 = xstrdup(fmt);
1117 +  c = fmt1;
1118 +
1119 +  if (!c)
1120 +	return false;
1121 +
1122 +  while (*c != 0) {	
1123 +	if (*c == ';')
1124 +		break;
1125 +	c++;
1126 +  }
1127 +
1128 +  if (*c == 0) {
1129 +	free(fmt1);
1130 +	return false;
1131 +  }
1132 +  
1133 +  c1 = c;
1134 +  while (*(c1 -1) == ' ')
1135 +     c1--;
1136 +
1137 +  *c1 = 0;
1138 +
1139 +  c++;
1140 +  
1141 +  while (*c == ' ')
1142 +	c++;
1143 +
1144 +  old_global_holes  = save_global_holes ();
1145 +  patt.args_ptr = NULL;
1146 +  patt.format_spec = c;
1147 +  reset_local_holes (); 
1148 +  res = match_tree_pattinfo (t, &patt, "", ctx_node, 0, 0);
1149 +
1150 +  /* nothing left in the pattern ? */
1151 +  if (res && (*patt.format_spec == '\0'))
1152 +    ;
1153 +  else
1154 +    {
1155 +      free(fmt1);	   
1156 +      restore_global_holes (old_global_holes); /* unbind global holes */
1157 +      return false;
1158 +    }
1159 +
1160 +  node_prev = ctx_node->prev; 
1161 +  while (node_prev) {
1162 +  	patt.args_ptr = NULL;
1163 +	patt.format_spec = fmt1;
1164 +	prev_stmt =  cfg_node_stmt(node_prev);
1165 +	res = match_tree_pattinfo (prev_stmt, &patt, "", node_prev, 0, 0);
1166 +	if (res && (*patt.format_spec == '\0'))
1167 +	    {
1168 +	      restore_global_holes (old_global_holes); /* unbind global holes */
1169 +	      free(fmt1);
1170 +	      return true;
1171 +	    }	
1172 +	else if (patt.format_spec != fmt1)
1173 +	    {
1174 +	      restore_global_holes (old_global_holes); 
1175 +	      free(fmt1);
1176 +	      return false;
1177 +	    }
1178 +	node_prev = node_prev->prev;
1179 +
1180 +  }
1181 +  free(fmt1);	   
1182 +  restore_global_holes (old_global_holes); /* unbind global holes */
1183 +  return false;
1184 +}
1185 +
1186 +
1187 +bool 
1188 +tree_match_prevstmt_disj (tree t, pattern patt, cfg_node ctx_node)
1189 +{
1190 +  if (!patt)
1191 +    return false;
1192 +
1193 +  return (tree_match_prevstmt (t, patt->format_spec, ctx_node) 
1194 +	  || (patt->next && tree_match_prevstmt_disj (t, patt->next, ctx_node)));
1195 +}
1196 +
1197 +bool tree_parse_typenames(const char * typenames)
1198 +{
1199 +
1200 +	int typesize, i;
1201 +	char *typenamesave, *typenamescur;
1202 +	if (!typenames || strlen(typenames) < 3)
1203 +		return false;
1204 +
1205 +
1206 +	typesize = strlen(typenames);
1207 +
1208 +      	typenamesave = typenamescur = xstrdup(typenames);
1209 +	i = typesize;
1210 +
1211 +	while (1) {
1212 +		int j;
1213 +		struct entry_type * entry_type, *tmp, *prev;
1214 +
1215 +		while (typenamescur[i-1] == ' '){
1216 +			i--;
1217 +		}
1218 +		if (i == 1)
1219 +			break;
1220 +
1221 +		typenamescur[i] = 0;
1222 +
1223 +		while (typenamescur [i-1] != '%')
1224 +			i--;
1225 +
1226 +		entry_type = xmalloc(sizeof(struct entry_type));
1227 +		entry_type->holename = xmalloc(sizeof(char));
1228 +		*entry_type->holename = typenamescur[i];
1229 +		j = i+1;
1230 +
1231 +		while (typenamescur[j] == ' ')
1232 +			j++;
1233 +		
1234 +
1235 +		while (typenamescur[j] == ' ')
1236 +			j++;
1237 +		
1238 +		entry_type->typename = xstrdup(typenamescur + j);
1239 +
1240 +		if (type_chain == 0) {
1241 +                	type_chain = entry_type;
1242 +			entry_type->next = 0;
1243 +			entry_type->prev = 0;
1244 +			continue;
1245 +		}
1246 +
1247 +	        tmp = prev = type_chain;
1248 +	        while (tmp) {
1249 +        	        prev = tmp;
1250 +                	tmp = tmp->next;
1251 +	        }
1252 +
1253 +        	prev->next = entry_type;
1254 +	        entry_type->prev = prev;
1255 +		entry_type->next = 0;
1256 +		if (i != 1) {
1257 +			i--;
1258 +			while (typenamescur[i-1] == ';')
1259 +				i--;
1260 +		}
1261 +	}		
1262 +	free(typenamesave); 
1263 +	return true;
1264 +}
1265 +
1266 +bool tree_clean_typenames(void)
1267 +{
1268 +	struct entry_type *tmp, *prev;
1269 +        tmp = prev = type_chain;
1270 +        while (tmp) {
1271 +       	        prev = tmp;
1272 +               	tmp = tmp->next;
1273 +		free(prev->holename);
1274 +		free(prev->typename);
1275 +		free(prev);
1276 +        }
1277 +	type_chain = 0;
1278 +	return true;
1279  }
1280 Only in src/gcc: tree-match.c.back
1281 Only in src/gcc: tree-match.c~
1282 diff -ur src.orig/gcc/tree-match.h src/gcc/tree-match.h
1283 --- src.orig/gcc/tree-match.h	Sun Apr 15 00:14:58 2007
1284 +++ src/gcc/tree-match.h	Sun Jan 13 16:49:53 2008
1285 @@ -61,6 +61,8 @@
1286    struct patt_info_s *next; /* next disjunct in the pattern */
1287  } patt_info;
1288  
1289 +
1290 +
1291  typedef patt_info *pattern;
1292  
1293  /* Atomic pattern constructor.  */
1294 @@ -137,6 +139,7 @@
1295     property.  Thus, a variable %X has the same value in different
1296     patterns.  */
1297  extern hole global_holes[GLOBAL_MAX];
1298 +extern hole *argument_holes;
1299  
1300  extern bool is_global_hole (char c);
1301  extern hole *get_hole_named (char c);
1302 @@ -152,6 +155,19 @@
1303  extern bool tree_scanf (tree t, const char *fmt, cfg_node ctx_node, ...);
1304  extern bool tree_match (tree t, const char *fmt, cfg_node ctx_node);
1305  extern bool tree_match_disj (tree t, pattern fmt, cfg_node ctx_node);
1306 +extern bool tree_match_prevstmt (tree t, const char *fmt, cfg_node ctx_node);
1307 +extern bool tree_match_prevstmt_disj (tree t, pattern patt, cfg_node ctx_node);
1308 +
1309 +struct entry_type {
1310 +char * holename;
1311 +char * typename;
1312 +struct entry_type *next;
1313 +struct entry_type *prev;
1314 +};
1315 +
1316 +extern struct entry_type *type_chain;
1317 +extern bool tree_parse_typenames(const char * typenames);
1318 +extern bool tree_clean_typenames(void);
1319  
1320  /* A "condate" is a program property involving CONtrol, DATa, and
1321     other aspects such as syntactic and semantic information.  For
1322 @@ -160,8 +176,13 @@
1323     lock-unlock bugs.  Thus, condates are built upon patterns, CFG and
1324     dataflow information.  */
1325  typedef struct condate_s {
1326 +  int fromappearatleastonce;
1327 +  char *types;
1328    char *name;    /* Used to identify the condate in warning messages.  */
1329    pattern from;  /* Paths start at nodes matching this pattern.  */
1330 +  pattern match; 
1331 +  pattern function;
1332 +  pattern follow;
1333    pattern to;    /* Paths end at nodes matching this pattern.  */
1334    pattern avoid; /* Paths must avoid nodes matching this pattern. */
1335    pattern avoid_then; /* ... successful conditions matching this pattern. */
1336 @@ -172,15 +193,26 @@
1337  /* Condate constructor.  */
1338  static inline condate 
1339  mkcond (const char *name, pattern from, pattern to, pattern avoid, 
1340 -	pattern avoid_then, pattern avoid_else) 
1341 +	pattern avoid_then, pattern avoid_else, pattern match, char *types, pattern function,
1342 +	pattern follow, int fromappearatleastonce) 
1343  { 
1344    condate cond = xmalloc (sizeof (struct condate_s));
1345 -  if (name)
1346 +  if (name) 
1347      cond->name = xstrdup (name);
1348    else 
1349      cond->name = NULL;
1350 +  if (types) {
1351 +    cond->types = xstrdup(types);
1352 +    free(types);
1353 +  }
1354 +  else
1355 +    cond->types = NULL;
1356 +  cond->fromappearatleastonce = fromappearatleastonce;
1357 +  cond->function = function;
1358    cond->from = from; 
1359    cond->to = to; 
1360 +  cond->follow = follow;
1361 +  cond->match = match;
1362    cond->avoid = avoid; 
1363    cond->avoid_then = avoid_then; 
1364    cond->avoid_else = avoid_else;
1365 Only in src/gcc: tree-match.h.back
1366 Only in src/gcc: tree-match.h~
1367 diff -ur src.orig/gcc/tree-pretty-print.c src/gcc/tree-pretty-print.c
1368 --- src.orig/gcc/tree-pretty-print.c	Sun Apr 15 00:10:40 2007
1369 +++ src/gcc/tree-pretty-print.c	Thu Jan  3 11:17:58 2008
1370 @@ -48,7 +48,7 @@
1371  static void do_niy (pretty_printer *, tree);
1372  static void dump_vops (pretty_printer *, tree, int, int);
1373  static void dump_generic_bb_buff (pretty_printer *, basic_block, int, int);
1374 -
1375 +static nolazy = 0;
1376  #define INDENT(SPACE) do { \
1377    int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
1378  
1379 @@ -440,7 +440,7 @@
1380  dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
1381  		   bool is_stmt)
1382  { 
1383 -  if (!pp_lazy_mode (buffer))
1384 +  if (!pp_lazy_mode (buffer)||nolazy)
1385      return dump_generic_node_aux (buffer, node, spc, flags, is_stmt); 
1386    else 
1387      {
1388 @@ -3064,6 +3064,22 @@
1389  
1390    return res;
1391  }
1392 +
1393 +VEC (tree_chunk, heap) *
1394 +nolazy_dump_generic_node (tree node, int flags, bool is_stmt) 
1395 +{
1396 +  pretty_printer *pp = &buffer;
1397 +  VEC (tree_chunk, heap) *res;
1398 +  nolazy = 1;
1399 +  pp->buffer->chunks = VEC_alloc (tree_chunk, heap, 10);
1400 +  dump_generic_node_aux (pp, node, 0, flags, is_stmt);
1401 +  nolazy = 0;
1402 +  res = pp->buffer->chunks;
1403 +  pp->buffer->chunks = NULL;
1404 +
1405 +  return res;
1406 +}
1407 +
1408  
1409  /* Unparse the top level of a tree and dump the resulting list of 
1410     tree chunks to a file */
1411 Only in src/gcc: tree-pretty-print.c~
1412 Only in src/gcc: tree-ssa-threadedge.c~
1413 diff -ur src.orig/gcc/tree-vrp.c src/gcc/tree-vrp.c
1414 --- src.orig/gcc/tree-vrp.c	Sun Apr 15 00:10:41 2007
1415 +++ src/gcc/tree-vrp.c	Sun Jan  6 20:12:11 2008
1416 @@ -3649,8 +3649,7 @@
1417        /* Traverse the strictly dominated sub-graph rooted at E->DEST
1418  	 to determine if any of the operands in the conditional
1419  	 predicate are used.  */
1420 -      if (e->dest != bb)
1421 -	need_assert |= find_assert_locations (e->dest);
1422 +      need_assert |= find_assert_locations (e->dest);
1423  
1424        /* Register the necessary assertions for each operand in the
1425  	 conditional predicate.  */
1426 Only in src/gcc: tree-vrp.c~

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.