From: Qing Zhao <qing.zhao@oracle.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Richard Biener <rguenther@suse.de>,
gcc-patches Nick Alcock via <gcc-patches@gcc.gnu.org>
Subject: Re: [Patch][PR102281]do not add BUILTIN_CLEAR_PADDING for variables that are gimple registers.
Date: Mon, 18 Oct 2021 17:01:55 +0000 [thread overview]
Message-ID: <FF9B8D4C-ADD3-456D-9359-DA25B2E10001@oracle.com> (raw)
In-Reply-To: <20211018164606.GC304296@tucnak>
> On Oct 18, 2021, at 11:46 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Mon, Oct 18, 2021 at 03:58:56PM +0000, Qing Zhao wrote:
>>> Furthermore, __builtin_clear_padding doesn't assume anything, but it takes
>>> an address of an object as argument and already the taking of the address
>>> that gimple_add_padding_init_for_auto_var does makes the var
>>> TREE_ADDRESABLE, which is something that needs to be done before the var is
>>> ever accessed during gimplification.
>>
>> Yes, currently, “gimple_add_padding_init_for_auto_var” has already done the following before
>> calling __builtin_clear_padding:
>>
>> mark_addressable (decl);
>> addr_of_decl = build_fold_addr_expr (decl);
>>
>> But looks like that “making the DECL as ADDRESSABLE here” is too late.
>
> Wouldn't be if we could prove it wasn't gimplified already.
>
>> Yes, If we can “make the DECL as ADDRESSABLE” before the var is accessed during gimplification, that will also
>> fix this issue. But “Where” is the right place to make the DECL as ADDRESSABLE? (Do it in “gimplify_decl_expr” when handling
>> The variable’s declaration? )
>
> The where is typically somewhere in the FEs.
> But, there are two things.
> One is that in order to gimplify it properly, it needs to be marked earlier.
> But the other is that if it is not addressable, then clearing padding in it
> makes not much sense as I've tried to explain, all it could do is making it
> slightly less likely that the var will be optimized into a gimple reg later,
> but if it does, then the padding will not be cleared anyway.
> And it is only at RTL expansion or RA that the var could be assigned into a
> stack location or spilled and at that point is the right time to clear
> padding in there if needed.
> So while the FEs could make it addressable and then you could clear padding,
> it would just penalize code and nothing else, later on the optimizations
> would figure out it is no longer addressable and optimize it into gimple
> reg.
So, from my understanding so far, adding “!is_gimple_reg(decl)” to decide whether to add __builtin_clear_padding call
is a good and simple solution to this bug?
Qing
>
> Jakub
>
next prev parent reply other threads:[~2021-10-18 17:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-18 15:04 Qing Zhao
2021-10-18 15:36 ` Jakub Jelinek
2021-10-18 15:58 ` Qing Zhao
2021-10-18 16:46 ` Jakub Jelinek
2021-10-18 17:01 ` Qing Zhao [this message]
2021-10-18 17:15 ` Jakub Jelinek
2021-10-18 17:24 ` 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=FF9B8D4C-ADD3-456D-9359-DA25B2E10001@oracle.com \
--to=qing.zhao@oracle.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=rguenther@suse.de \
/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).