aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2007-03-19 13:52:19 -0600
committerJeff Law <law@gcc.gnu.org>2007-03-19 13:52:19 -0600
commit1799efef2cedc4e593396c29b866891244cbc3a9 (patch)
tree9801ed0ff3b74a2c13137bfc63578ad1674ffb07 /gcc
parent7270dd8e8dd70e91690c434421a8ccf1074fda38 (diff)
downloadgcc-1799efef2cedc4e593396c29b866891244cbc3a9.zip
gcc-1799efef2cedc4e593396c29b866891244cbc3a9.tar.gz
gcc-1799efef2cedc4e593396c29b866891244cbc3a9.tar.bz2
re PR tree-optimization/30984 (ICE with computed goto and constants)
* tree-cfg.c (find_taken_edge): Tighten conditions for optimizing computed gotos. * PR tree-optimization/30984 * gcc.c-torture/pr30984.c: New test. From-SVN: r123067
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr30984.c7
-rw-r--r--gcc/tree-cfg.c13
4 files changed, 29 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fb839f5..ec45c0e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2007-03-19 Jeff Law <law@redhat.com>
+
+ * tree-cfg.c (find_taken_edge): Tighten conditions for
+ optimizing computed gotos.
+
2007-03-19 Michael Matz <matz@suse.de>
* builtins.c (expand_builtin_sync_operation,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b62c6eb..72474a8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-03-19 Jeff Law <law@redhat.com>
+
+ * PR tree-optimization/30984
+ * gcc.c-torture/pr30984.c: New test.
+
2007-03-19 Andrew Pinski <andrew_pinski@playstation.sony.com>
Richard Guenther <rguenther@suse.de>
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr30984.c b/gcc/testsuite/gcc.c-torture/compile/pr30984.c
new file mode 100644
index 0000000..265a6f3
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr30984.c
@@ -0,0 +1,7 @@
+int fs_exec(int ino)
+{
+ void *src = 0;
+ if (ino)
+ src = (void*)0xe000;
+ goto *src;
+}
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 202a69e..fa4800e 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 ();
}