[tree-ssa] Fix unfactoring of computed gotos
Zdenek Dvorak
rakdver@atrey.karlin.mff.cuni.cz
Fri Apr 23 11:02:00 GMT 2004
Hello,
the current way factored computed gotos are unfactored is broken,
since there is no guarantee that no code will be emitted between
factored_computed_goto_label and factored_computed_goto.
I don't have a testcase (it happed to me just on lno-branch, where
store motion may expose it) and it is possible that it indeed cannot
be reproduced with the clean tree-ssa branch.
Bootstrapped & regtested on i686.
Zdenek
* tree-cfg.c (factored_computed_goto_label,
factored_computed_goto): Removed.
(disband_implicit_edges): Unfactor computed gotos without
using them.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.280
diff -c -3 -p -r1.1.4.280 tree-cfg.c
*** tree-cfg.c 3 Apr 2004 11:12:00 -0000 1.1.4.280
--- tree-cfg.c 21 Apr 2004 20:47:27 -0000
*************** static struct cfg_stats_d cfg_stats;
*** 67,81 ****
/* Nonzero if we found a computed goto while building basic blocks. */
static bool found_computed_goto;
- /* If we found computed gotos, then they are all revectored to this
- location. We try to unfactor them after we have translated out
- of SSA form. */
- static GTY(()) tree factored_computed_goto_label;
-
- /* The factored computed goto. We cache this so we can easily recover
- the destination of computed gotos when unfactoring them. */
- static GTY(()) tree factored_computed_goto;
-
/* Basic blocks and flowgraphs. */
static basic_block create_bb (void *, void *, basic_block);
static void create_block_annotation (basic_block);
--- 67,72 ----
*************** factor_computed_gotos (void)
*** 223,228 ****
--- 213,220 ----
basic_block bb;
tree factored_label_decl = NULL;
tree var = NULL;
+ tree factored_computed_goto_label = NULL;
+ tree factored_computed_goto = NULL;
/* We know there are one or more computed gotos in this function.
Examine the last statement in each basic block to see if the block
*************** disband_implicit_edges (void)
*** 2457,2463 ****
basic_block bb;
block_stmt_iterator last;
edge e;
! tree stmt, label;
FOR_EACH_BB (bb)
{
--- 2449,2455 ----
basic_block bb;
block_stmt_iterator last;
edge e;
! tree stmt, label, forward;
FOR_EACH_BB (bb)
{
*************** disband_implicit_edges (void)
*** 2524,2543 ****
label = tree_block_label (e->dest);
! /* ??? Why bother putting this back together when rtl is just
about to take it apart again? */
! if (factored_computed_goto_label
! && label == LABEL_EXPR_LABEL (factored_computed_goto_label))
! label = GOTO_DESTINATION (factored_computed_goto);
bsi_insert_after (&last,
build1 (GOTO_EXPR, void_type_node, label),
BSI_NEW_STMT);
e->flags &= ~EDGE_FALLTHRU;
}
-
- factored_computed_goto = NULL;
- factored_computed_goto_label = NULL;
}
--- 2516,2535 ----
label = tree_block_label (e->dest);
! /* If this is a goto to a goto, jump to the final destination.
! Handles unfactoring of the computed jumps.
! ??? Why bother putting this back together when rtl is just
about to take it apart again? */
! forward = last_and_only_stmt (e->dest);
! if (forward
! && TREE_CODE (forward) == GOTO_EXPR)
! label = GOTO_DESTINATION (forward);
bsi_insert_after (&last,
build1 (GOTO_EXPR, void_type_node, label),
BSI_NEW_STMT);
e->flags &= ~EDGE_FALLTHRU;
}
}
More information about the Gcc-patches
mailing list