diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-28 21:02:27 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-28 21:02:27 +0000 |
commit | b00b0dc449a61012746eaa2b05e90d3c5142f1a2 (patch) | |
tree | bb8a862dbfe8dc6771f668944332fe22797539f2 /gcc | |
parent | c4606d19ff8feb9ef235d5286d394ed7838bd212 (diff) | |
download | gcc-b00b0dc449a61012746eaa2b05e90d3c5142f1a2.tar.gz |
PR tree-optimization/50682
* tree-eh.c (maybe_remove_unreachable_handlers): New function.
* tree-flow.h (maybe_remove_unreachable_handlers): New prototype.
* tree-optimize.c (execute_cleanup_cfg_post_optimizing): Call it.
* g++.dg/opt/pr50682.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181785 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/opt/pr50682.C | 39 | ||||
-rw-r--r-- | gcc/tree-eh.c | 23 | ||||
-rw-r--r-- | gcc/tree-flow.h | 1 | ||||
-rw-r--r-- | gcc/tree-optimize.c | 1 |
6 files changed, 76 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d37a4411fb6..a2b33deac3f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2011-11-28 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/50682 + * tree-eh.c (maybe_remove_unreachable_handlers): New function. + * tree-flow.h (maybe_remove_unreachable_handlers): New prototype. + * tree-optimize.c (execute_cleanup_cfg_post_optimizing): Call it. + 2011-11-28 Georg-Johann Lay <avr@gjlay.de> * doc/extend.texi (AVR Built-in Functions): Add documentation for diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a6a077c9b88..72c3fac85e7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-11-28 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/50682 + * g++.dg/opt/pr50682.C: New test. + 2011-11-28 Tobias Burnus <burnus@net-b.de> PR fortran/51308 diff --git a/gcc/testsuite/g++.dg/opt/pr50682.C b/gcc/testsuite/g++.dg/opt/pr50682.C new file mode 100644 index 00000000000..b7e91f45d73 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr50682.C @@ -0,0 +1,39 @@ +// PR tree-optimization/50682 +// { dg-do compile } +// { dg-options "-O2 -fnon-call-exceptions -ftracer -fno-tree-ccp -fno-tree-copy-prop -fno-tree-dce" } + +void foo () __attribute__ ((__noreturn__)); +int baz (); + +const int & +bar (const int &x, const int &y) +{ + if (x >= y) + return y; + return x; +} + +int a, b; + +struct S +{ + ~S (); + bool m () + { + int l = bar (a, b); + int r = baz (); + if (r) + r = l; + return r; + } +}; + +void +test () +{ + S s; + if (!s.m ()) + foo (); + if (!s.m ()) + foo (); +} diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index 440ac0f4082..5faeefed55f 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -3473,6 +3473,29 @@ remove_unreachable_handlers (void) #endif } +/* Remove unreachable handlers if any landing pads have been removed after + last ehcleanup pass (due to gimple_purge_dead_eh_edges). */ + +void +maybe_remove_unreachable_handlers (void) +{ + eh_landing_pad lp; + int i; + + if (cfun->eh == NULL) + return; + + for (i = 1; VEC_iterate (eh_landing_pad, cfun->eh->lp_array, i, lp); ++i) + if (lp && lp->post_landing_pad) + { + if (label_to_block (lp->post_landing_pad) == NULL) + { + remove_unreachable_handlers (); + return; + } + } +} + /* Remove regions that do not have landing pads. This assumes that remove_unreachable_handlers has already been run, and that we've just manipulated the landing pads since then. */ diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h index 211c1079f3c..ded7a3f9fac 100644 --- a/gcc/tree-flow.h +++ b/gcc/tree-flow.h @@ -789,6 +789,7 @@ extern bool maybe_duplicate_eh_stmt_fn (struct function *, gimple, extern bool maybe_duplicate_eh_stmt (gimple, gimple); extern bool verify_eh_edges (gimple); extern bool verify_eh_dispatch_edge (gimple); +extern void maybe_remove_unreachable_handlers (void); /* In tree-ssa-pre.c */ struct pre_expr_d; diff --git a/gcc/tree-optimize.c b/gcc/tree-optimize.c index 5479d9026a6..2f6b394111d 100644 --- a/gcc/tree-optimize.c +++ b/gcc/tree-optimize.c @@ -159,6 +159,7 @@ static unsigned int execute_cleanup_cfg_post_optimizing (void) { cleanup_tree_cfg (); + maybe_remove_unreachable_handlers (); cleanup_dead_labels (); group_case_labels (); if ((flag_compare_debug_opt || flag_compare_debug) |