This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] PR debug/66653: avoid late_global_decl on decl_type_context()s


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?

Richard.

> The attached patch fixes the problem.
>
> Tested with --enable-languages=all.  Ada had other issues, so I skipped it.
>
> OK for mainline?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]