This removes defering DECL_ASSEMBLER_NAME computation inside dwarf2out.c, something which is not possible when LTO is enabled during compilation as we free up tree fields after we think the frontend is finished - but DECL_ASSEMBLER_NAME computation involves a langhook and frontend specific data. In theory we try hard to properly assign assembler names for everything reachable in free_lang_data, but the frontend hands even "unreachable" types to dwarf2out via rest_of_type_compilation and debug_hooks->type_decl.
Another approach would be to only call add_linkage_attr if the assembler name was set meanwhile by other means, thus Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 188063) +++ gcc/dwarf2out.c (working copy) @@ -22158,7 +22158,8 @@ dwarf2out_finish (const char *filename) for (node = deferred_asm_name; node; node = node->next) { tree decl = node->created_for; - if (DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl)) + if (DECL_ASSEMBLER_NAME_SET_P (decl) + && DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl)) { add_linkage_attr (node->die, decl); move_linkage_attr (node->die); But I bootstrapped and tested the following variant instead which generates the same code and debuginfo with -O0 -g for tramp3d at the cost of a 0.01% compile-time hit (not sure, but I suppose the deferral was for a reason?). Ok? Thanks, Richard. 2012-05-31 Richard Guenther <rguent...@suse.de> PR debug/53471 * dwarf2out.c (deferred_asm_name): Remove. (add_linkage_name): Force DECL_ASSEMBLER_NAME creation here. (move_linkage_attr): Remove. (dwarf2out_finish): Do not process deferred_asm_name. Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 188056) +++ gcc/dwarf2out.c (working copy) @@ -2652,10 +2652,6 @@ static GTY(()) comdat_type_node *comdat_ /* A list of DIEs with a NULL parent waiting to be relocated. */ static GTY(()) limbo_die_node *limbo_die_list; -/* A list of DIEs for which we may have to generate - DW_AT_{,MIPS_}linkage_name once their DECL_ASSEMBLER_NAMEs are set. */ -static GTY(()) limbo_die_node *deferred_asm_name; - /* Filenames referenced by this compilation unit. */ static GTY((param_is (struct dwarf_file_data))) htab_t file_table; @@ -15394,22 +15390,9 @@ add_linkage_name (dw_die_ref die, tree d && TREE_PUBLIC (decl) && !DECL_ABSTRACT (decl) && !(TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl)) - && die->die_tag != DW_TAG_member) - { - /* Defer until we have an assembler name set. */ - if (!DECL_ASSEMBLER_NAME_SET_P (decl)) - { - limbo_die_node *asm_name; - - asm_name = ggc_alloc_cleared_limbo_die_node (); - asm_name->die = die; - asm_name->created_for = decl; - asm_name->next = deferred_asm_name; - deferred_asm_name = asm_name; - } - else if (DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl)) - add_linkage_attr (die, decl); - } + && die->die_tag != DW_TAG_member + && DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl)) + add_linkage_attr (die, decl); } /* Add a DW_AT_name attribute and source coordinate attribute for the @@ -21161,37 +21144,6 @@ htab_ct_eq (const void *of1, const void DWARF_TYPE_SIGNATURE_SIZE)); } -/* Move a DW_AT_{,MIPS_}linkage_name attribute just added to dw_die_ref - to the location it would have been added, should we know its - DECL_ASSEMBLER_NAME when we added other attributes. This will - probably improve compactness of debug info, removing equivalent - abbrevs, and hide any differences caused by deferring the - computation of the assembler name, triggered by e.g. PCH. */ - -static inline void -move_linkage_attr (dw_die_ref die) -{ - unsigned ix = VEC_length (dw_attr_node, die->die_attr); - dw_attr_node linkage = *VEC_index (dw_attr_node, die->die_attr, ix - 1); - - gcc_assert (linkage.dw_attr == DW_AT_linkage_name - || linkage.dw_attr == DW_AT_MIPS_linkage_name); - - while (--ix > 0) - { - dw_attr_node *prev = VEC_index (dw_attr_node, die->die_attr, ix - 1); - - if (prev->dw_attr == DW_AT_decl_line || prev->dw_attr == DW_AT_name) - break; - } - - if (ix != VEC_length (dw_attr_node, die->die_attr) - 1) - { - VEC_pop (dw_attr_node, die->die_attr); - VEC_quick_insert (dw_attr_node, die->die_attr, ix, &linkage); - } -} - /* Helper function for resolve_addr, mark DW_TAG_base_type nodes referenced from typed stack ops and count how often they are used. */ @@ -22155,18 +22107,6 @@ dwarf2out_finish (const char *filename) resolve_addr (comp_unit_die ()); move_marked_base_types (); - for (node = deferred_asm_name; node; node = node->next) - { - tree decl = node->created_for; - if (DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl)) - { - add_linkage_attr (node->die, decl); - move_linkage_attr (node->die); - } - } - - deferred_asm_name = NULL; - /* Walk through the list of incomplete types again, trying once more to emit full debugging info for them. */ retry_incomplete_types ();