public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [-fcompare-debug] skip more debug stmts in cleanup_empty_eh
@ 2017-01-03  5:29 Alexandre Oliva
  2017-01-04 11:31 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Alexandre Oliva @ 2017-01-03  5:29 UTC (permalink / raw)
  To: gcc-patches

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.

Regstrapped on x86_64-linux-gnu and i686-linux-gnu.  Ok to install?

for  gcc/ChangeLog

	* gimple-iterator.h (gsi_one_nondebug_before_end_p): New.
	* tree-eh.c (cleanup_empty_eh): Skip more debug stmts.
---
 gcc/gimple-iterator.h |   14 ++++++++++++++
 gcc/tree-eh.c         |    7 ++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/gcc/gimple-iterator.h b/gcc/gimple-iterator.h
index a58b0a4b5d..d7cd87e 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 db72156..e9edd97 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;

-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [-fcompare-debug] skip more debug stmts in cleanup_empty_eh
  2017-01-03  5:29 [-fcompare-debug] skip more debug stmts in cleanup_empty_eh Alexandre Oliva
@ 2017-01-04 11:31 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2017-01-04 11:31 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: GCC Patches

On Tue, Jan 3, 2017 at 6:28 AM, Alexandre Oliva <aoliva@redhat.com> wrote:
> 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.
>
> Regstrapped on x86_64-linux-gnu and i686-linux-gnu.  Ok to install?

Ok.

Richard.

> for  gcc/ChangeLog
>
>         * gimple-iterator.h (gsi_one_nondebug_before_end_p): New.
>         * tree-eh.c (cleanup_empty_eh): Skip more debug stmts.
> ---
>  gcc/gimple-iterator.h |   14 ++++++++++++++
>  gcc/tree-eh.c         |    7 ++++---
>  2 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/gimple-iterator.h b/gcc/gimple-iterator.h
> index a58b0a4b5d..d7cd87e 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 db72156..e9edd97 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;
>
> --
> Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
> You must be the change you wish to see in the world. -- Gandhi
> Be Free! -- http://FSFLA.org/   FSF Latin America board member
> Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-04 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-03  5:29 [-fcompare-debug] skip more debug stmts in cleanup_empty_eh Alexandre Oliva
2017-01-04 11:31 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).