This is the mail archive of the gcc@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: [tree-ssa] Bootstrap failure on powerpc-apple-darwin


On Sat, Nov 15, 2003 at 02:21:05AM +0100, Jan Hubicka wrote:
> > It happens wen the function itself does:
> >   lower_stmt_body (&BIND_EXPR_BODY (stmt), data);
> > the first stamement of BIND_EXPR_BODY seems to be the BIND_EXPR itself
> > that looks very wrong, but I can't figure out how it happens.

Correct fix below.  Committed.  The gimple-low change is the real
bug fix; the gimplify change is just to avoid being wasteful.


> > I am also no longer able to dump the insn chains.  How this is done?

define ptu
if ($arg0 != -1)
set $NODE=$arg0
end
set print_generic_stmt (stderr, $NODE, 1<<5 | 1<<7)
end


r~


        * function.c (clear_block_marks): Rename from reorder_blocks_0, export.
        * function.h (clear_block_marks): Declare.
        * gimple-low.c (lower_function_body): Use it.
        (lower_bind_expr): Ensure we don't link blocks into the tree twice.
        * gimplify.c (gimplify_body): Keep old bind_expr at top level if
        possible.


Index: gcc/function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.374.2.31
diff -u -p -r1.374.2.31 function.c
--- gcc/function.c	13 Nov 2003 02:37:54 -0000	1.374.2.31
+++ gcc/function.c	15 Nov 2003 19:40:02 -0000
@@ -262,7 +262,6 @@ static void pad_below (struct args_size 
 static rtx round_trampoline_addr (rtx);
 static rtx adjust_trampoline_addr (rtx);
 static tree *identify_blocks_1 (rtx, tree *, tree *, tree *);
-static void reorder_blocks_0 (tree);
 static void reorder_blocks_1 (rtx, tree, varray_type *);
 static void reorder_fix_fragments (tree);
 static int all_blocks (tree, tree *);
@@ -6035,7 +6034,7 @@ reorder_blocks (void)
   VARRAY_TREE_INIT (block_stack, 10, "block_stack");
 
   /* Reset the TREE_ASM_WRITTEN bit for all blocks.  */
-  reorder_blocks_0 (block);
+  clear_block_marks (block);
 
   /* Prune the old trees away, so that they don't get in the way.  */
   BLOCK_SUBBLOCKS (block) = NULL_TREE;
@@ -6051,13 +6050,13 @@ reorder_blocks (void)
 
 /* Helper function for reorder_blocks.  Reset TREE_ASM_WRITTEN.  */
 
-static void
-reorder_blocks_0 (tree block)
+void
+clear_block_marks (tree block)
 {
   while (block)
     {
       TREE_ASM_WRITTEN (block) = 0;
-      reorder_blocks_0 (BLOCK_SUBBLOCKS (block));
+      clear_block_marks (BLOCK_SUBBLOCKS (block));
       block = BLOCK_CHAIN (block);
     }
 }
Index: gcc/function.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.h,v
retrieving revision 1.83.2.17
diff -u -p -r1.83.2.17 function.h
--- gcc/function.h	4 Nov 2003 00:13:36 -0000	1.83.2.17
+++ gcc/function.h	15 Nov 2003 19:40:02 -0000
@@ -614,6 +614,7 @@ extern void reorder_blocks (void);
 /* Set BLOCK_NUMBER for all the blocks in FN.  */
 extern void number_blocks (tree);
 
+extern void clear_block_marks (tree);
 extern tree blocks_nreverse (tree);
 extern void reset_block_changes (void);
 extern void record_block_change (tree);
Index: gcc/gimple-low.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gimple-low.c,v
retrieving revision 1.1.4.11
diff -u -p -r1.1.4.11 gimple-low.c
--- gcc/gimple-low.c	12 Nov 2003 22:06:25 -0000	1.1.4.11
+++ gcc/gimple-low.c	15 Nov 2003 19:40:03 -0000
@@ -65,6 +65,7 @@ lower_function_body (tree *body)
   data.block = DECL_INITIAL (current_function_decl);
   BLOCK_SUBBLOCKS (data.block) = NULL_TREE;
   BLOCK_CHAIN (data.block) = NULL_TREE;
+  TREE_ASM_WRITTEN (data.block) = 1;
 
   record_vars (BIND_EXPR_VARS (*body));
   *body = BIND_EXPR_BODY (*body);
@@ -74,6 +75,8 @@ lower_function_body (tree *body)
     abort ();
   BLOCK_SUBBLOCKS (data.block)
     = blocks_nreverse (BLOCK_SUBBLOCKS (data.block));
+
+  clear_block_marks (data.block);
 }
 
 /* Lowers the EXPR.  Unlike gimplification the statements are not relowered
@@ -156,35 +159,57 @@ lower_bind_expr (tree_stmt_iterator *tsi
 {
   tree old_block = data->block;
   tree stmt = tsi_stmt (*tsi);
+  tree new_block = BIND_EXPR_BLOCK (stmt);
 
-  if (BIND_EXPR_BLOCK (stmt))
+  if (new_block)
     {
-      data->block = BIND_EXPR_BLOCK (stmt);
+      if (new_block == old_block)
+	{
+	  /* The outermost block of the original function may not be the
+	     outermost statement chain of the gimplified function.  So we
+	     may see the outermost block just inside the function.  */
+	  if (new_block != DECL_INITIAL (current_function_decl))
+	    abort ();
+	  new_block = NULL;
+	}
+      else
+	{
+	  /* We do not expect to handle duplicate blocks.  */
+	  /* ??? This is probably wrong.  We've already done some amount
+	     of code replication in tree-eh.c; we should probably be doing
+	     something like reorder_blocks, which knows how to handle
+	     duplicates.  Either that or lower bind_exprs before this
+	     can matter.  */
+	  if (TREE_ASM_WRITTEN (new_block))
+	    abort ();
+	  TREE_ASM_WRITTEN (new_block) = 1;
+
+	  /* Block tree may get clobbered by inlining.  Normally this would
+	     be fixed in rest_of_decl_compilation using block notes, but
+	     since we are not going to emit them, it is up to us.  */
+	  BLOCK_CHAIN (new_block) = BLOCK_SUBBLOCKS (old_block);
+	  BLOCK_SUBBLOCKS (old_block) = new_block;
+	  BLOCK_SUBBLOCKS (new_block) = NULL_TREE;
+	  BLOCK_SUPERCONTEXT (new_block) = old_block;
 
-      /* Block tree may get clobbered by inlining.  Normally this would be
-	 fixed in rest_of_decl_compilation using block notes, but since we
-	 are not going to emit them, it is up to us.  */
-      BLOCK_CHAIN (data->block) = BLOCK_SUBBLOCKS (old_block);
-      BLOCK_SUBBLOCKS (old_block) = data->block;
-      BLOCK_SUBBLOCKS (data->block) = NULL_TREE;
-      BLOCK_SUPERCONTEXT (data->block) = old_block;
+	  data->block = new_block;
+	}
     }
 
   record_vars (BIND_EXPR_VARS (stmt));
   lower_stmt_body (&BIND_EXPR_BODY (stmt), data);
 
