This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ast-optimizer-branch] Bootstrap fixes [patch]


On 7 May 2002, Diego Novillo wrote:

> On Tue, 2002-05-07 at 14:41, Daniel Berlin wrote:
> 
> > I only need to disable simplify_self_mod_expr and simplify_save_expr to be 
> > able to bootstrap before.
> > 
> > This includes simplifying statement expressions.
> > 
> Oh, that's good news.  Could you post the patch?  I'm now tracking the
> C++ library failure.

Here's what I can bootstrap with.  Self modifying statements and save 
expression simplification are the only things off.

Adding back the needs_lvalue rather than 0 in the binary expressions 
causes us to not properly simplify

*i * *r, because it doesn't try to create temporaries when it simplifies 
each part of the binary expression if needs_lvalue is 1 (and we pass it 
along).

Other than that, the only real changes are 

1. Most importantly is the where/when we copy nodes.
Play with this, and you can easily cause crashes due to improper sharing 
or save_expr fun.
2. Let save_exprs/self modifying expressions appear on the RHS, so we 
don't have to touch them for now.
3. The extra argument to create_tmp_var to prefix our nodes with names
4. The added statement expression simplification.

There are probably a few copy_nodes in there that are still unnecessary 
(like, fer instance, i'm almost positive the one in the default case of 
simplify_expr is pointless), i just remove one at a time and bootstrap, so 
it'll take me a while to whittle them back down.

BTW, with this patch, we actually simplify

*SAVE_EXPR(a++) &= *r++
into

T.1 = SAVE_EXPR (a++)
T.2 = *a
T.3 = r++
T.4 = *r

*T.1 = T.2 & T.4;

Which is right

I have a seperate patch to c-pretty-print to print SAVE_EXPR(...) around 
the SAVE_EXPRS, so you can see easily what gets screwed up.

I.E. the unparse printout looks like:
(ORIGINAL)
...
  for (i = 0; i < set_size; i++ )
          *SAVE_EXPR (r++ ) = *SAVE_EXPR (r++ ) & *p++ ;
...
(SIMPLIFIED)
    for (i = 0; i < set_size; i++ )
            {
              T.275 = SAVE_EXPR (r++ );
              T.276 = *T.275;
              T.277 = p++ ;
              T.278 = *T.277;
              *T.275 = T.276 & T.278;
            }
...

It's very easy to see how we get screwed on some copies/non-copies with 
the pretty-print patch.
Want me to submit it seperately (it's not included here, since it's not 
strictly necessary for bootstrapping)?

Obviously, i'm not submitting this for approval, it's just what my local 
tree looks like for these files.


Index: tree-simple.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-simple.c,v
retrieving revision 1.1.2.9
diff -u -3 -p -w -B -b -r1.1.2.9 tree-simple.c
--- tree-simple.c	6 May 2002 18:13:31 -0000	1.1.2.9
+++ tree-simple.c	8 May 2002 05:58:15 -0000
@@ -402,7 +402,13 @@ is_simple_rhs (t)
 {
   return (is_simple_binary_expr (t)
           || is_simple_unary_expr (t)
-	  || is_simple_condexpr (t));
+	  || is_simple_condexpr (t)
+	  || TREE_CODE (t) == SAVE_EXPR
+	  || TREE_CODE (t) == PREINCREMENT_EXPR
+	  || TREE_CODE (t) == POSTINCREMENT_EXPR
+	  || TREE_CODE (t) == PREDECREMENT_EXPR
+	  || TREE_CODE (t) == POSTDECREMENT_EXPR
+	  );
 }
 
 /* }}} */
Index: tree-simple.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-simple.h,v
retrieving revision 1.1.2.7
diff -u -3 -p -w -B -b -r1.1.2.7 tree-simple.h
--- tree-simple.h	27 Apr 2002 22:54:22 -0000	1.1.2.7
+++ tree-simple.h	8 May 2002 05:58:15 -0000
@@ -25,7 +25,7 @@ Boston, MA 02111-1307, USA.  */
 /* Interface used in [break/goto]-elimination: to be declared in a .h file. */
 extern void insert_before_continue_end PARAMS ((tree, tree, int));
 extern void tree_build_scope           PARAMS ((tree *));
