Skip to content

Commit

Permalink
[DWARF] Defer creating declaration DIEs until we prepare call site info
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vedantk committed Dec 20, 2019
1 parent 79daafc commit fa4701e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 31 deletions.
7 changes: 0 additions & 7 deletions llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,13 +924,6 @@ DwarfDebug::getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit) {
NewCU.setSection(Asm->getObjFileLowering().getDwarfInfoSection());
}

// Create DIEs for function declarations used for call site debug info.
// Note: Declaration subprograms imported by LTO are not added to the unit's
// list of retained types, so their DIEs are not constructed here.
for (auto Scope : DIUnit->getRetainedTypes())
if (auto *SP = dyn_cast_or_null<DISubprogram>(Scope))
NewCU.getOrCreateSubprogramDIE(SP);

CUMap.insert({DIUnit, &NewCU});
CUDieMap.insert({&NewCU.getUnitDie(), &NewCU});
return NewCU;
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ body: |
...

# CHECK: DW_TAG_GNU_call_site
# CHECK-NEXT: DW_AT_abstract_origin (0x0000002a "call_int")
# CHECK-NEXT: DW_AT_abstract_origin ({{.*}} "call_int")
#
# CHECK: DW_TAG_GNU_call_site_parameter
# CHECK-NEXT: DW_AT_location (DW_OP_reg0 W0)
Expand Down Expand Up @@ -205,7 +205,7 @@ body: |
...

# CHECK: DW_TAG_GNU_call_site
# CHECK-NEXT: DW_AT_abstract_origin (0x0000003e "call_long")
# CHECK-NEXT: DW_AT_abstract_origin ({{.*}} "call_long")
#
# CHECK: DW_TAG_GNU_call_site_parameter
# CHECK-NEXT: DW_AT_location (DW_OP_reg0 W0)
Expand Down Expand Up @@ -265,7 +265,7 @@ body: |
...

# CHECK: DW_TAG_GNU_call_site
# CHECK-NEXT: DW_AT_abstract_origin (0x00000052 "call_int_int")
# CHECK-NEXT: DW_AT_abstract_origin ({{.*}} "call_int_int")
#
# CHECK: DW_TAG_GNU_call_site_parameter
# FIXME: The DW_AT_location attribute should actually refer to W0! See PR44118.
Expand Down
18 changes: 9 additions & 9 deletions llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,11 @@
# CHECK-GNU-NEXT: DW_AT_location (DW_OP_reg8 R8)
# CHECK-GNU-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg14 R14+3)

# CHECK-DWARF5: [[getValue_SP:.*]]: DW_TAG_subprogram
# CHECK-DWARF5-NEXT: DW_AT_name ("getVal")

# CHECK-DWARF5: [[foo_SP:.*]]: DW_TAG_subprogram
# CHECK-DWARF5-NEXT: DW_AT_name ("foo")

# CHECK-DWARF5: DW_TAG_call_site
# CHECK-DWARF5: DW_AT_call_origin ([[getValue_SP]])
#
# CHECK-DWARF5: DW_AT_call_origin ([[getValue_SP:.*]])

# CHECK-DWARF5: DW_TAG_call_site
# CHECK-DWARF5: DW_AT_call_origin ([[foo_SP]])
# CHECK-DWARF5: DW_AT_call_origin ([[foo_SP:.*]])
# CHECK-DWARF5: DW_AT_call_return_pc {{.*}}
# CHECK-DWARF5-EMPTY:
# CHECK-DWARF5: DW_TAG_call_site_parameter
Expand All @@ -71,6 +65,12 @@
# CHECK-DWARF5-NEXT: DW_AT_location (DW_OP_reg8 R8)
# CHECK-DWARF5-NEXT: DW_AT_call_value (DW_OP_breg14 R14+3)

# CHECK-DWARF5: [[getValue_SP]]: DW_TAG_subprogram
# CHECK-DWARF5-NEXT: DW_AT_name ("getVal")

# CHECK-DWARF5: [[foo_SP]]: DW_TAG_subprogram
# CHECK-DWARF5-NEXT: DW_AT_name ("foo")

--- |
; ModuleID = 'test.c'
source_filename = "test.c"
Expand Down
12 changes: 0 additions & 12 deletions llvm/test/DebugInfo/X86/lto-cross-cu-call-origin-ref.ll
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@
; CHECK: DW_TAG_compile_unit
; CHECK: DW_AT_name ("a.c")

; CHECK: DW_TAG_subprogram
; CHECK: DW_AT_name ("func_from_b")
; CHECK: DW_AT_declaration (true)

; CHECK: 0x{{0+}}[[NOINLINE_FUNC_IN_A:.*]]: DW_TAG_subprogram
; CHECK: DW_AT_name ("noinline_func_in_a")

Expand Down Expand Up @@ -81,14 +77,6 @@
; CHECK: DW_TAG_compile_unit
; CHECK: DW_AT_name ("b.c")

; CHECK: DW_TAG_subprogram
; CHECK: DW_AT_name ("noinline_func_in_a")
; CHECK: DW_AT_declaration (true)

; CHECK: DW_TAG_subprogram
; CHECK: DW_AT_name ("always_inline_helper_in_a_that_calls_foo")
; CHECK: DW_AT_declaration (true)

; 3) Validate the cross-CU ref from "call_func_in_b_from_a" in a.c.
; CHECK: 0x{{0+}}[[FUNC_FROM_B]]: DW_TAG_subprogram
; CHECK: DW_AT_name ("func_from_b")
Expand Down

0 comments on commit fa4701e

Please sign in to comment.