On Fri, Aug 16, 2024 at 12:49 PM Bernd Edlinger <bernd.edlin...@hotmail.de> wrote: > > While this already works correctly for the case when an inlined > subroutine contains only one subrange, a redundant DW_TAG_lexical_block > is still emitted when the subroutine has multiple blocks.
Huh. The point is that the inline context is a single scope block with no siblings - how did that get messed up? The patch unfortunately does not contain a testcase. Richard. > Fixes: ac02e5b75451 ("re PR debug/37801 (DWARF output for inlined functions > doesn't always use DW_TAG_inlined_subroutine)") > > gcc/ChangeLog: > > PR debug/87440 > * dwarf2out.cc (gen_inlined_subroutine_die): Handle the case > of multiple subranges correctly. > --- > some more context is here: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87440#c5 > Bootstrapped and regression-tested on x86_64-pc-linux-gnu, OK for trunk? > > gcc/dwarf2out.cc | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc > index 357efaa5990..346feeb53c8 100644 > --- a/gcc/dwarf2out.cc > +++ b/gcc/dwarf2out.cc > @@ -25171,9 +25171,10 @@ gen_inlined_subroutine_die (tree stmt, dw_die_ref > context_die) > Do that by doing the recursion to subblocks on the single subblock > of STMT. */ > bool unwrap_one = false; > - if (BLOCK_SUBBLOCKS (stmt) && !BLOCK_CHAIN (BLOCK_SUBBLOCKS (stmt))) > + tree sub = BLOCK_SUBBLOCKS (stmt); > + if (sub) > { > - tree origin = block_ultimate_origin (BLOCK_SUBBLOCKS (stmt)); > + tree origin = block_ultimate_origin (sub); > if (origin > && TREE_CODE (origin) == BLOCK > && BLOCK_SUPERCONTEXT (origin) == decl) > @@ -25181,7 +25182,11 @@ gen_inlined_subroutine_die (tree stmt, dw_die_ref > context_die) > } > decls_for_scope (stmt, subr_die, !unwrap_one); > if (unwrap_one) > - decls_for_scope (BLOCK_SUBBLOCKS (stmt), subr_die); > + { > + decls_for_scope (sub, subr_die); > + for (sub = BLOCK_CHAIN (sub); sub; sub = BLOCK_CHAIN (sub)) > + gen_block_die (sub, subr_die); > + } > } > > /* Generate a DIE for a field in a record, or structure. CTX is required: > see > -- > 2.39.2 >