From: Alexandre Oliva Date: Thu, 5 Jan 2017 01:46:14 +0000 (+0000) Subject: [-fcompare-debug] skip more debug stmts in cleanup_empty_eh X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=556655048b30188a560f135ccde732bc436eded2;p=gcc.git [-fcompare-debug] skip more debug stmts in cleanup_empty_eh Various Ada RTS files failed -fcompare-debug compilation because debug stmts prevented EH cleanups from taking place. Adjusting cleanup_empty_eh to skip them fixes it. for gcc/ChangeLog * gimple-iterator.h (gsi_one_nondebug_before_end_p): New. * tree-eh.c (cleanup_empty_eh): Skip more debug stmts. From-SVN: r244088 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2582f4814d5..6f26a7a0e40 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-01-04 Alexandre Oliva + + * gimple-iterator.h (gsi_one_nondebug_before_end_p): New. + * tree-eh.c (cleanup_empty_eh): Skip more debug stmts. + 2017-01-04 Alexandre Oliva * multiple_target.c (create_dispatcher_calls): Init e_next. diff --git a/gcc/gimple-iterator.h b/gcc/gimple-iterator.h index 7b2c49c83a6..70f18beceff 100644 --- a/gcc/gimple-iterator.h +++ b/gcc/gimple-iterator.h @@ -305,6 +305,20 @@ gsi_last_nondebug_bb (basic_block bb) return i; } +/* Return true if I is followed only by debug statements in its + sequence. */ + +static inline bool +gsi_one_nondebug_before_end_p (gimple_stmt_iterator i) +{ + if (gsi_one_before_end_p (i)) + return true; + if (gsi_end_p (i)) + return false; + gsi_next_nondebug (&i); + return gsi_end_p (i); +} + /* Iterates I statement iterator to the next non-virtual statement. */ static inline void diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index 2be4312b862..45e6b9e4ebb 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -4382,7 +4382,8 @@ cleanup_empty_eh (eh_landing_pad lp) return false; } - resx = last_stmt (bb); + gsi = gsi_last_nondebug_bb (bb); + resx = gsi_stmt (gsi); if (resx && is_gimple_resx (resx)) { if (stmt_can_throw_external (resx)) @@ -4416,12 +4417,12 @@ cleanup_empty_eh (eh_landing_pad lp) resx = gsi_stmt (gsi); if (!e_out && gimple_call_builtin_p (resx, BUILT_IN_STACK_RESTORE)) { - gsi_next (&gsi); + gsi_next_nondebug (&gsi); resx = gsi_stmt (gsi); } if (!is_gimple_resx (resx)) return ret; - gcc_assert (gsi_one_before_end_p (gsi)); + gcc_assert (gsi_one_nondebug_before_end_p (gsi)); /* Determine if there are non-EH edges, or resx edges into the handler. */ has_non_eh_pred = false;