public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Richard Biener <rguenther@suse.de>
Cc: Jakub Jelinek <jakub@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] debug/108772 - ICE with late debug generated with -flto
Date: Thu, 2 Mar 2023 08:19:57 -0500	[thread overview]
Message-ID: <c9f80e41-fc8c-f2e8-9cfb-25bd74e8abb4@redhat.com> (raw)
In-Reply-To: <nycvar.YFH.7.77.849.2303020734550.27913@jbgna.fhfr.qr>

On 3/2/23 02:43, Richard Biener wrote:
> On Wed, 1 Mar 2023, Jason Merrill wrote:
> 
>> On 3/1/23 08:09, Jakub Jelinek wrote:
>>> On Wed, Mar 01, 2023 at 01:07:02PM +0000, Richard Biener wrote:
>>>> When combining -g1 with -flto we run into the DIE location annotation
>>>> machinery for globals calling dwarf2out_late_global_decl but not
>>>> having any early generated DIE for function scope statics.  In
>>>> this process we'd generate a limbo DIE since also the function scope
>>>> doesn't have any early generated DIE.  The limbo handling then tries
>>>> to force a DIE for the context chain which ultimatively fails and
>>>> ICEs at the std namespace decl because at -g1 we don't represent that.
>>>>
>>>> The following avoids this situation by making sure to never generate
>>>> any limbo DIEs from dwarf2out_late_global_decl in the in_lto_p path
>>>> but instead for function scope globals rely on DIE generation for
>>>> the function to output a DIE for the local static (which doesn't
>>>> happen for -g1).
>>
>> So the issue is that we're trying to force out a DIE for a decl that we
>> wouldn't have generated without -flto?  How is it avoided in the non-LTO case?
> 
> When we go rest_of_decl_compilation for this decl we defer to the
> containing function to generate an early DIE but that doesn't
> (because of -g1).  The call to late_global_decl that's done by
> assemble_decl then does nothing because there's no early DIE.  But with
> -flto we cannot completely rely on early DIE presence (not even without,
> in case of cloning - but we don't clone global variables), esp. because
> there's still the "supported" non-early-LTO path for non-ELF targets.
> 
> So at this point it seems to be the best thing to mimic what
> rest_of_decl_compilation does and defer to dwarf2out of the
> containing function to generate the DIE (or not).  For the reason
> of the least amount of changes at this point in stage4 I went for
> querying the DECL_CONTEXT DIE instead of right-out not handling
> local_function_static () decls in this path.
> 
> If you'd prefer that, so
> 
>        if (! die && in_lto_p
>            /* Function scope variables are emitted when emitting the
>               DIE for the function.  */
>            && ! local_function_static (decl))
>          dwarf2out_decl (decl);
> 
> then I can test that variant as well which feels a bit more
> consistent.

That variant is OK, thanks.

Jason


  reply	other threads:[~2023-03-02 13:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <01327.123030108070400465@us-mta-295.us.mimecast.lan>
2023-03-01 13:09 ` Jakub Jelinek
2023-03-01 20:11   ` Jason Merrill
2023-03-02  7:43     ` Richard Biener
2023-03-02 13:19       ` Jason Merrill [this message]
     [not found] <20230301130718.E51473858C62@sourceware.org>
2023-03-11 20:08 ` Jeff Law
2023-03-01 13:07 Richard Biener

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=c9f80e41-fc8c-f2e8-9cfb-25bd74e8abb4@redhat.com \
    --to=jason@redhat.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).