-  if (BIND_EXPR_BLOCK (stmt))
+  if (new_block)
     {
-      if (data->block != BIND_EXPR_BLOCK (stmt))
+      if (data->block != new_block)
 	abort ();
 
-      BLOCK_SUBBLOCKS (data->block) =
-	      blocks_nreverse (BLOCK_SUBBLOCKS (data->block));
+      BLOCK_SUBBLOCKS (new_block)
+	= blocks_nreverse (BLOCK_SUBBLOCKS (new_block));
       data->block = old_block;
     }
 
-  /* The BIND_EXPR no longer carries any useful information, so get rid
-     of it.  */
+  /* The BIND_EXPR no longer carries any useful information -- kill it.  */
   tsi_link_before (tsi, BIND_EXPR_BODY (stmt), TSI_SAME_STMT);
   tsi_delink (tsi);
 }
Index: gcc/gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gimplify.c,v
retrieving revision 1.1.2.114
diff -u -p -r1.1.2.114 gimplify.c
--- gcc/gimplify.c	14 Nov 2003 08:16:55 -0000	1.1.2.114
+++ gcc/gimplify.c	15 Nov 2003 19:40:05 -0000
@@ -3288,6 +3288,7 @@ void
 gimplify_body (tree *body_p, tree fndecl)
 {
   location_t saved_location = input_location;
+  tree body;
 
   timevar_push (TV_TREE_GIMPLIFY);
   push_gimplify_context ();
@@ -3300,23 +3301,30 @@ gimplify_body (tree *body_p, tree fndecl
 
   /* Gimplify the function's body.  */
   gimplify_stmt (body_p);
+  body = *body_p;
 
   /* Unshare again, in case gimplification was sloppy.  */
-  unshare_all_trees (*body_p);
+  unshare_all_trees (body);
 
   /* If there isn't an outer BIND_EXPR, add one.  */
-  if (TREE_CODE (*body_p) != BIND_EXPR)
+  if (TREE_CODE (body) == STATEMENT_LIST)
+    {
+      tree t = expr_only (*body_p);
+      if (t)
+	body = t;
+    }
+  if (TREE_CODE (body) != BIND_EXPR)
     {
-      tree t = *body_p;
       tree b = build (BIND_EXPR, void_type_node, NULL_TREE,
 		      NULL_TREE, NULL_TREE);
       TREE_SIDE_EFFECTS (b) = 1;
-      append_to_statement_list (t, &BIND_EXPR_BODY (b));
-      *body_p = b;
+      append_to_statement_list (body, &BIND_EXPR_BODY (b));
+      body = b;
     }
+  *body_p = body;
 
   /* Declare the new temporary variables.  */
-  declare_tmp_vars (gimplify_ctxp->temps, *body_p);
+  declare_tmp_vars (gimplify_ctxp->temps, body);
 
   pop_gimplify_context ();
   timevar_pop (TV_TREE_GIMPLIFY);


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