public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
To: Richard Biener <richard.guenther@gmail.com>,
	Jeff Law <law@redhat.com>,	Martin Sebor <msebor@gmail.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] look harder for MEM_REF operand equality to avoid -Wstringop-truncation (PR 84561)
Date: Mon, 17 Sep 2018 18:41:00 -0000	[thread overview]
Message-ID: <VI1PR0701MB2862F8BAC2DCC7C389870ECEE41E0@VI1PR0701MB2862.eurprd07.prod.outlook.com> (raw)
In-Reply-To: <A38C4345-1EDB-4D3E-AC8C-F5877C8D408A@gmail.com>

On 09/17/18 19:35, Richard Biener wrote:
> On September 17, 2018 7:24:16 PM GMT+02:00, Jeff Law <law@redhat.com> wrote:
>> On 9/15/18 2:14 AM, Bernd Edlinger wrote:
>>> On 9/14/18, Martin Sebor wrote:
>>>> As I said above, this happens during the dom walk in the ccp
>>>> pass:
>>>>
>>>>    substitute_and_fold_dom_walker walker (CDI_DOMINATORS, this);
>>>>    walker.walk (ENTRY_BLOCK_PTR_FOR_FN (cfun));
>>>>
>>>> The warning is issued during the walker.walk() call as
>>>> strncpy is being folded into memcpy.  The prior assignments are
>>>> only propagated later, when the next statement after the strncpy
>>>> call is reached.  It happens in
>>>> substitute_and_fold_dom_walker::before_dom_children(). So during
>>>> the strncpy folding we see the next statement as:
>>>>
>>>>    MEM[(struct S *)_1].a[n_7] = 0;
>>>>
>>>> After the strncpy call is transformed to memcpy, the assignment
>>>> above is transformed to
>>>>
>>>>    MEM[(struct S *)_8].a[3] = 0;
>>>>
>>>>
>>>>>      If they're only discovered as copies within the pass where
>> you're trying
>>>>>      to issue the diagnostic, then you'd want to see if the pass has
>> any
>>>>>      internal structures that tell you about equivalences.
>>>>
>>>>
>>>> I don't know if this is possible.  I don't see any APIs in
>>>> tree-ssa-propagate.h that would let me query the internal data
>>>> somehow to find out during folding (when the warning is issued).
>>>
>>>
>>> Well,
>>>
>>> if I see this right, the CCP is doing tree transformations
>>> while from the folding of strncpy the predicate
>> maybe_diag_stxncpy_trunc
>>> is called, and sees inconsistent information, in the tree,
>>> and therefore it issues a warning.
>>>
>>> I understand that walking the references is fragile at least
>>> in this state.
>>>
>>> But why not just prevent warnings when this is called from CCP?
>>>
>>>
>>> Like this?
>>>
>>> Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
>>> Is it OK for trunk?
>> No.  That's just hacking around the real problem.
> 
> The real problem is emitting diagnostics from folding code.
> 

Yes, I am also very concerned about that.

So if this is a design bug, then it is probably impossible
to fix at the implementation, and we should fix the design.

It is unfortunate, that this means regressions on the existing
(and probably also proposed, future) test cases.


Bernd.

  reply	other threads:[~2018-09-17 18:35 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-15  8:43 Bernd Edlinger
2018-09-17 17:34 ` Jeff Law
2018-09-17 17:50   ` Richard Biener
2018-09-17 18:41     ` Bernd Edlinger [this message]
2018-09-17 21:18     ` Martin Sebor
2018-09-18  0:17       ` Jeff Law
2018-09-18  2:49         ` Martin Sebor
  -- strict thread matches above, loose matches on Subject: below --
2018-08-30  0:12 Martin Sebor
2018-08-30  8:35 ` Richard Biener
2018-08-30 16:54   ` Martin Sebor
2018-08-30 17:22     ` Richard Biener
2018-08-30 17:39       ` Martin Sebor
2018-08-31 10:07         ` Richard Biener
2018-09-12 18:03           ` Martin Sebor
2018-09-14 21:35             ` Jeff Law
2018-09-14 23:44               ` Martin Sebor
2018-09-17 23:13                 ` Jeff Law
2018-09-18 17:38                   ` Martin Sebor
2018-09-18 19:24                     ` Jeff Law
2018-09-18 20:01                       ` Martin Sebor
2018-09-19  5:40                         ` Jeff Law
2018-09-19 14:31                           ` Martin Sebor
2018-09-20  9:21                             ` Richard Biener
2018-09-21 14:50                               ` Martin Sebor
2018-10-04  3:08                             ` Jeff Law
2018-09-19 13:51                       ` Richard Biener

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=VI1PR0701MB2862F8BAC2DCC7C389870ECEE41E0@VI1PR0701MB2862.eurprd07.prod.outlook.com \
    --to=bernd.edlinger@hotmail.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --cc=msebor@gmail.com \
    --cc=richard.guenther@gmail.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).