Skip to content

Commit fa4701e

Browse files
committed
[DWARF] Defer creating declaration DIEs until we prepare call site info
It isn't necessary to create DIEs for all of the declaration subprograms in a CU's retainedTypes list. We can defer creating these subprograms until we need to prepare a call site tag that refers to one. This cleanup was mentioned in passing in D70350.
1 parent 79daafc commit fa4701e

File tree

4 files changed

+12
-31
lines changed

4 files changed

+12
-31
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -924,13 +924,6 @@ DwarfDebug::getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit) {
924924
NewCU.setSection(Asm->getObjFileLowering().getDwarfInfoSection());
925925
}
926926

927-
// Create DIEs for function declarations used for call site debug info.
928-
// Note: Declaration subprograms imported by LTO are not added to the unit's
929-
// list of retained types, so their DIEs are not constructed here.
930-
for (auto Scope : DIUnit->getRetainedTypes())
931-
if (auto *SP = dyn_cast_or_null<DISubprogram>(Scope))
932-
NewCU.getOrCreateSubprogramDIE(SP);
933-
934927
CUMap.insert({DIUnit, &NewCU});
935928
CUDieMap.insert({&NewCU.getUnitDie(), &NewCU});
936929
return NewCU;

llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir

+3-3
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ body: |
159159
...
160160

161161
# CHECK: DW_TAG_GNU_call_site
162-
# CHECK-NEXT: DW_AT_abstract_origin (0x0000002a "call_int")
162+
# CHECK-NEXT: DW_AT_abstract_origin ({{.*}} "call_int")
163163
#
164164
# CHECK: DW_TAG_GNU_call_site_parameter
165165
# CHECK-NEXT: DW_AT_location (DW_OP_reg0 W0)
@@ -205,7 +205,7 @@ body: |
205205
...
206206

207207
# CHECK: DW_TAG_GNU_call_site
208-
# CHECK-NEXT: DW_AT_abstract_origin (0x0000003e "call_long")
208+
# CHECK-NEXT: DW_AT_abstract_origin ({{.*}} "call_long")
209209
#
210210
# CHECK: DW_TAG_GNU_call_site_parameter
211211
# CHECK-NEXT: DW_AT_location (DW_OP_reg0 W0)
@@ -265,7 +265,7 @@ body: |
265265
...
266266

267267
# CHECK: DW_TAG_GNU_call_site
268-
# CHECK-NEXT: DW_AT_abstract_origin (0x00000052 "call_int_int")
268+
# CHECK-NEXT: DW_AT_abstract_origin ({{.*}} "call_int_int")
269269
#
270270
# CHECK: DW_TAG_GNU_call_site_parameter
271271
# FIXME: The DW_AT_location attribute should actually refer to W0! See PR44118.

llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir

+9-9
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,11 @@
3939
# CHECK-GNU-NEXT: DW_AT_location (DW_OP_reg8 R8)
4040
# CHECK-GNU-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg14 R14+3)
4141

42-
# CHECK-DWARF5: [[getValue_SP:.*]]: DW_TAG_subprogram
43-
# CHECK-DWARF5-NEXT: DW_AT_name ("getVal")
44-
45-
# CHECK-DWARF5: [[foo_SP:.*]]: DW_TAG_subprogram
46-
# CHECK-DWARF5-NEXT: DW_AT_name ("foo")
47-
4842
# CHECK-DWARF5: DW_TAG_call_site
49-
# CHECK-DWARF5: DW_AT_call_origin ([[getValue_SP]])
50-
#
43+
# CHECK-DWARF5: DW_AT_call_origin ([[getValue_SP:.*]])
44+
5145
# CHECK-DWARF5: DW_TAG_call_site
52-
# CHECK-DWARF5: DW_AT_call_origin ([[foo_SP]])
46+
# CHECK-DWARF5: DW_AT_call_origin ([[foo_SP:.*]])
5347
# CHECK-DWARF5: DW_AT_call_return_pc {{.*}}
5448
# CHECK-DWARF5-EMPTY:
5549
# CHECK-DWARF5: DW_TAG_call_site_parameter
@@ -71,6 +65,12 @@
7165
# CHECK-DWARF5-NEXT: DW_AT_location (DW_OP_reg8 R8)
7266
# CHECK-DWARF5-NEXT: DW_AT_call_value (DW_OP_breg14 R14+3)
7367

68+
# CHECK-DWARF5: [[getValue_SP]]: DW_TAG_subprogram
69+
# CHECK-DWARF5-NEXT: DW_AT_name ("getVal")
70+
71+
# CHECK-DWARF5: [[foo_SP]]: DW_TAG_subprogram
72+
# CHECK-DWARF5-NEXT: DW_AT_name ("foo")
73+
7474
--- |
7575
; ModuleID = 'test.c'
7676
source_filename = "test.c"

llvm/test/DebugInfo/X86/lto-cross-cu-call-origin-ref.ll

-12
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@
4949
; CHECK: DW_TAG_compile_unit
5050
; CHECK: DW_AT_name ("a.c")
5151

52-
; CHECK: DW_TAG_subprogram
53-
; CHECK: DW_AT_name ("func_from_b")
54-
; CHECK: DW_AT_declaration (true)
55-
5652
; CHECK: 0x{{0+}}[[NOINLINE_FUNC_IN_A:.*]]: DW_TAG_subprogram
5753
; CHECK: DW_AT_name ("noinline_func_in_a")
5854

@@ -81,14 +77,6 @@
8177
; CHECK: DW_TAG_compile_unit
8278
; CHECK: DW_AT_name ("b.c")
8379

84-
; CHECK: DW_TAG_subprogram
85-
; CHECK: DW_AT_name ("noinline_func_in_a")
86-
; CHECK: DW_AT_declaration (true)
87-
88-
; CHECK: DW_TAG_subprogram
89-
; CHECK: DW_AT_name ("always_inline_helper_in_a_that_calls_foo")
90-
; CHECK: DW_AT_declaration (true)
91-
9280
; 3) Validate the cross-CU ref from "call_func_in_b_from_a" in a.c.
9381
; CHECK: 0x{{0+}}[[FUNC_FROM_B]]: DW_TAG_subprogram
9482
; CHECK: DW_AT_name ("func_from_b")

0 commit comments

Comments
 (0)