This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] Patch for handle_switch_fallthru
- From: Andrew MacLeod <amacleod at redhat dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: 29 Jul 2003 00:38:51 -0400
- Subject: [tree-ssa] Patch for handle_switch_fallthru
I've checked in the following patch which fixes a bug in switch code
insertion which Dan found. Basically, if the last stmt in the switch
block is part
of a basic block, we ought to use bsi_link_after instead of
tsi_link_after to make sure all the block pointers are fixed up
properly.
Bootstrapped, make checked, etc etc.
Andrew
2003-07-28 Andrew MacLeod <amacleod@redhat.com>
* tree-cfg.c (handle_switch_fallthru): Use bsi_link_after if stmt is
in a basic block.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.136
diff -c -p -r1.1.4.136 tree-cfg.c
*** tree-cfg.c 28 Jul 2003 17:04:54 -0000 1.1.4.136
--- tree-cfg.c 29 Jul 2003 02:07:36 -0000
*************** handle_switch_fallthru (tree sw_stmt, ba
*** 3823,3830 ****
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);
--- 3823,3836 ----
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);