https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87295
--- Comment #13 from Richard Biener <rguenth at gcc dot gnu.org> --- OK, so we're cloning from two different type units ultimatively refering to the same DIE. This means that copy_ancestor_tree doesn't set up decl_table appropriately since it doesn't have the same logic as clone_as_declaration. The following fixes tramp3d and survives the dwarf2.exp testsuites. Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 268446) +++ gcc/dwarf2out.c (working copy) @@ -8169,6 +8169,11 @@ copy_ancestor_tree (dw_die_ref unit, dw_ decl_table_entry **slot = NULL; struct decl_table_entry *entry = NULL; + /* If DIE refers to a stub unfold that so we get the appropriate + DIE registered as orig in decl_table. */ + if (dw_die_ref c = get_AT_ref (die, DW_AT_signature)) + die = c; + if (decl_table) { /* Check if the entry has already been copied to UNIT. */