Commit 99d8763e by Jakub Jelinek Committed by Jakub Jelinek

re PR tree-optimization/50682 (ICE: SIGSEGV in main_block_label with -O2…

re PR tree-optimization/50682 (ICE: SIGSEGV in main_block_label with -O2 -fnon-call-exceptions -ftracer)

	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.

From-SVN: r181785
parent 62bad7cd
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> 2011-11-28 Georg-Johann Lay <avr@gjlay.de>
* doc/extend.texi (AVR Built-in Functions): Add documentation for * doc/extend.texi (AVR Built-in Functions): Add documentation for
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> 2011-11-28 Tobias Burnus <burnus@net-b.de>
PR fortran/51308 PR fortran/51308
......
// 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 ();
}
...@@ -3473,6 +3473,29 @@ remove_unreachable_handlers (void) ...@@ -3473,6 +3473,29 @@ remove_unreachable_handlers (void)
#endif #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 /* Remove regions that do not have landing pads. This assumes
that remove_unreachable_handlers has already been run, and that remove_unreachable_handlers has already been run, and
that we've just manipulated the landing pads since then. */ that we've just manipulated the landing pads since then. */
......
...@@ -789,6 +789,7 @@ extern bool maybe_duplicate_eh_stmt_fn (struct function *, gimple, ...@@ -789,6 +789,7 @@ extern bool maybe_duplicate_eh_stmt_fn (struct function *, gimple,
extern bool maybe_duplicate_eh_stmt (gimple, gimple); extern bool maybe_duplicate_eh_stmt (gimple, gimple);
extern bool verify_eh_edges (gimple); extern bool verify_eh_edges (gimple);
extern bool verify_eh_dispatch_edge (gimple); extern bool verify_eh_dispatch_edge (gimple);
extern void maybe_remove_unreachable_handlers (void);
/* In tree-ssa-pre.c */ /* In tree-ssa-pre.c */
struct pre_expr_d; struct pre_expr_d;
......
...@@ -159,6 +159,7 @@ static unsigned int ...@@ -159,6 +159,7 @@ static unsigned int
execute_cleanup_cfg_post_optimizing (void) execute_cleanup_cfg_post_optimizing (void)
{ {
cleanup_tree_cfg (); cleanup_tree_cfg ();
maybe_remove_unreachable_handlers ();
cleanup_dead_labels (); cleanup_dead_labels ();
group_case_labels (); group_case_labels ();
if ((flag_compare_debug_opt || flag_compare_debug) if ((flag_compare_debug_opt || flag_compare_debug)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment