aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2010-06-12 14:43:02 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2010-06-12 12:43:02 +0000
commit02d635a2f81e72f3ce3302abd54a2daf7941ae24 (patch)
tree65fd83e0010f199a3093c2816ea1ffcd8347839c
parent153a30276e1c07f7e7d6d926fa45c056cdca9e85 (diff)
downloadgcc-02d635a2f81e72f3ce3302abd54a2daf7941ae24.zip
gcc-02d635a2f81e72f3ce3302abd54a2daf7941ae24.tar.gz
gcc-02d635a2f81e72f3ce3302abd54a2daf7941ae24.tar.bz2
re PR tree-optimization/44485 (ICE in get_expr_operands, at tree-ssa-operands.c:1020)
PR tree-optimize/44485 * tree-cfgcleanup.c (fixup_noreturn_call): Remove basic blocks containing use of return value of noreturn function. * gcc.c-torture/compile/pc44485.c: New testcase. From-SVN: r160659
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pc44485.c46
-rw-r--r--gcc/tree-cfgcleanup.c22
4 files changed, 75 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bfd89e2..532842e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2010-06-12 Jan Hubicka <jh@suse.cz>
+
+ PR tree-optimize/44485
+ * tree-cfgcleanup.c (fixup_noreturn_call): Remove basic blocks containing
+ use of return value of noreturn function.
+
2010-06-12 Anatoly Sokolov <aesok@post.ru>
* targhooks.c (default_function_value): Don't use
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e56ac3a..5041fc5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2010-06-12 Jan Hubicka <jh@suse.cz>
+
+ * gcc.c-torture/compile/pc44485.c: New testcase.
+
2010-06-12 Janus Weil <janus@gcc.gnu.org>
PR fortran/40117
diff --git a/gcc/testsuite/gcc.c-torture/compile/pc44485.c b/gcc/testsuite/gcc.c-torture/compile/pc44485.c
new file mode 100644
index 0000000..fc95925
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pc44485.c
@@ -0,0 +1,46 @@
+static int
+foo (int si1, int si2)
+{
+ return si1 > 0 && si2 > 0 && si1 > -si2 || si1 < 0 && si2 < 0
+ && si1 < -si2 ? : si1 + si2;
+}
+
+struct S0
+{
+ unsigned short f1;
+};
+int g_4;
+struct S0 g_54 = {
+ 3428
+};
+
+int
+func_21 (int * p_22, int * const int32p_24, unsigned p_25,
+ const int * p_26);
+
+void int324 (unsigned p_15, int * p_16, int * p_17, int * p_18)
+{
+ if (foo (g_4, func_21 (p_18, &g_4, 0, 0)))
+ {
+ for (g_54.f1; g_54.f1; g_54.f1 += 1)
+ {
+ }
+ }
+}
+
+int
+func_21 (int * p_22, int * const int32p_24, unsigned p_25,
+ const int * p_26)
+{
+ for (0; 1; p_25 += 1)
+ lbl_29:if (p_25)
+ goto lbl_28;
+lbl_28:for (p_25 = 0; p_25 < 9; p_25 += 1)
+ if (p_25)
+ goto lbl_29;
+ unsigned short l_53;
+ for (0; l_53; l_53 = foo)
+ {
+ }
+ return 0;
+}
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index fc2141f..62db258 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -559,18 +559,34 @@ fixup_noreturn_call (gimple stmt)
{
tree op = gimple_call_lhs (stmt);
gimple_call_set_lhs (stmt, NULL_TREE);
+
/* We need to remove SSA name to avoid checking.
All uses are dominated by the noreturn and thus will
- be removed afterwards. */
+ be removed afterwards.
+ We proactively remove affected non-PHI statements to avoid
+ fixup_cfg from trying to update them and crashing. */
if (TREE_CODE (op) == SSA_NAME)
{
use_operand_p use_p;
imm_use_iterator iter;
gimple use_stmt;
+ bitmap_iterator bi;
+ unsigned int bb_index;
+
+ bitmap blocks = BITMAP_ALLOC (NULL);
FOR_EACH_IMM_USE_STMT (use_stmt, iter, op)
- FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
- SET_USE (use_p, error_mark_node);
+ {
+ if (gimple_code (use_stmt) != GIMPLE_PHI)
+ bitmap_set_bit (blocks, gimple_bb (use_stmt)->index);
+ else
+ FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
+ SET_USE (use_p, error_mark_node);
+ }
+ EXECUTE_IF_SET_IN_BITMAP (blocks, 0, bb_index, bi)
+ delete_basic_block (BASIC_BLOCK (bb_index));
+ BITMAP_FREE (blocks);
+ release_ssa_name (op);
}
update_stmt (stmt);
changed = true;