[tree-ssa]: We don't update end of bb in before insertion when we should

Andrew MacLeod amacleod@redhat.com
Fri May 30 13:26:00 GMT 2003


On Fri, 2003-05-30 at 01:44, Daniel Berlin wrote:
> We aren't updating it at all, when we should be in a single case in 
> bsi_insert_before.
> Andrew, when we insert before the statement at the end of the block, it 
> might (usually does) change the bb end.
> IE we transform like so:
> COMPOUND_EXPR <<<<< OLD END OF BB
> 	goto_expr
> 	nothing
> into
> COMPOUND_EXPR <<<<<< STILL END OF BB
> 	new stmt
> 	COMPOUND_EXPR <<<<< Just created
> 		goto_expr
> 		nothing
> which is exactly what occurs below.
> 

Drat. Brain fart. You are quite correct. When I reworked insert_before
and insert_after a couple of weeks ago, I remove that because it looked
like a piece of bsi_insert_after had been copied in and and not fixed up
(We weren't updating head properly either). 

doh!

Andrew

Try this (Includes a modified version of the last one)

	* tree-cfg.c (bsi_insert_before): Update BB head pointer correctly.
	Update BB tail pointer if required.


Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.96
diff -c -p -r1.1.4.96 tree-cfg.c
*** tree-cfg.c	24 May 2003 13:08:50 -0000	1.1.4.96
--- tree-cfg.c	30 May 2003 11:11:41 -0000
*************** bsi_insert_before (curr_bsi, t, mode)
*** 3553,3564 ****
    tsi_link_before (&inserted_tsi, t, TSI_NEW_STMT);
    add_stmt_to_bb (tsi_container (inserted_tsi), curr_bb, parent);
  
-   same_tsi = inserted_tsi;
-   tsi_next (&same_tsi);
- 
    if (curr_container == curr_bb->head_tree_p)
      {
!       curr_bb->head_tree_p = tsi_container (same_tsi);
        /* If the parent block is a COND_EXPR or LOOP_EXPR, check if this
  	 is the block which they point to and update if necessary.  */
        if (parent)
--- 3553,3561 ----
    tsi_link_before (&inserted_tsi, t, TSI_NEW_STMT);
    add_stmt_to_bb (tsi_container (inserted_tsi), curr_bb, parent);
  
    if (curr_container == curr_bb->head_tree_p)
      {
!       curr_bb->head_tree_p = tsi_container (inserted_tsi);
        /* If the parent block is a COND_EXPR or LOOP_EXPR, check if this
  	 is the block which they point to and update if necessary.  */
        if (parent)
*************** bsi_insert_before (curr_bsi, t, mode)
*** 3584,3589 ****
--- 3581,3596 ----
  	    }
  	}
      }
+ 
+   same_tsi = inserted_tsi;
+   tsi_next (&same_tsi);
+ 
+   /* The end block pointer can be modified when we insert before the last stmt
+      in a block.  This occurs because we insert a new container for the last
+      stmt.  */
+ 
+   if (curr_container == curr_bb->end_tree_p)
+     curr_bb->end_tree_p = tsi_container (same_tsi);
  
    if (mode == BSI_SAME_STMT)
      bsi_update_from_tsi (curr_bsi, same_tsi);



More information about the Gcc mailing list