public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: "Bin.Cheng" <amker.cheng@gmail.com>, Richard Earnshaw <rearnsha@arm.com>
Cc: Bin Cheng <bin.cheng@arm.com>,
	       "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH PR62151]Fix uninitialized register issue caused by distribute_notes in combine pass
Date: Sat, 30 Aug 2014 05:58:00 -0000	[thread overview]
Message-ID: <5401680D.60907@redhat.com> (raw)
In-Reply-To: <CAHFci28BS75pySKVtLTeY8BQsYupJHvXs73ZdYq1RkfHLbXocQ@mail.gmail.com>

On 08/27/14 23:04, Bin.Cheng wrote:
> On Wed, Aug 27, 2014 at 6:34 PM, Richard Earnshaw <rearnsha@arm.com> wrote:
>> On 27/08/14 11:08, Bin Cheng wrote:
>>> Hi
>>> As reported in bug pr62151, combine pass may wrongly delete necessary
>>> instruction in function distribute_notes thus leaving register
>>> uninitialized.  This patch is to fix the issue by checking if i2 immediately
>>> modifies the register in REG_DEAD note.  If yes, set tem_insn accordingly to
>>> start finding right place for note distribution from i2.
>>>
>>> I once sent a RFC patch at
>>> https://gcc.gnu.org/ml/gcc-patches/2014-08/msg01718.html, but got no
>>> comments,  here I added some comments in this patch to make it a formal one.
>>>
>>>
>>> I tested the original patch, and will re-test it against the latest code
>>> later.  So is it OK?  Any comments will be appreciated.
>>>
>>
>> Isn't this the sort of sequence that combinable_i3pat is supposed to reject?
> Hi Richard,
> I think it's not.  combinable_i3pat checks cases in which i1 feeds to
> i3 directly, while i2 kills reg_use in i1.  For this case the feeding
> chain is "i0->i1->i2->i3", the combination is valid and beneficial.
> What needs to be handled is if i2dest is anticipated after i3.  If
> not, then i2 could be deleted; if yes, i2 should be preserved.
> Moreover, following constant propagation could delete i2 after
> propagating the new i2src into i4.  Note combine pass already handles
> this kind of case using variable added_sets_2 in function try_combine.
> The problem is in distribute_notes which mis-deleted i2.
>
> I added one test case in the updated patch.
One could argue that this mess is a result of trying to optimize a reg 
that is set more than once.    Though I guess that might be a bit of a 
big hammer.

I haven't thought real hard, but isn't it the case that for a pseudo 
with multiple sets that we never want to move a REG_DEAD note across a 
set of that pseudo?  It would seem that in these cases we want to drop 
the REG_DEAD note completely.

Note that i0..i4 need not be consecutive insns, so you'd have to walk 
the chain from the location with the death note to the proposed death 
note site.  If between those locations there's another set of the same 
pseudo, then drop the note.  Since this may be an expensive check it 
should probably be conditionalized on REG_N_SETS (pseudo) > 1

Jeff

  reply	other threads:[~2014-08-30  5:58 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-27 10:08 Bin Cheng
2014-08-27 10:34 ` Richard Earnshaw
2014-08-28  5:04   ` Bin.Cheng
2014-08-30  5:58     ` Jeff Law [this message]
2014-08-31 12:19       ` Segher Boessenkool
2014-09-01  3:36         ` Bin.Cheng
2014-09-01 11:39           ` Segher Boessenkool
2014-09-01 16:52             ` Jeff Law
2014-09-01 17:50               ` Segher Boessenkool
2014-09-02  2:02                 ` Bin.Cheng
2014-09-02 11:40                   ` Segher Boessenkool
2014-09-02  3:35                 ` Jeff Law
2014-09-02 12:10                 ` Ulrich Weigand
2014-09-02 13:41                   ` Segher Boessenkool
2014-09-03  2:36                     ` Bin.Cheng
2014-09-03 13:21                       ` Segher Boessenkool
2014-09-01 16:52         ` Jeff Law
2014-09-01 19:16           ` Segher Boessenkool
2014-09-02  3:28             ` Jeff Law
2014-09-02  5:18               ` Bin.Cheng
2014-09-05  4:17                 ` Jeff Law
2014-09-02 11:50               ` Segher Boessenkool
2014-09-01  4:18       ` Bin.Cheng
2014-09-02  3:40         ` Jeff Law
2014-09-02  5:15           ` Bin.Cheng
2014-09-05  4:13             ` Jeff Law

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=5401680D.60907@redhat.com \
    --to=law@redhat.com \
    --cc=amker.cheng@gmail.com \
    --cc=bin.cheng@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rearnsha@arm.com \
    /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).