aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernd Edlinger <bernd.edlinger@hotmail.de>2024-08-16 12:26:27 +0200
committerBernd Edlinger <bernd.edlinger@hotmail.de>2024-08-22 12:35:36 +0200
commitbcb33b1237042e9540a905d9de19219f876e26c0 (patch)
tree122f269922965af0435504d6684dd7e60a944561
parent9bbad3685131ec95d970f81bf75f9556d4d92742 (diff)
downloadgcc-bcb33b1237042e9540a905d9de19219f876e26c0.zip
gcc-bcb33b1237042e9540a905d9de19219f876e26c0.tar.gz
gcc-bcb33b1237042e9540a905d9de19219f876e26c0.tar.bz2
Do not emit a redundant DW_TAG_lexical_block for inlined subroutines
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. 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. gcc/testsuite/ChangeLog: * gcc.dg/debug/dwarf2/inline7.c: New test.
-rw-r--r--gcc/dwarf2out.cc15
-rw-r--r--gcc/testsuite/gcc.dg/debug/dwarf2/inline7.c20
2 files changed, 32 insertions, 3 deletions
diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index d514471..75ce91e 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -25194,17 +25194,26 @@ 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)
unwrap_one = true;
+ for (tree next = BLOCK_CHAIN (sub); unwrap_one && next;
+ next = BLOCK_CHAIN (next))
+ if (BLOCK_FRAGMENT_ORIGIN (next) != sub)
+ unwrap_one = false;
}
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
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline7.c b/gcc/testsuite/gcc.dg/debug/dwarf2/inline7.c
new file mode 100644
index 0000000..48d4572
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/inline7.c
@@ -0,0 +1,20 @@
+/* Verify that both inline instances have a DW_AT_ranges but
+ no extra DW_TAG_lexical_block. */
+/* { dg-options "-O -gdwarf -dA" } */
+/* { dg-do compile } */
+/* { dg-final { scan-assembler-times "\\(DIE \\(\[^\n\]*\\) DW_TAG_inlined_subroutine" 2 } } */
+/* { dg-final { scan-assembler-times " DW_AT_ranges" 2 } } */
+/* { dg-final { scan-assembler-times "\\(DIE \\(\[^\n\]*\\) DW_TAG_lexical_block" 0 } } */
+
+static int foo (int i)
+{
+ volatile int j = i + 3;
+ if (j == 3)
+ return 0;
+ return j - 2;
+}
+int main()
+{
+ volatile int z = foo (-2) && foo (-1);
+ return z;
+}