From: Martin Sebor <msebor@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] look harder for MEM_REF operand equality to avoid -Wstringop-truncation (PR 84561)
Date: Thu, 30 Aug 2018 17:39:00 -0000 [thread overview]
Message-ID: <9ca1c7dc-041a-3e15-a191-34d16a68aa2f@gmail.com> (raw)
In-Reply-To: <DA544E5B-097A-43BB-806E-FD8D24DF577A@gmail.com>
On 08/30/2018 11:22 AM, Richard Biener wrote:
> On August 30, 2018 6:54:21 PM GMT+02:00, Martin Sebor <msebor@gmail.com> wrote:
>> On 08/30/2018 02:35 AM, Richard Biener wrote:
>>> On Thu, Aug 30, 2018 at 2:12 AM Martin Sebor <msebor@gmail.com>
>> wrote:
>>>>
>>>> The attached patch adds code to work harder to determine whether
>>>> the destination of an assignment involving MEM_REF is the same
>>>> as the destination of a prior strncpy call. The included test
>>>> case demonstrates when this situation comes up. During ccp,
>>>> dstbase and lhsbase returned by get_addr_base_and_unit_offset()
>>>> end up looking like this:
>>>
>>> "During CCP" means exactly when? The CCP lattice tracks copies
>>> so CCP should already know that _1 == _8. I suppose during
>>> substitute_and_fold then? But that replaces uses before folding
>>> the stmt.
>>
>> Yes, when ccp_finalize() performs the final substitution during
>> substitute_and_fold().
>
> But then you shouldn't need the loop but at most look at the pointer SSA Def to get at the non-invariant ADDR_EXPR.
I don't follow. Are you suggesting to compare
SSA_NAME_DEF_STMT (dstbase) to SSA_NAME_DEF_STMT (lhsbase) for
equality? They're not equal.
The first loop iterates once and retrieves
1. _8 = &pb_3(D)->a;
The second loop iterates three times and retrieves:
1. _1 = _9
2. _9 = _8
3. _8 = &pb_3(D)->a;
How do I get from _1 to &pb_3(D)->a without iterating? Or are
you saying to still iterate but compare the SSA_NAME_DEF_STMT?
Martin
>
> Richard.
>
>> Martin
>>
>>>
>>> So I'm confused.
>>>
>>>>
>>>> _8 = &pb_3(D)->a;
>>>> _9 = _8;
>>>> _1 = _9;
>>>> strncpy (MEM_REF (&pb_3(D)->a), ...);
>>>> MEM[(struct S *)_1].a[n_7] = 0;
>>>>
>>>> so the loops follow the simple assignments until we get at
>>>> the ADDR_EXPR assigned to _8 which is the same as the strncpy
>>>> destination.
>>>>
>>>> Tested on x86_64-linux.
>>>>
>>>> Martin
>
next prev parent reply other threads:[~2018-08-30 17:39 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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-01 21:46 ` [PING] " Martin Sebor
2018-10-08 22:03 ` [PING #2] " Martin Sebor
2018-10-31 17:11 ` [PING #3] " Martin Sebor
2018-11-16 3:09 ` [PING #4] " Martin Sebor
2018-11-16 8:46 ` Richard Biener
2018-11-19 14:55 ` Jeff Law
2018-11-19 16:27 ` Martin Sebor
2018-11-20 9:23 ` Richard Biener
2018-10-04 3:08 ` Jeff Law
2018-09-19 13:51 ` Richard Biener
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
2018-09-17 21:18 ` Martin Sebor
2018-09-18 0:17 ` Jeff Law
2018-09-18 2:49 ` Martin Sebor
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=9ca1c7dc-041a-3e15-a191-34d16a68aa2f@gmail.com \
--to=msebor@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--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).