summaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.c
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-19 19:52:19 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-19 19:52:19 +0000
commit94ca49167953b5f6445bdcdc6a44646e5eec4c23 (patch)
tree9801ed0ff3b74a2c13137bfc63578ad1674ffb07 /gcc/tree-cfg.c
parent4cbf73b4bf1d81e7983204180f9c3d2a65a068e6 (diff)
downloadgcc-94ca49167953b5f6445bdcdc6a44646e5eec4c23.tar.gz
* tree-cfg.c (find_taken_edge): Tighten conditions for
optimizing computed gotos. * PR tree-optimization/30984 * gcc.c-torture/pr30984.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123067 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r--gcc/tree-cfg.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 202a69e2c8f..fa4800e00c2 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -2039,7 +2039,18 @@ find_taken_edge (basic_block bb, tree val)
return find_taken_edge_switch_expr (bb, val);
if (computed_goto_p (stmt))
- return find_taken_edge_computed_goto (bb, TREE_OPERAND( val, 0));
+ {
+ /* Only optimize if the argument is a label, if the argument is
+ not a label then we can not construct a proper CFG.
+
+ It may be the case that we only need to allow the LABEL_REF to
+ appear inside an ADDR_EXPR, but we also allow the LABEL_REF to
+ appear inside a LABEL_EXPR just to be safe. */
+ if ((TREE_CODE (val) == ADDR_EXPR || TREE_CODE (val) == LABEL_EXPR)
+ && TREE_CODE (TREE_OPERAND (val, 0)) == LABEL_DECL)
+ return find_taken_edge_computed_goto (bb, TREE_OPERAND (val, 0));
+ return NULL;
+ }
gcc_unreachable ();
}