RFA: Fix PR41905 (ICE in lower_eh_constructs)
Michael Matz
matz@suse.de
Thu Nov 26 14:55:00 GMT 2009
Hi,
the problem here is that lower_eh_constructs_2 adds an assignment to a new
temporary for throwing statements, which includes normals calls. In the
testcase that call happens to be noreturn, so adding the assignment
changes the body from being not fallthru to a maybe-fallthru, but really
require a non-fallthru body.
The easiest seems to simply not add this assigment for statements that
can't fallthru. Other options would be that the frontend or gimplifier
emit a call to a noreturn function without a LHS. To me the former looks
more conservative.
It fixes the testcase, regstrapping on x86_64-linux in progress. Okay if
that passes?
Ciao,
Michael.
--
* tree-eh.c (lower_eh_constructs_2): Don't add assignments
below statements that can't fall thru.
testsuite/
* g++.dg/tree-ssa/pr41905.C: New testcase.
Index: tree-eh.c
===================================================================
--- tree-eh.c (revision 154672)
+++ tree-eh.c (working copy)
@@ -1868,9 +1868,12 @@ lower_eh_constructs_2 (struct leh_state
case GIMPLE_ASSIGN:
/* If the stmt can throw use a new temporary for the assignment
to a LHS. This makes sure the old value of the LHS is
- available on the EH edge. */
+ available on the EH edge. Only do so for statements that
+ potentially fall thru (no noreturn calls e.g.), otherwise
+ this new assignment might create fake fallthru regions. */
if (stmt_could_throw_p (stmt)
&& gimple_has_lhs (stmt)
+ && gimple_stmt_may_fallthru (stmt)
&& !tree_could_throw_p (gimple_get_lhs (stmt))
&& is_gimple_reg_type (TREE_TYPE (gimple_get_lhs (stmt))))
{
Index: testsuite/g++.dg/tree-ssa/pr41905.C
===================================================================
--- testsuite/g++.dg/tree-ssa/pr41905.C (revision 0)
+++ testsuite/g++.dg/tree-ssa/pr41905.C (revision 0)
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+int foo() __attribute__((noreturn));
+int bar() { return foo(); }
More information about the Gcc-patches
mailing list