[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.
This commit is contained in:
Vedant Kumar 2019-12-20 15:12:18 -08:00
parent 79daafc903
commit fa4701e197
4 changed files with 12 additions and 31 deletions

View File

@ -924,13 +924,6 @@ DwarfDebug::getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit) {
NewCU.setSection(Asm->getObjFileLowering().getDwarfInfoSection()); 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}); CUMap.insert({DIUnit, &NewCU});
CUDieMap.insert({&NewCU.getUnitDie(), &NewCU}); CUDieMap.insert({&NewCU.getUnitDie(), &NewCU});
return NewCU; return NewCU;

View File

@ -159,7 +159,7 @@ body: |
... ...
# CHECK: DW_TAG_GNU_call_site # 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: DW_TAG_GNU_call_site_parameter
# CHECK-NEXT: DW_AT_location (DW_OP_reg0 W0) # CHECK-NEXT: DW_AT_location (DW_OP_reg0 W0)
@ -205,7 +205,7 @@ body: |
... ...
# CHECK: DW_TAG_GNU_call_site # 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: DW_TAG_GNU_call_site_parameter
# CHECK-NEXT: DW_AT_location (DW_OP_reg0 W0) # CHECK-NEXT: DW_AT_location (DW_OP_reg0 W0)
@ -265,7 +265,7 @@ body: |
... ...
# CHECK: DW_TAG_GNU_call_site # 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 # CHECK: DW_TAG_GNU_call_site_parameter
# FIXME: The DW_AT_location attribute should actually refer to W0! See PR44118. # FIXME: The DW_AT_location attribute should actually refer to W0! See PR44118.

View File

@ -39,17 +39,11 @@
# CHECK-GNU-NEXT: DW_AT_location (DW_OP_reg8 R8) # 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-GNU-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg14 R14+3)
# CHECK-DWARF5: [[getValue_SP:.*]]: DW_TAG_subprogram # CHECK-DWARF5: DW_TAG_call_site
# CHECK-DWARF5-NEXT: DW_AT_name ("getVal") # CHECK-DWARF5: DW_AT_call_origin ([[getValue_SP:.*]])
# CHECK-DWARF5: [[foo_SP:.*]]: DW_TAG_subprogram
# CHECK-DWARF5-NEXT: DW_AT_name ("foo")
# CHECK-DWARF5: DW_TAG_call_site # CHECK-DWARF5: DW_TAG_call_site
# CHECK-DWARF5: DW_AT_call_origin ([[getValue_SP]]) # CHECK-DWARF5: DW_AT_call_origin ([[foo_SP:.*]])
#
# CHECK-DWARF5: DW_TAG_call_site
# CHECK-DWARF5: DW_AT_call_origin ([[foo_SP]])
# CHECK-DWARF5: DW_AT_call_return_pc {{.*}} # CHECK-DWARF5: DW_AT_call_return_pc {{.*}}
# CHECK-DWARF5-EMPTY: # CHECK-DWARF5-EMPTY:
# CHECK-DWARF5: DW_TAG_call_site_parameter # CHECK-DWARF5: DW_TAG_call_site_parameter
@ -71,6 +65,12 @@
# CHECK-DWARF5-NEXT: DW_AT_location (DW_OP_reg8 R8) # CHECK-DWARF5-NEXT: DW_AT_location (DW_OP_reg8 R8)
# CHECK-DWARF5-NEXT: DW_AT_call_value (DW_OP_breg14 R14+3) # 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' ; ModuleID = 'test.c'
source_filename = "test.c" source_filename = "test.c"

View File

@ -49,10 +49,6 @@
; CHECK: DW_TAG_compile_unit ; CHECK: DW_TAG_compile_unit
; CHECK: DW_AT_name ("a.c") ; 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: 0x{{0+}}[[NOINLINE_FUNC_IN_A:.*]]: DW_TAG_subprogram
; CHECK: DW_AT_name ("noinline_func_in_a") ; CHECK: DW_AT_name ("noinline_func_in_a")
@ -81,14 +77,6 @@
; CHECK: DW_TAG_compile_unit ; CHECK: DW_TAG_compile_unit
; CHECK: DW_AT_name ("b.c") ; 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. ; 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: 0x{{0+}}[[FUNC_FROM_B]]: DW_TAG_subprogram
; CHECK: DW_AT_name ("func_from_b") ; CHECK: DW_AT_name ("func_from_b")