From: Richard Guenther <richard.guenther@gmail.com>
To: Jason Merrill <jason@redhat.com>
Cc: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: RFA: PATCH to make fold_indirect_ref_1 fold more things
Date: Fri, 29 Oct 2010 16:06:00 -0000 [thread overview]
Message-ID: <AANLkTimeH4v43OivNW8r7=GiSB4Bw0Svy5ufL5AcNvZa@mail.gmail.com> (raw)
In-Reply-To: <4CC97076.5040506@redhat.com>
On Thu, Oct 28, 2010 at 2:45 PM, Jason Merrill <jason@redhat.com> wrote:
> On 10/27/2010 02:29 PM, Richard Guenther wrote:
>>
>> On Tue, Oct 26, 2010 at 6:35 PM, Jason Merrill<jason@redhat.com> wrote:
>>>
>>> For constexpr I need to be able to fold some tree forms that
>>> fold_indirect_ref_1 didn't handle; this patch extends it to handle
>>> folding
>>> POINTER_PLUS_EXPR to an ARRAY_REF, and also folding to COMPONENT_REF.
>>
>> I think by making this kind of transforms you are prone to bugs like
>> PR44468.
>
> Ah, interesting. But it seems to me that this case is different because we
> are starting from an ADDR_EXPR around an expression of the aggregate type in
> the folded expression, not just any pointer to the aggregate type. What do
> you think?
Hm, I think what might save you is that you only look into immediate
fields (not fields
in sub-structs as we originally did).
Now I am concerned about sth like
struct S {
int i;
int j;
};
struct R {
struct S a;
int k;
};
struct S s;
int main()
{
struct R *p = (struct R *)&s;
s.i = 1;
s.j = 2;
(*(struct S *)&*p).i = 0;
if (s.i != 0)
abort ();
return 0;
}
where if we end up folding the obfuscated access to p->a.i = 0 we will generate
wrong code (one might argue that *p is invalid in C, but I'm viewing this from
a middle-end POV, not a C one). Now if &* is already folded it will look as
p and so your code wouldn't trigger, but I guess this is just a matter of
obfuscating (like using &(*p + offset)) - the point is that the actual access
would change from one via struct S to one via struct R (and the alias set
of struct is a subset of that of R, but not the other way around).
So - what kind of testcases are you trying to handle? (the middle-end will
optimize this stuff keeping TBAA info correct during forwprop)
Richard.
> Jason
>
next prev parent reply other threads:[~2010-10-29 15:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-27 2:16 Jason Merrill
2010-10-27 20:10 ` Richard Guenther
2010-10-28 16:18 ` Jason Merrill
2010-10-29 16:06 ` Richard Guenther [this message]
2010-10-29 21:51 ` Jason Merrill
2010-10-30 7:53 ` Richard Guenther
2010-10-31 23:44 ` Jason Merrill
2010-11-01 22:17 ` Richard Guenther
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='AANLkTimeH4v43OivNW8r7=GiSB4Bw0Svy5ufL5AcNvZa@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.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).