Skip to content

Commit 802bec8

Browse files
committed
Revert "Reland: [DWARF] Allow cross-CU references of subprogram definitions"
... as well as: Revert "[DWARF] Defer creating declaration DIEs until we prepare call site info" This reverts commit fa4701e. This reverts commit 79daafc. There have been reports of this assert getting hit: CalleeDIE && "Could not find DIE for call site entry origin
1 parent 0ebc8e6 commit 802bec8

File tree

8 files changed

+24
-295
lines changed

8 files changed

+24
-295
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -990,8 +990,8 @@ DIE &DwarfCompileUnit::constructCallSiteEntryDIE(DIE &ScopeDIE,
990990
addAddress(CallSiteDIE, getDwarf5OrGNUAttr(dwarf::DW_AT_call_target),
991991
MachineLocation(CallReg));
992992
} else {
993-
DIE *CalleeDIE = getDIE(CalleeSP);
994-
assert(CalleeDIE && "Could not find DIE for call site entry origin");
993+
DIE *CalleeDIE = getOrCreateSubprogramDIE(CalleeSP);
994+
assert(CalleeDIE && "Could not create DIE for call site entry origin");
995995
addDIEEntry(CallSiteDIE, getDwarf5OrGNUAttr(dwarf::DW_AT_call_origin),
996996
*CalleeDIE);
997997
}

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

+5-19
Original file line numberDiff line numberDiff line change
@@ -540,14 +540,6 @@ void DwarfDebug::constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU,
540540
}
541541
}
542542

543-
DIE &DwarfDebug::constructSubprogramDefinitionDIE(const DISubprogram *SP) {
544-
DICompileUnit *Unit = SP->getUnit();
545-
assert(SP->isDefinition() && "Subprogram not a definition");
546-
assert(Unit && "Subprogram definition without parent unit");
547-
auto &CU = getOrCreateDwarfCompileUnit(Unit);
548-
return *CU.getOrCreateSubprogramDIE(SP);
549-
}
550-
551543
/// Try to interpret values loaded into registers that forward parameters
552544
/// for \p CallMI. Store parameters with interpreted value into \p Params.
553545
static void collectCallSiteParameters(const MachineInstr *CallMI,
@@ -757,17 +749,6 @@ void DwarfDebug::constructCallSiteEntryDIEs(const DISubprogram &SP,
757749
if (!CalleeDecl || !CalleeDecl->getSubprogram())
758750
continue;
759751
CalleeSP = CalleeDecl->getSubprogram();
760-
761-
if (CalleeSP->isDefinition()) {
762-
// Ensure that a subprogram DIE for the callee is available in the
763-
// appropriate CU.
764-
constructSubprogramDefinitionDIE(CalleeSP);
765-
} else {
766-
// Create the declaration DIE if it is missing. This is required to
767-
// support compilation of old bitcode with an incomplete list of
768-
// retained metadata.
769-
CU.getOrCreateSubprogramDIE(CalleeSP);
770-
}
771752
}
772753

773754
// TODO: Omit call site entries for runtime calls (objc_msgSend, etc).
@@ -915,6 +896,11 @@ DwarfDebug::getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit) {
915896
NewCU.setSection(Asm->getObjFileLowering().getDwarfInfoSection());
916897
}
917898

899+
// Create DIEs for function declarations used for call site debug info.
900+
for (auto Scope : DIUnit->getRetainedTypes())
901+
if (auto *SP = dyn_cast_or_null<DISubprogram>(Scope))
902+
NewCU.getOrCreateSubprogramDIE(SP);
903+
918904
CUMap.insert({DIUnit, &NewCU});
919905
CUDieMap.insert({&NewCU.getUnitDie(), &NewCU});
920906
return NewCU;

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h

-3
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,6 @@ class DwarfDebug : public DebugHandlerBase {
442442
/// Construct a DIE for this abstract scope.
443443
void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope);
444444

445-
/// Construct a DIE for the subprogram definition \p SP and return it.
446-
DIE &constructSubprogramDefinitionDIE(const DISubprogram *SP);
447-
448445
/// Construct DIEs for call site entries describing the calls in \p MF.
449446
void constructCallSiteEntryDIEs(const DISubprogram &SP, DwarfCompileUnit &CU,
450447
DIE &ScopeDIE, const MachineFunction &MF);

llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,18 @@ int64_t DwarfUnit::getDefaultLowerBound() const {
188188

189189
/// Check whether the DIE for this MDNode can be shared across CUs.
190190
bool DwarfUnit::isShareableAcrossCUs(const DINode *D) const {
191-
// When the MDNode can be part of the type system (this includes subprogram
192-
// declarations *and* subprogram definitions, even local definitions), the
193-
// DIE must be shared across CUs.
191+
// When the MDNode can be part of the type system, the DIE can be shared
192+
// across CUs.
194193
// Combining type units and cross-CU DIE sharing is lower value (since
195194
// cross-CU DIE sharing is used in LTO and removes type redundancy at that
196195
// level already) but may be implementable for some value in projects
197196
// building multiple independent libraries with LTO and then linking those
198197
// together.
199198
if (isDwoUnit() && !DD->shareAcrossDWOCUs())
200199
return false;
201-
return (isa<DIType>(D) || isa<DISubprogram>(D)) && !DD->generateTypeUnits();
200+
return (isa<DIType>(D) ||
201+
(isa<DISubprogram>(D) && !cast<DISubprogram>(D)->isDefinition())) &&
202+
!DD->generateTypeUnits();
202203
}
203204

204205
DIE *DwarfUnit::getDIE(const DINode *D) const {

llvm/test/DebugInfo/AArch64/unretained-declaration-subprogram.ll

-44
This file was deleted.

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 ({{.*}} "call_int")
162+
# CHECK-NEXT: DW_AT_abstract_origin (0x0000002a "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 ({{.*}} "call_long")
208+
# CHECK-NEXT: DW_AT_abstract_origin (0x0000003e "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 ({{.*}} "call_int_int")
268+
# CHECK-NEXT: DW_AT_abstract_origin (0x00000052 "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,11 +39,17 @@
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: DW_TAG_call_site
43-
# CHECK-DWARF5: DW_AT_call_origin ([[getValue_SP:.*]])
42+
# CHECK-DWARF5: [[getValue_SP:.*]]: DW_TAG_subprogram
43+
# CHECK-DWARF5-NEXT: DW_AT_name ("getVal")
4444

45+
# CHECK-DWARF5: [[foo_SP:.*]]: DW_TAG_subprogram
46+
# CHECK-DWARF5-NEXT: DW_AT_name ("foo")
47+
48+
# CHECK-DWARF5: DW_TAG_call_site
49+
# CHECK-DWARF5: DW_AT_call_origin ([[getValue_SP]])
50+
#
4551
# CHECK-DWARF5: DW_TAG_call_site
46-
# CHECK-DWARF5: DW_AT_call_origin ([[foo_SP:.*]])
52+
# CHECK-DWARF5: DW_AT_call_origin ([[foo_SP]])
4753
# CHECK-DWARF5: DW_AT_call_return_pc {{.*}}
4854
# CHECK-DWARF5-EMPTY:
4955
# CHECK-DWARF5: DW_TAG_call_site_parameter
@@ -65,12 +71,6 @@
6571
# CHECK-DWARF5-NEXT: DW_AT_location (DW_OP_reg8 R8)
6672
# CHECK-DWARF5-NEXT: DW_AT_call_value (DW_OP_breg14 R14+3)
6773

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"

0 commit comments

Comments
 (0)