public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Eric Botcazou <ebotcazou@adacore.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: Fix thinko in gimple_assign_set_rhs_with_ops
Date: Wed, 26 Jul 2017 07:52:00 -0000	[thread overview]
Message-ID: <CAFiYyc3geBV6k0YACu8EqA=5saa6qmZbfZzgrS1ZNaP-qUmBgg@mail.gmail.com> (raw)
In-Reply-To: <2663014.h6Leadj67V@arcturus.home>

On Tue, Jul 25, 2017 at 3:59 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> The attached fix to the Ada front-end introduces a regression in the ACATS
> testsuite for cb4009a.  The backtrace is:
>
> #0  operation_could_trap_helper_p(tree_code, bool, bool, bool, bool,
> tree_node*, bool*) () at /home/eric/gnat/gnat-head/src/gcc/tree-eh.c:2439
> #1  0x00000000012946d7 in stmt_could_throw_1_p (stmt=<optimized out>)
>     at /home/eric/gnat/gnat-head/src/gcc/tree-eh.c:2759
> #2  stmt_could_throw_p(gimple*) [clone .part.186] ()
>     at /home/eric/gnat/gnat-head/src/gcc/tree-eh.c:2809
> #3  0x0000000001295f28 in stmt_could_throw_p (stmt=0x7ffff6c5d420)
>     at /home/eric/gnat/gnat-head/src/gcc/tree-eh.c:2924
> #4  maybe_clean_or_replace_eh_stmt (old_stmt=old_stmt@entry=0x7ffff6c565d8,
>     new_stmt=new_stmt@entry=0x7ffff6c5d420)
>     at /home/eric/gnat/gnat-head/src/gcc/tree-eh.c:2908
> #5  0x0000000000fd8a0b in gsi_replace(gimple_stmt_iterator*, gimple*, bool) ()
>     at /home/eric/gnat/gnat-head/src/gcc/gimple-iterator.c:447
> #6  0x0000000000fd14af in
> gimple_assign_set_rhs_with_ops(gimple_stmt_iterator*, tree_code, tree_node*,
> tree_node*, tree_node*) ()
>     at /home/eric/gnat/gnat-head/src/gcc/gimple.c:1616
> #7  0x0000000000fe7af7 in replace_stmt_with_simplification (inplace=false,
>     seq=0x7fffffffd818, ops=0x7fffffffd820, rcode=..., gsi=0x7fffffffd8e0)
>     at /home/eric/gnat/gnat-head/src/gcc/gimple-fold.c:4151
> #8  fold_stmt_1(gimple_stmt_iterator*, bool, tree_node* (*)(tree_node*)) ()
>     at /home/eric/gnat/gnat-head/src/gcc/gimple-fold.c:4462
> #9  0x0000000000fe961a in fold_stmt (gsi=gsi@entry=0x7fffffffd8e0,
>     valueize=valueize@entry=0x1331170 <fwprop_ssa_val(tree)>)
>     at /home/eric/gnat/gnat-head/src/gcc/gimple-fold.c:4689
>
> The folding is turning a TRUNC_DIV_EXPR into a COND_EXPR and the code does:
>
>   /* If the new CODE needs more operands, allocate a new statement.  */
>   if (gimple_num_ops (stmt) < new_rhs_ops + 1)
>     {
>       tree lhs = gimple_assign_lhs (stmt);
>       gimple *new_stmt = gimple_alloc (gimple_code (stmt), new_rhs_ops + 1);
>       memcpy (new_stmt, stmt, gimple_size (gimple_code (stmt)));
>       gimple_init_singleton (new_stmt);
>       gsi_replace (gsi, new_stmt, true);
>       stmt = new_stmt;
>
>       /* The LHS needs to be reset as this also changes the SSA name
>          on the LHS.  */
>       gimple_assign_set_lhs (stmt, lhs);
>     }
>
> i.e it asks gsi_replace to update EH info, which doesn't work since the new
> statement is dummy at this point.  Fixed by passing false instead of true.
>
> Bootstrapped/regtested on x86_64-suse-linux, applied on mainline as obvious.

I think we should get rid of that update-EH-info flag, always assuming
false.  This
is IMHO a too low-level interface to do this (and we lack a
gsi_replace_without_update)

Not sure if you're willing to do this kind of cleanup ;)

Richard.

>
> 2017-07-25  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * gimple.c (gimple_assign_set_rhs_with_ops): Do not ask gsi_replace
>         to update EH info here.
>
>
> 2017-07-25  Javier Miranda  <miranda@adacore.com>
>
> ada/
>         * checks.adb (Apply_Divide_Checks): Ensure that operands are not
>         evaluated twice.
>
>
> 2017-07-25  Eric Botcazou  <ebotcazou@adacore.com>
>
> testsuite/
>         * gnat.dg/opt66.adb: New test.
>
>
> --
> Eric Botcazou

  reply	other threads:[~2017-07-26  7:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-25 14:41 Eric Botcazou
2017-07-26  7:52 ` Richard Biener [this message]
2017-07-28  7:37   ` Eric Botcazou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFiYyc3geBV6k0YACu8EqA=5saa6qmZbfZzgrS1ZNaP-qUmBgg@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).