public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@redhat.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>, jason merrill <jason@redhat.com>
Subject: Re: [patch] PR debug/66653: avoid late_global_decl on decl_type_context()s
Date: Thu, 25 Jun 2015 15:08:00 -0000	[thread overview]
Message-ID: <558C16CA.3030409@redhat.com> (raw)
In-Reply-To: <CAFiYyc13ELkrRGR4FxpYMpRh8v1m=kS8C_E36D71ZwhX-KFzxw@mail.gmail.com>

On 06/25/2015 02:48 AM, Richard Biener wrote:
> On Thu, Jun 25, 2015 at 5:12 AM, Aldy Hernandez <aldyh@redhat.com> wrote:
>> The problem here is that we are trying to call dwarf2out_late_global_decl()
>> on a static variable in a template which has a type of TEMPLATE_TYPE_PARM:
>>
>> template <typename T> class A
>> {
>>    static __thread T a;
>> };
>>
>> We are calling late_global_decl because we are about to remove the unused
>> static from the symbol table:
>>
>>            /* See if the debugger can use anything before the DECL
>>               passes away.  Perhaps it can notice a DECL that is now a
>>               constant and can tag the early DIE with an appropriate
>>               attribute.
>>
>>               Otherwise, this is the last chance the debug_hooks have
>>               at looking at optimized away DECLs, since
>>               late_global_decl will subsequently be called from the
>>               contents of the now pruned symbol table.  */
>>            if (!decl_function_context (node->decl))
>>              (*debug_hooks->late_global_decl) (node->decl);
>>
>> Since gen_type_die_with_usage() cannot handle TEMPLATE_TYPE_PARMs we ICE.
>>
>> I think we need to avoid calling late_global_decl on DECL's for which
>> decl_type_context() is true, similarly to what we do for the call to
>> early_global_decl in rest_of_decl_compilation:
>>
>>        && !decl_function_context (decl)
>>        && !current_function_decl
>>        && DECL_SOURCE_LOCATION (decl) != BUILTINS_LOCATION
>>        && !decl_type_context (decl))
>>      (*debug_hooks->early_global_decl) (decl);
>>
>> Presumably the old code did not run into this problem because the
>> TEMPLATE_TYPE_PARAMs had been lowered by the time dwarf2out_decl was called,
>> but here we are calling late_global_decl relatively early.
>
> I think we need to sort out that instead - by the time we call _early_
> global decl it
> should already be "lowered".  Otherwise LTO streaming will run into
> the decl_type_context it cannot handle.  Is the case running into
> late_global_decl
> before we called early_global_decl on it btw?

Typically in C++ we call early_global_decl via:

	cp_finish_decl
	  -> make_rtl_for_nonlocal_decl
	    -> rest_of_decl_compilation
	      -> early_global_decl.

However, in this case we have not called early_global_decl on the DECL 
because cp_finish_decl avoids the make_rtl_for_nonlocal_decl path for 
templates:

cp_finish_decl():
   ...
   if (processing_template_decl)
     {
       bool type_dependent_p;
       ...
       ...
       return;
     }

Aldy

  reply	other threads:[~2015-06-25 14:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-25  3:19 Aldy Hernandez
2015-06-25  9:49 ` Richard Biener
2015-06-25 15:08   ` Aldy Hernandez [this message]
2015-06-25 13:56 ` Eric Botcazou
2015-06-25 14:57   ` Aldy Hernandez
2015-06-25 20:57     ` Eric Botcazou
2015-06-25 17:02 ` Jason Merrill
2015-06-26  9:40   ` Richard Biener
2015-06-26 22:04     ` Jason Merrill
2015-06-29  9:14       ` Richard Biener
2015-06-29 22:35         ` Jason Merrill
2015-06-30 14:43           ` Jason Merrill
2015-07-01  7:39             ` 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=558C16CA.3030409@redhat.com \
    --to=aldyh@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=richard.guenther@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).