From 87cd42599c846abbaf7a4ea063e594e68a175a5a Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Thu, 26 Nov 2009 15:54:07 +0000 Subject: [PATCH] tree-eh.c (lower_eh_constructs_2): Don't add assignments below statements that can't fall thru. * 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. From-SVN: r154674 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/tree-ssa/pr41905.C | 4 ++++ gcc/tree-eh.c | 5 ++++- 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr41905.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1ba6dd629bd0..26668214c15a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2009-11-26 Michael Matz + + PR tree-optimization/41905 + * tree-eh.c (lower_eh_constructs_2): Don't add assignments + below statements that can't fall thru. + 2009-11-26 Michael Matz * builtins.c (expand_builtin_printf, expand_builtin_fprintf, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 965327c3f938..73f39a7c29d3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-11-26 Michael Matz + + PR tree-optimization/41905 + * g++.dg/tree-ssa/pr41905.C: New testcase. + 2009-11-25 Richard Henderson * gcc.dg/vect/slp-21.c: Succeed with vect_extract_even_odd too. diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr41905.C b/gcc/testsuite/g++.dg/tree-ssa/pr41905.C new file mode 100644 index 000000000000..4424ce8d23db --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr41905.C @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +int foo() __attribute__((noreturn)); +int bar() { return foo(); } diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index 21da53470a26..dde343c46116 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -1868,9 +1868,12 @@ lower_eh_constructs_2 (struct leh_state *state, gimple_stmt_iterator *gsi) 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)))) {