[tree-ssa]: After edge insertion, two bb's share the same heda
Andrew MacLeod
amacleod@redhat.com
Sun Jul 27 22:58:00 GMT 2003
On Sun, 2003-07-27 at 01:23, Daniel Berlin wrote:
>
> On Saturday, July 26, 2003, at 9:20 PM, Daniel Berlin wrote:
>
> >
> >
> > We go to insert on the edge between block 9 and block 21
> > It creates a new basic block to do this, bb 30.
> > So it then goes to find the insert location for the statement.
> > It then notices it's inserting into a switch statement, sees it's
> > inserting into the fallthru, and calls handle_switch_fallthru.
> > Handle switch fallthru starts to do it's thing, eventually calls:
> > 3820 tsi = tsi_last (&BIND_EXPR_BODY (SWITCH_BODY (sw_stmt)));
> >
> > The tsi it returns is a pointer to the head of basic block 20 (which
> > is the correct last thing in the bind_expr_body, AFAICT).
> > At this point, we link the new case label after that statement (which
> > is a statement really in bb 20, still :P), so that bb 20 now looks
> > like:
> > 51 goto <UL1070>;
> > -1 default :
> >
> > We then try to append the container (which is the pointer to the head
> > of bb 20) to the new bb, which causes the two bb's to now share a
> > head.
> >
>
> On this note, if i comment out the first append, which appends the
> current container (IE line 3287 of tree-cfg.c, not line 3289) it seems
> to do the right thing, which is not screw up the old block, and
> simultaneously make the new block look okay.
>
> But of course, i'm shooting in the dark here :)
>
Good analysis of the problem. I havent got time to do any extensive
testing, but see if this resolves your problem. Im not sure if it'll
cause other problems or not. In theory it shouldn't but Im pressed for
time at the moment. I'll do a better investigation of this fix on
monday.
Andrew
* tree-cfg.c (handle_switch_fallthru): If final stmt is in a block,
use bsi_link_after rather than tsi_link_after.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.132
diff -c -p -r1.1.4.132 tree-cfg.c
*** tree-cfg.c 22 Jul 2003 02:50:14 -0000 1.1.4.132
--- tree-cfg.c 27 Jul 2003 13:59:20 -0000
*************** handle_switch_fallthru (tree sw_stmt, ba
*** 3839,3846 ****
stmt = build (CASE_LABEL_EXPR, void_type_node, NULL_TREE, NULL_TREE, label);
/* Update block in the new CE node. */
! tsi_link_after (&tsi, stmt, TSI_SAME_STMT);
! append_stmt_to_bb (tsi_container (tsi), new_bb, sw_stmt);
tsi_next (&tsi);
append_stmt_to_bb (tsi_container (tsi), new_bb, sw_stmt);
--- 3839,3852 ----
stmt = build (CASE_LABEL_EXPR, void_type_node, NULL_TREE, NULL_TREE, label);
/* Update block in the new CE node. */
! tmp_bb = bb_for_stmt (tsi_stmt (tsi));
! if (tmp_bb)
! tsi = bsi_link_after (&tsi, stmt, tmp_bb, parent_stmt (tsi_stmt (tsi)));
! else
! {
! tsi_link_after (&tsi, stmt, TSI_SAME_STMT);
! append_stmt_to_bb (tsi_container (tsi), new_bb, sw_stmt);
! }
tsi_next (&tsi);
append_stmt_to_bb (tsi_container (tsi), new_bb, sw_stmt);
More information about the Gcc
mailing list