Hi,
the following two patches both "fix" the immediate issue of gdb asserting with ../../gdb/dwarf2read.c:9730: internal-error: void dw2_add_symbol_to_list(symbol*, pending**): Assertion `(*listhead) == NULL || (SYMBOL_LANGUAGE ((*listhead)->symbol[0]) == SYMBOL_LANGUAGE (symbol))' failed. on most LTO compiled objects now. I tracked this down to us generating bogus DWARF (as I read it), specifically an inline instance that is output not as DW_TAG_inlined_subroutine but represented as DW_TAG_lexical_block (but otherwise with same children and abstract origin). This is because we do have (quite a lot :/) inlined calls with LOCATION_LOCUS (gimple_location (stmt)) == UNKNOWN_LOCATION and thus inlined_function_outer_scope_p returning false on the BLOCK the inliner generates. A third yet untested alternative would be to store the combined locus|BLOCK location in BLOCK_SOURCE_LOCATION and in inlined_function_outer_scope_p check for literal UNKNOWN_LOCATION instead of looking at LOCATION_LOCUS. We'd have to properly remap the locus in remap_block (which may be a chicken-and-egg issue) to not run foul of what I fixed with r196542. But somehow that runs into issues with the new debug notes Alex added last year. Similarly keying on BLOCK_ABSTRACT_ORIGIN rather than BLOCK_SOURCE_LOCATION in inlined_function_outer_scope_p. Any ideas? The least fallout is probably produced by the BUILTINS_LOCATION "hack" (but dwarf2out.c assumes that the locations are sensible and thus will output some "interesting" src-coords for the lexical block, <built-in>:0 respectively). Thanks, Richard. 2018-09-25 Richard Biener <rguent...@suse.de> PR debug/87428 PR debug/87362 * tree-inline.c (expand_call_inline): When the location of the call is UNKNOWN_LOCATION drop debug info on the floor. Index: gcc/tree-inline.c =================================================================== --- gcc/tree-inline.c (revision 264564) +++ gcc/tree-inline.c (working copy) @@ -4525,7 +4525,8 @@ expand_call_inline (basic_block bb, gimp artificial decls inserted by the compiler itself. We need to either link the inlined blocks into the caller block tree or not refer to them in any way to not break GC for locations. */ - if (gimple_block (stmt)) + if (gimple_block (stmt) + && LOCATION_LOCUS (gimple_location (stmt)) != UNKNOWN_LOCATION) { id->block = make_node (BLOCK); BLOCK_ABSTRACT_ORIGIN (id->block) = fn; @@ -4591,7 +4592,7 @@ expand_call_inline (basic_block bb, gimp if (DECL_INITIAL (fn)) { - if (gimple_block (stmt)) + if (id->block) { tree *var; 2018-09-25 Richard Biener <rguent...@suse.de> PR debug/87428 PR debug/87362 * tree-inline.c (expand_call_inline): When the location of the call is UNKNOWN_LOCATION use BUILTINS_LOCATION for the BLOCK_SOURCE_LOCATION of the inserted BLOCK to make inlined_function_outer_scope_p recognize it. Index: gcc/tree-inline.c =================================================================== --- gcc/tree-inline.c (revision 264564) +++ gcc/tree-inline.c (working copy) @@ -4527,10 +4527,12 @@ expand_call_inline (basic_block bb, gimp not refer to them in any way to not break GC for locations. */ if (gimple_block (stmt)) { + location_t loc = LOCATION_LOCUS (gimple_location (stmt)); + if (loc == UNKNOWN_LOCATION) + loc = BUILTINS_LOCATION; id->block = make_node (BLOCK); BLOCK_ABSTRACT_ORIGIN (id->block) = fn; - BLOCK_SOURCE_LOCATION (id->block) - = LOCATION_LOCUS (gimple_location (stmt)); + BLOCK_SOURCE_LOCATION (id->block) = loc; prepend_lexical_block (gimple_block (stmt), id->block); }