The following patch fixes PR69137 where after the early-debug merge we build DECL_ASSEMBLER_NAME for TYPE_DECLs too early. The fix is easy - just go through the deferred-asm-name machinery.
LTO bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2016-01-15 Richard Biener <rguent...@suse.de> PR debug/69137 * dwarf2out.c (add_linkage_name_raw): New function split out from ... (add_linkage_name): ... here. (gen_typedef_die): Use add_linkage_name_raw instead of add_linkage_attr to delay DECL_ASSEMBLER_NAME computation if necessary. * g++.dg/lto/pr69137_0.C: New testcase. Index: gcc/dwarf2out.c =================================================================== *** gcc/dwarf2out.c (revision 232401) --- gcc/dwarf2out.c (working copy) *************** add_src_coords_attributes (dw_die_ref di *** 18574,18579 **** --- 18574,18599 ---- /* Add DW_AT_{,MIPS_}linkage_name attribute for the given decl. */ static void + add_linkage_name_raw (dw_die_ref die, tree decl) + { + /* Defer until we have an assembler name set. */ + if (!DECL_ASSEMBLER_NAME_SET_P (decl)) + { + limbo_die_node *asm_name; + + asm_name = ggc_cleared_alloc<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); + } + + /* Add DW_AT_{,MIPS_}linkage_name attribute for the given decl if desired. */ + + static void add_linkage_name (dw_die_ref die, tree decl) { if (debug_info_level > DINFO_LEVEL_NONE *************** add_linkage_name (dw_die_ref die, tree d *** 18581,18601 **** && TREE_PUBLIC (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_cleared_alloc<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); ! } } /* Add a DW_AT_name attribute and source coordinate attribute for the --- 18601,18607 ---- && TREE_PUBLIC (decl) && !(TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl)) && die->die_tag != DW_TAG_member) ! add_linkage_name_raw (die, decl); } /* Add a DW_AT_name attribute and source coordinate attribute for the *************** gen_typedef_die (tree decl, dw_die_ref c *** 22425,22431 **** is the name of the typedef decl naming the anonymous struct. This greatly eases the work of consumers of this debug info. */ ! add_linkage_attr (lookup_type_die (type), decl); } } --- 22431,22437 ---- is the name of the typedef decl naming the anonymous struct. This greatly eases the work of consumers of this debug info. */ ! add_linkage_name_raw (lookup_type_die (type), decl); } } Index: gcc/testsuite/g++.dg/lto/pr69137_0.C =================================================================== *** gcc/testsuite/g++.dg/lto/pr69137_0.C (revision 0) --- gcc/testsuite/g++.dg/lto/pr69137_0.C (working copy) *************** *** 0 **** --- 1,8 ---- + // { dg-lto-do link } + // { dg-lto-options { { -std=c++11 -g -flto } } } + // { dg-extra-ld-options "-r -nostdlib" } + + typedef struct { + typedef struct { } VarSelectorRecord; + } Format14Cmap; + void fn1() { Format14Cmap a; }