From: Qing Zhao <qing.zhao@oracle.com>
To: Richard Sandiford <richard.sandiford@arm.com>
Cc: Qing Zhao via Gcc-patches <gcc-patches@gcc.gnu.org>,
Richard Biener <rguenther@suse.de>,
Jakub Jelinek <jakub@redhat.com>,
Kees Cook <keescook@chromium.org>
Subject: Re: [patch][version 6] add -ftrivial-auto-var-init and variable attribute "uninitialized" to gcc
Date: Wed, 11 Aug 2021 16:29:37 +0000 [thread overview]
Message-ID: <EF73284A-0A80-48E9-AE62-34F507D4F3B4@oracle.com> (raw)
In-Reply-To: <mpty298ufei.fsf@arm.com>
> On Aug 11, 2021, at 11:15 AM, Richard Sandiford <richard.sandiford@arm.com> wrote:
>
> Qing Zhao <qing.zhao@oracle.com> writes:
>>> On Aug 11, 2021, at 4:02 AM, Richard Sandiford <richard.sandiford@arm.com> wrote:
>>>> I came up with the following solution:
>>>>
>>>> Define the IFN_DEFERRED_INIT function as:
>>>>
>>>> LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, IS_VLA);
>>>>
>>>> if IS_VLA is false, the LHS is the DECL itself,
>>>> if IS_VLA is true, the LHS is the pointer to this DECL that created by
>>>> gimplify_vla_decl.
>>>>
>>>>
>>>> The benefit of this solution are:
>>>>
>>>> 1. Resolved the invalid IR issue;
>>>> 2. The call stmt carries the address of the VLA natually;
>>>>
>>>> The issue with this solution is:
>>>>
>>>> For VLA and non-VLA, the LHS will be different,
>>>>
>>>> Do you see any other potential issues with this solution?
>>>
>>> The idea behind the DECL version of the .DEFERRED_INIT semantics was
>>> that .DEFERRED_INIT just returns a SIZE-byte value that the caller
>>> then assigns to a SIZE-byte lhs (with the caller choosing the lhs).
>>> .DEFEREED_INIT itself doesn't read or write memory and so can be const,
>>> which in turn allows alias analysis to be more precise.
>> Yes. That’s right.
>>
>>>
>>> If we want to handle the VLA case using pointers instead then I think
>>> that needs to be a different IFN.
>>>
>>> If we did handle the VLA case using pointers (not expressing an opinion
>>> on that), then it would be the caller's job to allocate the VLA and work
>>> out the address of the VLA;
>>
>> the current routine “gimplify_vla_decl” has done this already:
>>
>> It created a temporary variable for the address of the VLA, and created a call to “alloca” to allocate the VLA.
>
> Right, that's what I mean. It's this alloca that allocates the VLA
> and determines its address. This address is therefore logically an
> input rather than an output to the following zero/pattern initialisation.
>
> In C you wouldn't write:
>
> addr = alloca(size);
> addr = initialise(size);
>
> to allocate and initialise a size-byte buffer, because initialise()
> would need to know the address of the memory it's supposed to initialise.
> The same is true for this gimple code.
This really make good sense to me. :-)
>
>> My -ftrivial-auto-var-init work just try to use the “address variable of the VLA” in the new .DEFERRED_INIT call to carry it to RTL expansion phase.
>>
>>
>>> this isn't something that .DEFERRED_INIT
>>> would work out on the caller's behalf. The address of the VLA should
>>> therefore be an argument to the new IFN, rather than something that
>>> the IFN returns.
>>
>> Then what’s the LHS of this call? Currently the major issue is the LHS is invalid gimple.
>
> For this (different, address-taking, VLA-only) IFN, there would be no lhs.
> The IFN would be similar to a memset.
I see.
>
> Like I say, this is all hypothetical, based on “if we did handle the VLA
> case using pointers”. As discussed, it would make alias analysis less
> precise. I was just answering the question about whether there were
> potential issues.
Okay, understood.
I will not handle the VLA case using pointers at this time.
Per discussion with Richard Biener in the other emails, I might go the other route to special handle the
_1 = .DEFERRED_INIT (4, 2, 0);
alt_reloc = _1;
To see whether that can resolve the issues.
Let me know your opinion.
Thanks a lot.
Qing
>
> Thanks,
> Richard
next prev parent reply other threads:[~2021-08-11 16:29 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-27 3:26 Qing Zhao
2021-07-28 20:21 ` Kees Cook
2021-07-28 21:53 ` Qing Zhao
2021-08-09 14:09 ` Richard Biener
2021-08-09 16:38 ` Qing Zhao
2021-08-09 17:14 ` Richard Biener
2021-08-10 7:36 ` Richard Biener
2021-08-10 13:39 ` Qing Zhao
2021-08-10 14:16 ` Richard Biener
2021-08-10 15:02 ` Qing Zhao
2021-08-10 15:22 ` Richard Biener
2021-08-10 15:55 ` Qing Zhao
2021-08-10 20:16 ` Qing Zhao
2021-08-10 22:26 ` Qing Zhao
2021-08-11 7:02 ` Richard Biener
2021-08-11 13:33 ` Qing Zhao
2021-08-11 13:37 ` Richard Biener
2021-08-11 13:54 ` Qing Zhao
2021-08-11 13:58 ` Richard Biener
2021-08-11 14:00 ` Qing Zhao
2021-08-11 15:30 ` Qing Zhao
2021-08-11 15:53 ` Richard Biener
2021-08-11 16:22 ` Qing Zhao
2021-08-11 16:55 ` Richard Biener
2021-08-11 16:57 ` Qing Zhao
2021-08-11 20:30 ` Qing Zhao
2021-08-11 22:03 ` Qing Zhao
2021-08-16 7:12 ` Richard Biener
2021-08-16 14:48 ` Qing Zhao
2021-08-16 15:08 ` Richard Biener
2021-08-16 15:39 ` Qing Zhao
2021-08-16 7:11 ` Richard Biener
2021-08-16 16:48 ` Qing Zhao
2021-08-17 15:04 ` Qing Zhao
2021-08-17 20:40 ` Qing Zhao
2021-08-18 7:19 ` Richard Biener
2021-08-18 14:39 ` Qing Zhao
2021-08-11 9:02 ` Richard Sandiford
2021-08-11 13:44 ` Qing Zhao
2021-08-11 16:15 ` Richard Sandiford
2021-08-11 16:29 ` Qing Zhao [this message]
2021-08-12 19:24 ` Qing Zhao
2021-08-12 22:45 ` Qing Zhao
2021-08-16 7:40 ` Richard Biener
2021-08-16 15:45 ` Qing Zhao
2021-08-17 8:29 ` Richard Biener
2021-08-17 14:50 ` Qing Zhao
2021-08-17 16:08 ` Qing Zhao
2021-08-18 7:15 ` Richard Biener
2021-08-18 16:02 ` Qing Zhao
2021-08-19 9:00 ` Richard Biener
2021-08-19 13:54 ` Qing Zhao
2021-08-20 14:52 ` Qing Zhao
2021-08-23 13:55 ` Richard Biener
2021-09-02 17:24 ` Qing Zhao
2021-08-16 19:49 ` Qing Zhao
2021-08-17 8:43 ` Richard Biener
2021-08-17 14:03 ` Qing Zhao
2021-08-17 14:45 ` Richard Biener
2021-08-17 14:53 ` Qing Zhao
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=EF73284A-0A80-48E9-AE62-34F507D4F3B4@oracle.com \
--to=qing.zhao@oracle.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=keescook@chromium.org \
--cc=rguenther@suse.de \
--cc=richard.sandiford@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).