-extern tree create_tmp_var             PARAMS ((tree));
+extern tree create_tmp_var             PARAMS ((tree, const char *));
 extern tree declare_tmp_vars           PARAMS ((tree, tree));
 extern tree deep_copy_list             PARAMS ((tree));
 extern tree deep_copy_node             PARAMS ((tree));
Index: c-simplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/c-simplify.c,v
retrieving revision 1.1.2.18
diff -u -3 -p -w -B -b -r1.1.2.18 c-simplify.c
--- c-simplify.c	7 May 2002 15:46:02 -0000	1.1.2.18
+++ c-simplify.c	8 May 2002 05:58:16 -0000
@@ -32,6 +32,7 @@ Software Foundation, 59 Temple Place - S
 #include "c-tree.h"
 #include "c-common.h"
 #include "tree-simple.h"
+#include "tree-inline.h"
 #include "diagnostic.h"
 
 /** The simplification pass converts the language-dependent trees
@@ -63,6 +64,7 @@ static tree simplify_if_stmt         PAR
 static tree simplify_expr            PARAMS ((tree, tree *, tree *,
                                               int (*) PARAMS ((tree)), int));
 static tree simplify_array_ref       PARAMS ((tree, tree *, tree *));
+static tree simplify_stmt_expr	     PARAMS ((tree, tree *, tree *));
 static tree simplify_self_mod_expr   PARAMS ((tree, tree *, tree *));
 static tree simplify_component_ref   PARAMS ((tree, tree *, tree *));
 static tree simplify_call_expr       PARAMS ((tree, tree *, tree *));
@@ -83,10 +85,32 @@ static tree tree_last_decl           PAR
 static tree convert_to_stmt_chain    PARAMS ((tree, tree));
 static int  stmt_has_effect          PARAMS ((tree));
 static int  expr_has_effect          PARAMS ((tree));
+static inline void strip_off_ending  PARAMS ((char *, int));
 
 /* }}} */
 
 
+/* Strip off a legitimate source ending from the input string NAME of
+   length LEN.  Rather than having to know the names used by all of
+   our front ends, we strip off an ending of a period followed by
+   up to five characters.  (Java uses ".class".)  */
+
+static inline void
+strip_off_ending (name, len)
+     char *name;
+     int len;
+{
+  int i;
+  for (i = 2;  i < 6 && len > i;  i++)
+    {
+      if (name[len - i] == '.')
+	{
+	  name[len - i] = '\0';
+	  break;
+	}
+    }
+}
+
 /* Simplification of statement trees.  */
 
 /** {{{ simplify_tree ()
@@ -935,6 +958,8 @@ simplify_expr (expr, pre_p, post_p, simp
 {
   enum tree_code code;
   tree expr_s, tmp, type;
+  const char *prefix = NULL;
+  tree stripped_decl;
 
   if (expr == NULL_TREE)
     abort ();
@@ -948,14 +973,19 @@ simplify_expr (expr, pre_p, post_p, simp
   code = TREE_CODE (expr);
 
   /* First deal with the special cases.  */
+  if ((TREE_CODE_CLASS (code) == 'e' || TREE_CODE_CLASS (code) == 'r') 
+      && TREE_OPERAND (expr, 0) 
+      && TREE_CODE (TREE_OPERAND (expr, 0)) == SAVE_EXPR)
   expr_s = expr;
