DebugInfo: Improve type safety and simplify some subprogram finalization code

This probably ended up this way aften the subprogram<>function link
inversion and debug info metadata schema changes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289697 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2016-12-14 19:38:39 +00:00
parent fb953956ab
commit 6cd8528a2d
2 changed files with 9 additions and 11 deletions

View File

@ -364,13 +364,13 @@ void DwarfDebug::constructAbstractSubprogramScopeDIE(LexicalScope *Scope) {
assert(Scope->isAbstractScope());
assert(!Scope->getInlinedAt());
const MDNode *SP = Scope->getScopeNode();
auto *SP = cast<DISubprogram>(Scope->getScopeNode());
ProcessedSPNodes.insert(SP);
// Find the subprogram's DwarfCompileUnit in the SPMap in case the subprogram
// was inlined from another compile unit.
auto &CU = *CUMap.lookup(cast<DISubprogram>(SP)->getUnit());
auto &CU = *CUMap.lookup(SP->getUnit());
forBothCUs(CU, [&](DwarfCompileUnit &CU) {
CU.constructAbstractSubprogramScopeDIE(Scope);
});
@ -535,13 +535,11 @@ void DwarfDebug::finishVariableDefinitions() {
}
void DwarfDebug::finishSubprogramDefinitions() {
for (auto &F : MMI->getModule()->functions())
if (auto *SP = F.getSubprogram())
if (ProcessedSPNodes.count(SP) &&
SP->getUnit()->getEmissionKind() != DICompileUnit::NoDebug)
forBothCUs(*CUMap.lookup(SP->getUnit()), [&](DwarfCompileUnit &CU) {
CU.finishSubprogramDefinition(SP);
});
for (const DISubprogram *SP : ProcessedSPNodes)
if (SP->getUnit()->getEmissionKind() != DICompileUnit::NoDebug)
forBothCUs(*CUMap.lookup(SP->getUnit()), [&](DwarfCompileUnit &CU) {
CU.finishSubprogramDefinition(SP);
});
}
void DwarfDebug::finalizeModuleInfo() {

View File

@ -216,7 +216,7 @@ class DwarfDebug : public DebugHandlerBase {
/// This is a collection of subprogram MDNodes that are processed to
/// create DIEs.
SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
SmallPtrSet<const DISubprogram *, 16> ProcessedSPNodes;
/// If nonnull, stores the current machine function we're processing.
const MachineFunction *CurFn;
@ -553,7 +553,7 @@ public:
// FIXME: Sink these functions down into DwarfFile/Dwarf*Unit.
SmallPtrSet<const MDNode *, 16> &getProcessedSPNodes() {
SmallPtrSet<const DISubprogram *, 16> &getProcessedSPNodes() {
return ProcessedSPNodes;
}
};