On Tue, Jan 3, 2017 at 6:28 AM, Alexandre Oliva <aol...@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

Reply via email to