public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Jason Merrill <jason@redhat.com>
Cc: Nathaniel Shead <nathanieloshead@gmail.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: End lifetime of objects in constexpr after destructor call [PR71093]
Date: Mon, 11 Dec 2023 20:17:22 +0100	[thread overview]
Message-ID: <5095B3D3-E545-4827-82BB-F7FD321F0225@suse.de> (raw)
In-Reply-To: <cddbfd86-86e9-4654-a1d7-73037d037be5@redhat.com>



> Am 11.12.2023 um 20:12 schrieb Jason Merrill <jason@redhat.com>:
> 
> On 12/11/23 03:02, Richard Biener wrote:
>>> On Sun, 10 Dec 2023, Jason Merrill wrote:
>>> On 12/10/23 05:22, Richard Biener wrote:
>>>>> Am 09.12.2023 um 21:13 schrieb Jason Merrill <jason@redhat.com>:
>>>>> 
>>>>> On 11/2/23 21:18, Nathaniel Shead wrote:
>>>>>> Bootstrapped and regtested on x86-64_pc_linux_gnu.
>>>>>> I'm not entirely sure if the change I made to have destructors clobber
>>>>>> with
>>>>>> CLOBBER_EOL instead of CLOBBER_UNDEF is appropriate, but nothing seemed to
>>>>>> have
>>>>>> broken by doing this and I wasn't able to find anything else that really
>>>>>> depended on this distinction other than a warning pass. Otherwise I could
>>>>>> experiment with a new clobber kind for destructor calls.
>>>>> 
>>>>> It seems wrong to me: CLOBBER_EOL is documented to mean that the storage is
>>>>> expiring at that point as well, which a (pseudo-)destructor does not imply;
>>>>> it's perfectly valid to destroy an object and then create another in the
>>>>> same storage.
>>>>> 
>>>>> We probably do want another clobber kind for end of object lifetime. And/or
>>>>> one for beginning of object lifetime.
>>>> 
>>>> There?s not much semantically different between UNDEF and end of object but
>>>> not storage lifetime?  At least for what middle-end optimizations do.
>>> 
>>> That's fine for the middle-end, but Nathaniel's patch wants to distinguish
>>> between the clobbers at beginning and end of object lifetime in order to
>>> diagnose stores to an out-of-lifetime object in constexpr evaluation.
>> Ah, I see.  I did want to add CLOBBER_SOL (start-of-life) when working
>> on PR90348, but I always fail to finish working on that stack-slot sharing
>> issue.  But it would be for the storage life, not object life, also
>> added by gimplification.
>>> One option might be to remove the clobber at the beginning of the constructor;
>>> are there any useful optimizations enabled by that, or is it just pedantically
>>> breaking people's code?
>> It's allowing DSE to the object that was live before the new one.  Not
>> all objects require explicit destruction (which would get you a clobber)
>> before storage can be re-used.
>>>> EOL is used by stack slot sharing and that operates on the underlying
>>>> storage, not individual objects live in it.
>>> 
>>> I wonder about changing the name to EOS (end of storage [duration]) to avoid
>>> similar confusion with object lifetime?
>> EOS{L,D}?  But sure, better names (and documentation) are appreciated.
> 
> Maybe something like this?  Or shall we write out the names like CLOBBER_OBJECT_START, CLOBBER_STORAGE_END, etc?

Yeah, the abbreviations look a bit confusing so spelling it out would be better

Richard 

> 
> <0001-tree-add-to-clobber_kind.patch>

  reply	other threads:[~2023-12-11 19:17 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-03  1:18 Nathaniel Shead
2023-11-03  1:34 ` Nathaniel Shead
2023-11-27 11:08   ` Nathaniel Shead
2023-12-09 20:12 ` Jason Merrill
2023-12-10 10:22   ` Richard Biener
2023-12-10 11:21     ` Alexander Monakov
2023-12-10 15:58       ` Richard Biener
2023-12-10 18:34     ` Jason Merrill
2023-12-11  8:02       ` Richard Biener
2023-12-11 19:12         ` Jason Merrill
2023-12-11 19:17           ` Richard Biener [this message]
2023-12-11 19:21             ` Marek Polacek
2023-12-11 22:00               ` Jason Merrill
2023-12-11 22:22                 ` Marek Polacek
2023-12-11 23:03                 ` Jakub Jelinek
2023-12-12 11:13                   ` Alexander Monakov
2023-12-12 11:15                     ` Jakub Jelinek
2023-12-12 15:24                       ` Jason Merrill
2023-12-12 17:50                         ` Jason Merrill
2023-12-13  4:40                           ` Jason Merrill
2023-12-13 16:47                             ` [pushed 1/4] c++: copy location to AGGR_INIT_EXPR Jason Merrill
2023-12-13 16:47                               ` [pushed 2/4] c++: constant direct-initialization [PR108243] Jason Merrill
2023-12-13 16:47                               ` [pushed 3/4] c++: fix in-charge parm in constexpr Jason Merrill
2023-12-13 16:47                               ` [pushed 4/4] c++: End lifetime of objects in constexpr after destructor call [PR71093] Jason Merrill
2023-12-13 18:05                               ` [pushed 1/4] c++: copy location to AGGR_INIT_EXPR Patrick Palka
2023-12-13 20:06                                 ` [pushed] c++: TARGET_EXPR location in default arg [PR96997] Jason Merrill
2023-12-14  0:00                               ` [pushed 1/4] c++: copy location to AGGR_INIT_EXPR Marek Polacek
2023-12-14  1:38                                 ` Jason Merrill
2023-12-14 14:25                                   ` Marek Polacek

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=5095B3D3-E545-4827-82BB-F7FD321F0225@suse.de \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=nathanieloshead@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).