Skip to content

Commit

Permalink
Revert "Reland: [DWARF] Allow cross-CU references of subprogram defin…
Browse files Browse the repository at this point in the history
…itions"

... 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

(cherry picked from commit 802bec8)
  • Loading branch information
vedantk authored and zmodem committed Jan 29, 2020
1 parent b28b38a commit b516ca0
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 295 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
Expand Up @@ -968,8 +968,8 @@ DIE &DwarfCompileUnit::constructCallSiteEntryDIE(
addAddress(CallSiteDIE, getDwarf5OrGNUAttr(dwarf::DW_AT_call_target),
MachineLocation(CallReg));
} else {
DIE *CalleeDIE = getDIE(CalleeSP);
assert(CalleeDIE && "Could not find DIE for call site entry origin");
DIE *CalleeDIE = getOrCreateSubprogramDIE(CalleeSP);
assert(CalleeDIE && "Could not create DIE for call site entry origin");
addDIEEntry(CallSiteDIE, getDwarf5OrGNUAttr(dwarf::DW_AT_call_origin),
*CalleeDIE);
}
Expand Down
24 changes: 5 additions & 19 deletions llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Expand Up @@ -540,14 +540,6 @@ void DwarfDebug::constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU,
}
}

DIE &DwarfDebug::constructSubprogramDefinitionDIE(const DISubprogram *SP) {
DICompileUnit *Unit = SP->getUnit();
assert(SP->isDefinition() && "Subprogram not a definition");
assert(Unit && "Subprogram definition without parent unit");
auto &CU = getOrCreateDwarfCompileUnit(Unit);
return *CU.getOrCreateSubprogramDIE(SP);
}

/// Try to interpret values loaded into registers that forward parameters
/// for \p CallMI. Store parameters with interpreted value into \p Params.
static void collectCallSiteParameters(const MachineInstr *CallMI,
Expand Down Expand Up @@ -758,17 +750,6 @@ void DwarfDebug::constructCallSiteEntryDIEs(const DISubprogram &SP,
if (!CalleeDecl || !CalleeDecl->getSubprogram())
continue;
CalleeSP = CalleeDecl->getSubprogram();

if (CalleeSP->isDefinition()) {
// Ensure that a subprogram DIE for the callee is available in the
// appropriate CU.
constructSubprogramDefinitionDIE(CalleeSP);
} else {
// Create the declaration DIE if it is missing. This is required to
// support compilation of old bitcode with an incomplete list of
// retained metadata.
CU.getOrCreateSubprogramDIE(CalleeSP);
}
}

// TODO: Omit call site entries for runtime calls (objc_msgSend, etc).
Expand Down Expand Up @@ -924,6 +905,11 @@ DwarfDebug::getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit) {
NewCU.setSection(Asm->getObjFileLowering().getDwarfInfoSection());
}

// Create DIEs for function declarations used for call site debug info.
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
3 changes: 0 additions & 3 deletions llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
Expand Up @@ -442,9 +442,6 @@ class DwarfDebug : public DebugHandlerBase {
/// Construct a DIE for this abstract scope.
void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope);

/// Construct a DIE for the subprogram definition \p SP and return it.
DIE &constructSubprogramDefinitionDIE(const DISubprogram *SP);

/// Construct DIEs for call site entries describing the calls in \p MF.
void constructCallSiteEntryDIEs(const DISubprogram &SP, DwarfCompileUnit &CU,
DIE &ScopeDIE, const MachineFunction &MF);
Expand Down
9 changes: 5 additions & 4 deletions llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
Expand Up @@ -188,17 +188,18 @@ int64_t DwarfUnit::getDefaultLowerBound() const {

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

DIE *DwarfUnit::getDIE(const DINode *D) const {
Expand Down
44 changes: 0 additions & 44 deletions llvm/test/DebugInfo/AArch64/unretained-declaration-subprogram.ll

This file was deleted.

6 changes: 3 additions & 3 deletions llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
Expand Up @@ -159,7 +159,7 @@ body: |
...

# CHECK: DW_TAG_GNU_call_site
# CHECK-NEXT: DW_AT_abstract_origin ({{.*}} "call_int")
# CHECK-NEXT: DW_AT_abstract_origin (0x0000002a "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 ({{.*}} "call_long")
# CHECK-NEXT: DW_AT_abstract_origin (0x0000003e "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 ({{.*}} "call_int_int")
# CHECK-NEXT: DW_AT_abstract_origin (0x00000052 "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
Expand Up @@ -39,11 +39,17 @@
# 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: DW_TAG_call_site
# CHECK-DWARF5: DW_AT_call_origin ([[getValue_SP:.*]])
# 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_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 @@ -65,12 +71,6 @@
# 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

0 comments on commit b516ca0

Please sign in to comment.