+  else
+    expr_s = copy_node (expr);
   switch (code)
     {
     case POSTINCREMENT_EXPR:
     case POSTDECREMENT_EXPR:
     case PREINCREMENT_EXPR:
     case PREDECREMENT_EXPR:
-      expr_s = simplify_self_mod_expr (expr, pre_p, post_p);
+      expr_s = expr; /* simplify_self_mod_expr (expr, pre_p, post_p);*/
       break;
 
     case ARRAY_REF:
@@ -982,7 +1012,6 @@ simplify_expr (expr, pre_p, post_p, simp
       expr_s = simplify_compound_expr (expr, pre_p, post_p);
       break;
 
-#if 0
     /* FIXME: This is definitely broken.  */
     case MODIFY_EXPR:
     case INIT_EXPR:
@@ -997,7 +1026,6 @@ simplify_expr (expr, pre_p, post_p, simp
 	  expr_s = TREE_OPERAND (expr_s, 0);
 	}
       break;
-#endif
 
     case TRUTH_ANDIF_EXPR:
     case TRUTH_ORIF_EXPR:
@@ -1008,13 +1036,11 @@ simplify_expr (expr, pre_p, post_p, simp
        end up taking the address of a temporary, instead of the address
        of the original object.  */
     case ADDR_EXPR:
-      expr_s = expr;
       break;
 
     /* va_arg expressions should also be left alone to avoid confusing the
        vararg code.  FIXME: Is this really necessary?  */
     case VA_ARG_EXPR:
-      expr_s = expr;
       break;
 
     case NOP_EXPR:
@@ -1023,7 +1049,6 @@ simplify_expr (expr, pre_p, post_p, simp
     case FIX_CEIL_EXPR:
     case FIX_FLOOR_EXPR:
     case FIX_ROUND_EXPR:
-      expr_s = expr;
       TREE_OPERAND (expr_s, 0) = simplify_expr (TREE_OPERAND (expr_s, 0),
 	                                        pre_p, post_p,
 						is_simple_varname,
@@ -1031,14 +1056,12 @@ simplify_expr (expr, pre_p, post_p, simp
       break;
 
     case INDIRECT_REF:
-      expr_s = expr;
       TREE_OPERAND (expr_s, 0) = simplify_expr (TREE_OPERAND (expr_s, 0),
 	                                        pre_p, post_p, is_simple_id,
 						needs_lvalue);
       break;
 
     case NEGATE_EXPR:
-      expr_s = expr;
       TREE_OPERAND (expr_s, 0) = simplify_expr (TREE_OPERAND (expr_s, 0),
 	                                        pre_p, post_p, is_simple_val,
 						needs_lvalue);
@@ -1049,33 +1072,29 @@ simplify_expr (expr, pre_p, post_p, simp
     case REAL_CST:
     case STRING_CST:
     case COMPLEX_CST:
-      expr_s = expr;
       break;
 
     /* Do not simplify compound literals.  FIXME: Maybe we should?  */
     case COMPOUND_LITERAL_EXPR:
-      expr_s = expr;
       break;
 
     /* Do not simplify constructor expressions.  FIXME: Maybe we should?  */
     case CONSTRUCTOR:
-      expr_s = expr;
       break;
 
     /* The following are special cases that are not handled by the original
        SIMPLE grammar.  */
     case STMT_EXPR:
-      expr_s = expr;
-      simplify_stmt (STMT_EXPR_STMT (expr));
+      expr_s = simplify_stmt_expr (expr, pre_p, post_p);
+      if (expr_s == NULL_TREE)
+	return expr_s;
       break;
 
-#if 0
     /* FIXME: This is definitely broken.  */
     case SAVE_EXPR:
-      expr_s = simplify_save_expr (expr, pre_p, post_p, simple_test_f,
-	                           needs_lvalue);
+      /*simplify_save_expr (expr, pre_p, post_p, simple_test_f,
+	                           needs_lvalue); expr;*/
       break;
-#endif
 
     case EXPR_WITH_FILE_LOCATION:
       expr_s = simplify_expr_wfl (expr, pre_p, post_p, simple_test_f,
@@ -1083,7 +1102,6 @@ simplify_expr (expr, pre_p, post_p, simp
       break;
 
     case BIT_FIELD_REF:
-      expr_s = expr;
       TREE_OPERAND (expr_s, 0) = simplify_expr (TREE_OPERAND (expr_s, 0),
 	                                        pre_p, post_p, is_simple_id,
 						needs_lvalue);
@@ -1098,7 +1116,6 @@ simplify_expr (expr, pre_p, post_p, simp
       break;
 
     case NON_LVALUE_EXPR:
-      expr_s = expr;
       TREE_OPERAND (expr_s, 0) = simplify_expr (TREE_OPERAND (expr_s, 0),
 	                                        pre_p, post_p, simple_test_f,
 						0);
@@ -1108,14 +1125,13 @@ simplify_expr (expr, pre_p, post_p, simp
        its class.  */
     default:
       {
-	expr_s = expr;
+	expr_s = copy_node (expr);
 
 	if (TREE_CODE_CLASS (TREE_CODE (expr_s)) == '1')
 	  TREE_OPERAND (expr_s, 0) = simplify_expr (TREE_OPERAND (expr_s, 0),
 						    pre_p, post_p,
 						    is_simple_val,
 						    needs_lvalue);
-#if 0
 	/* FIXME: This is definitely broken.  */
 	else if (TREE_CODE_CLASS (TREE_CODE (expr_s)) == '2'
 	         || TREE_CODE_CLASS (TREE_CODE (expr_s)) == '<'
@@ -1126,23 +1142,21 @@ simplify_expr (expr, pre_p, post_p, simp
 	    tree lhs, rhs;
 
 	    lhs = simplify_expr (TREE_OPERAND (expr_s, 0), pre_p, post_p,
-			         is_simple_val, needs_lvalue);
+			         is_simple_val, 0);
 
 	    rhs = simplify_expr (TREE_OPERAND (expr_s, 1), pre_p, post_p,
-				 is_simple_val, needs_lvalue);
+				 is_simple_val, 0);
+
 
 	    TREE_OPERAND (expr_s, 0) = lhs;
 	    TREE_OPERAND (expr_s, 1) = rhs;
 	  }
-#endif
-#if 0
 	else
 	  {
 	    fprintf (stderr, "unhandled expression in simplify_expr ():\n");
 	    debug_tree (expr);
 	    abort ();
 	  }
-#endif
       }
     }
 
@@ -1151,7 +1165,6 @@ simplify_expr (expr, pre_p, post_p, simp
   if ((*simple_test_f) (expr_s))
     return expr_s;
   
-#if 0
   /* Otherwise, we need to create a new temporary to hold the simplified
      expression.  At this point, the expression should be simple enough to
      qualify as a SIMPLE RHS.  Otherwise, simplification has failed.  */
@@ -1162,19 +1175,18 @@ simplify_expr (expr, pre_p, post_p, simp
       fprintf (stderr, "\n");
       abort ();
     }
-#endif
 
-  if (TREE_TYPE (expr_s) == NULL_TREE
-      || VOID_TYPE_P (TREE_TYPE (expr_s))
-      || AGGREGATE_TYPE_P (TREE_TYPE (expr_s)))
-    return expr_s;
 
+  stripped_decl = expr_s;
+  STRIP_NOPS (stripped_decl);
+  if (DECL_P (stripped_decl))
+    prefix = IDENTIFIER_POINTER (DECL_NAME (stripped_decl));
   if (!needs_lvalue)
     {
       /* The original expression is not an lvalue, create a new temporary
 	 variable T, emit 'T = EXPR_S' and return T.  */
       type = TREE_TYPE (expr_s);
-      tmp = create_tmp_var (type);
+      tmp = create_tmp_var (type, prefix);
       add_tree (build_modify_expr (tmp, NOP_EXPR, expr_s), pre_p);
       expr_s = tmp;
     }
@@ -1184,13 +1196,12 @@ simplify_expr (expr, pre_p, post_p, simp
 	 T, get the address of the simplified expression (T = &EXPR_S) and
 	 return a reference to T (*T).  */
       type = TREE_TYPE (expr_s);
-#if 0
       /* FIXME: This is definitely broken.  */
       if (POINTER_TYPE_P (type))
 	{
 	  /* If the expression is a pointer already, there is no need to
 	     take the address of the expression.  */
-	  tmp = create_tmp_var (type);
+	  tmp = create_tmp_var (type, prefix);
 	  add_tree (build_modify_expr (tmp, NOP_EXPR, expr_s), pre_p);
 	  expr_s = tmp;
 	}
@@ -1198,19 +1209,22 @@ simplify_expr (expr, pre_p, post_p, simp
 	{
 	  /* If the expression is an indirect reference, the address we
 	     need is the actual reference.  */
-	  type = TREE_TYPE (TREE_OPERAND (expr_s, 0));
-	  tmp = create_tmp_var (type);
-	  add_tree (build_modify_expr (tmp, NOP_EXPR, TREE_OPERAND (expr_s, 0)),
-	            pre_p);
+	  tree op0 = TREE_OPERAND (expr_s, 0);
+	  stripped_decl = op0;
+	  STRIP_NOPS (stripped_decl);
+	  if (DECL_P (stripped_decl))
+	    prefix = IDENTIFIER_POINTER (DECL_NAME (stripped_decl));
+	  type = TREE_TYPE (op0);
+	  tmp = create_tmp_var (type, prefix);
+	  add_tree (build_modify_expr (tmp, NOP_EXPR, op0), pre_p);
 	  TREE_OPERAND (expr_s, 0) = tmp;
 	}
       else
-#endif
 	{
 	  /* Take the address of the simplified expression and return a
 	     reference to it.  */
 	  type = build_pointer_type (type);
-	  tmp = create_tmp_var (type);
+	  tmp = create_tmp_var (type, prefix);
 	  add_tree (build_modify_expr (tmp, NOP_EXPR,
 		                       build1 (ADDR_EXPR, type, expr_s)),
                     pre_p);
@@ -1253,7 +1267,7 @@ simplify_array_ref (expr, pre_p, post_p)
   if (TREE_CODE (expr) != ARRAY_REF)
     abort ();
 
-  expr_s = expr;
+  expr_s = copy_node (expr);
   VARRAY_GENERIC_PTR_INIT (dim_stack, 10, "dim_stack");
 
   /* Create a stack with all the dimensions of the array so that they can
@@ -1373,7 +1387,7 @@ simplify_component_ref (expr, pre_p, pos
 
   rhs = simplify_expr (TREE_OPERAND (expr, 1), pre_p, post_p, is_simple_id, 0);
 
-  expr_s = expr;
+  expr_s = copy_node (expr);
   TREE_OPERAND (expr_s, 0) = lhs;
   TREE_OPERAND (expr_s, 1) = rhs;
 
@@ -1423,7 +1437,7 @@ simplify_call_expr (expr, pre_p, post_p)
     arglist = simplify_expr (TREE_OPERAND (expr, 1), pre_p, post_p,
   			     is_simple_arglist, 0);
   
-  expr_s = expr;
+  expr_s = copy_node (expr);
   TREE_OPERAND (expr_s, 0) = id;
   if (TREE_OPERAND (expr_s, 1))
     TREE_OPERAND (expr_s, 1) = arglist;
@@ -1461,8 +1475,12 @@ simplify_tree_list (expr, pre_p, post_p)
   expr_s = copy_list (expr);
   for (op = expr_s; op; op = TREE_CHAIN (op))
     {
-      tree arg;
-
+      tree arg = op;
+      if (DECL_P (arg) 
+	  || TREE_CODE (arg) == RTL_EXPR 
+	  || TREE_CODE (arg) == SAVE_EXPR 
+	  || TREE_CODE (arg) == WITH_CLEANUP_EXPR)
+	      abort();
       arg = simplify_expr (TREE_VALUE (op), pre_p, post_p, is_simple_val, 0);
       TREE_VALUE (op) = arg;
     }
@@ -1501,7 +1519,7 @@ simplify_cond_expr (expr, pre_p, post_p)
   expr_type = TREE_TYPE (expr);
 
   if (!VOID_TYPE_P (expr_type))
-    tmp = create_tmp_var (TREE_TYPE (expr));
+    tmp = create_tmp_var (TREE_TYPE (expr), "iftmp");
   else
     tmp = void_zero_node;
 
@@ -1563,7 +1581,7 @@ simplify_modify_expr (expr, pre_p, post_
 
   /* Break assignment chains (i.e., a = b = c = ...) into individual
      assignment expressions.  */
-  expr_s = expr;
+  expr_s = copy_node (expr);
   rhs = TREE_OPERAND (expr_s, 1);
   if (TREE_CODE (rhs) == MODIFY_EXPR)
     {
@@ -1635,9 +1655,8 @@ simplify_boolean_expr (expr, pre_p, post
      temporary.  */
   lhs = simplify_expr (TREE_OPERAND (expr, 0), pre_p, post_p, 
                        is_simple_condexpr, 0);
-  t = create_tmp_var (TREE_TYPE (expr));
+  t = create_tmp_var (TREE_TYPE (expr), "booltmp");
   add_tree (build_modify_expr (t, NOP_EXPR, lhs), pre_p);
-
   /* Build the body for the if() statement that conditionally evaluates the
      RHS of the expression.  Note that we first build the assignment
      surrounded by a new scope so that its simplified form is computed
@@ -1812,6 +1831,92 @@ simplify_save_expr (expr, pre_p, post_p,
 
 /* }}} */
 
+/** {{{ simplify_stmt_expr ()
+
+    Simplify an STMT_EXPR. EXPR is the expression to simplify. 
+    
+    PRE_P points to the list where side effects that must happen
+    before EXPR should be stored.
+ 
+    POST_P points to the list where side effects that must happen
+    after EXPR should be stored.  */
+
+static tree 
+simplify_stmt_expr (expr, pre_p, post_p)
+  tree expr;
+  tree *pre_p;
+  tree *post_p;
+{
+  tree type, tmp;
+  simplify_stmt (STMT_EXPR_STMT (expr));
+  /* These tests determine if the STMT_EXPR returns a value. If it does, we need
+     to store that value somewhere.  */
+  if (TREE_CODE (STMT_EXPR_STMT (expr)) == COMPOUND_STMT
+      && TREE_CODE (COMPOUND_BODY (STMT_EXPR_STMT (expr))) == SCOPE_STMT 
+      && TREE_CODE (TREE_TYPE (expr)) != VOID_TYPE)
+    {
+      
+      /* This produces code that *looks* right, but there are
+	 problems in duplicating the magic of STMT_EXPR's that return values.
+	 In particular, the way we expand them to RTL.  */
+      
+      tree body = STMT_EXPR_STMT (expr);
+      tree temp;
+      tree last;
+      tree temp2;
+      tree new_stmt = NULL_TREE;
+      tree last_expr;
+      const char * prefix = NULL;
+      /* Find the last statement in the statement expression.  */
+      while (TREE_CODE (body) == COMPOUND_STMT)
+	{
+	  body = COMPOUND_BODY (body);
+	  last = TREE_CHAIN (body);
+	  while (TREE_CHAIN (last))
+	    {
+	      temp = last;
+	      last = TREE_CHAIN (last);
+	    }
+	  body = temp;
+	}
+      type = TREE_TYPE (EXPR_STMT_EXPR (temp));
+      if (DECL_P (EXPR_STMT_EXPR (temp)))
+	prefix = IDENTIFIER_POINTER (DECL_NAME (EXPR_STMT_EXPR (temp)));
+      tmp = create_tmp_var (type, prefix);
+      last_expr = EXPR_STMT_EXPR (temp);
+      /* last_expr might just be a simple variable, or it could be a modify_expression. */    
+      temp2 =  (is_simple_modify_expr (last_expr))
+	? build_modify_expr (tmp, NOP_EXPR, TREE_OPERAND (last_expr, 0))
+	: build_modify_expr (tmp, NOP_EXPR, last_expr);
+      
+      if (is_simple_modify_expr (last_expr))
+	{
+	  new_stmt = build_stmt (EXPR_STMT ,temp2);
+	  TREE_CHAIN (new_stmt) = TREE_CHAIN (temp);
+	  TREE_CHAIN (temp) = new_stmt;
+	}
+      else
+	{	 
+	  EXPR_STMT_EXPR (temp) = temp2;
+	}
+      /* Need to add a *copy* of the STMT_EXPR_STMT, otherwise, we could end
+	 up introducing a circular chain, if something else has shared the 
+	 expression.  */
+      add_tree (copy_node (STMT_EXPR_STMT (expr)), pre_p);
+      return TREE_OPERAND (temp2, 0);
+    }
+  else
+    {
+      /* Need to add a *copy* of the STMT_EXPR_STMT, otherwise, we could end
+	 up introducing a circular chain, if something else has shared the 
+	 expression.  */
+      add_tree (copy_node (STMT_EXPR_STMT (expr)), pre_p);
+      return NULL_TREE;
+    } 
+}
+
+/* }}} */
+
 /** {{{ simplify_expr_wfl ()
 
     Simplify an EXPR_WITH_FILE_LOCATION.  EXPR is the expression to
@@ -1932,6 +2037,7 @@ add_tree (t, list_p)
     tree *list_p;
 {
   tree n;
+//  walk_tree (&t, copy_tree_r, NULL, NULL);
   
   if (t == NULL_TREE)
     return NULL_TREE;
@@ -2112,18 +2218,27 @@ insert_before_first (t, body)
 
 /** {{{ create_tmp_var ()
 
-   Create a new temporary variable declaration of type TYPE.  Returns the
+   Create a new temporary variable declaration of type TYPE, 
+   prefixing the name with PREFIX, if it's not NULL..  Returns the
    newly created decl and pushes it into the current binding.  */
 
 tree
-create_tmp_var (type)
+create_tmp_var (type, prefix)
      tree type;
+     const char *prefix;
 {
   static unsigned int id_num = 1;
   char *tmp_name;
+  char *preftmp = NULL;
   tree tmp_var;
-
-  ASM_FORMAT_PRIVATE_NAME (tmp_name, "T", id_num++);
+  /* prefix[0] != 0 to avoid an allocated string that happens to only contain a  NULL */
+  if (prefix)
+    {
+      preftmp = xstrdup (prefix); 
+      strip_off_ending (preftmp, strlen (preftmp));
+      prefix = preftmp;
+    }
+  ASM_FORMAT_PRIVATE_NAME (tmp_name, (prefix ? prefix : "T"), id_num++);
 
   /* If the type is an array, use TYPE_POINTER_TO to create a valid pointer
      that can be used in the LHS of an assignment.  */
@@ -2146,7 +2261,8 @@ create_tmp_var (type)
   TREE_USED (tmp_var) = 1;
 
   pushdecl (tmp_var);
-
+  if (preftmp)
+    free (preftmp);
   return tmp_var;
 }
 
@@ -2476,6 +2592,8 @@ static int
 expr_has_effect (expr)
      tree expr;
 {
+  if (expr == NULL_TREE)
+    return 0;
   return (TREE_SIDE_EFFECTS (expr)
 	  || (TREE_CODE (expr) == CONVERT_EXPR
 	      && VOID_TYPE_P (TREE_TYPE (expr))));
Index: simple-break-elim.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/simple-break-elim.c,v
retrieving revision 1.1.2.1
diff -u -3 -p -w -B -b -r1.1.2.1 simple-break-elim.c
--- simple-break-elim.c	6 May 2002 15:53:44 -0000	1.1.2.1
+++ simple-break-elim.c	8 May 2002 05:58:16 -0000
@@ -486,7 +486,7 @@ continue_stmt_solution2 (stmt)
       tree lvar, lvar_one;
       
       /* Initialise a logical variable to false at the beginning of the loop.  */
-      lvar = create_tmp_var (integer_type_node);
+      lvar = create_tmp_var (integer_type_node, "contelim");
       DECL_INITIAL (lvar) = integer_zero_node;
       
       /* Replace the CONTINUE_STMT by "lvar=1".  */
@@ -551,7 +551,7 @@ break_stmt_solution2 (stmt)
   /* Replace the BREAK_STMT by "lvar=1;".  */
   {
     /* Initialise a logical variable to false in the function's scope.  */
-    lvar = create_tmp_var (integer_type_node);
+    lvar = create_tmp_var (integer_type_node, "breakelim");
     DECL_INITIAL (lvar) = integer_zero_node;
     
     /* Replace the BREAK_STMT by "lvar=1".  */
Index: simple-goto-elim.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/simple-goto-elim.c,v
retrieving revision 1.1.2.1
diff -u -3 -p -w -B -b -r1.1.2.1 simple-goto-elim.c
--- simple-goto-elim.c	6 May 2002 15:53:44 -0000	1.1.2.1
+++ simple-goto-elim.c	8 May 2002 05:58:16 -0000
@@ -194,7 +194,7 @@ static PATH_TYPE PATH_TOP;
     }                                                                   \
   {                                                                     \
     tree decl;                                                          \
-    decl = create_tmp_var (integer_type_node);                          \
+    decl = create_tmp_var (integer_type_node, "gotoelim");              \
     DECL_INITIAL (decl) = integer_zero_node;                            \
     GOTO_LVAR (elt) = decl;                                             \
   }                                                                     \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]