This fixes one old and annyoing bug wrt LTO and debug-information. We pre-seed the LTO tree streamer cache with nodes from global_trees[] and friends, but this causes the type variant chain to become corrupt (in the sense that we do not merge TYPE_DECLs, so a get_qualified_type will fail to find a variant because the names (TYPE_DECLs) are not pointer-equal). dwarf2out.c already contains backup code for this case (get_qualified_type returning NULL) using __unknown__ for AT_name. But we can do better, use the actual name of the type.
[long term we want to stop pre-seeding the LTO tree streamer cache, but that's clearly nothing for stage3] Boostrap and regtest pending on x86_64-unknown-linux-gnu, ok if that succeeds? Thanks, Richard. 2011-12-19 Richard Guenther <rguent...@suse.de> PR lto/46796 * dwarf2out.c (modified_type_die): When the type variant chain is corrupt use the types name, if available, instead of __unknown__. Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 182472) +++ gcc/dwarf2out.c (working copy) @@ -9873,7 +9873,14 @@ modified_type_die (tree type, int is_con } /* This probably indicates a bug. */ else if (mod_type_die && mod_type_die->die_tag == DW_TAG_base_type) - add_name_attribute (mod_type_die, "__unknown__"); + { + name = TYPE_NAME (type); + if (name + && TREE_CODE (name) == TYPE_DECL) + name = DECL_NAME (name); + add_name_attribute (mod_type_die, + name ? IDENTIFIER_POINTER (name) : "__unknown__"); + } if (qualified_type) equate_type_number_to_die (qualified_type, mod_type_die);