Sink some of DwarfDebug::collectDeadVariables down into DwarfCompileUnit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221010 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2014-10-31 22:30:30 +00:00
parent cf19403e39
commit 54a86b37dd
4 changed files with 25 additions and 20 deletions

View File

@ -663,5 +663,26 @@ void DwarfCompileUnit::finishSubprogramDefinition(DISubprogram SP) {
applySubprogramAttributesToDefinition(SP, *D);
}
}
void DwarfCompileUnit::collectDeadVariables(DISubprogram SP) {
assert(SP.isSubprogram() && "CU's subprogram list contains a non-subprogram");
assert(SP.isDefinition() &&
"CU's subprogram list contains a subprogram declaration");
DIArray Variables = SP.getVariables();
if (Variables.getNumElements() == 0)
return;
DIE *SPDIE = DD->getAbstractSPDies().lookup(SP);
if (!SPDIE)
SPDIE = getDIE(SP);
assert(SPDIE);
for (unsigned vi = 0, ve = Variables.getNumElements(); vi != ve; ++vi) {
DIVariable DV(Variables.getElement(vi));
assert(DV.isVariable());
DbgVariable NewVar(DV, DIExpression(nullptr), DD);
auto VariableDie = constructVariableDIE(NewVar);
applyVariableAttributes(NewVar, *VariableDie);
SPDIE->addChild(std::move(VariableDie));
}
}
} // end llvm namespace

View File

@ -128,6 +128,8 @@ public:
constructImportedEntityDIE(const DIImportedEntity &Module);
void finishSubprogramDefinition(DISubprogram SP);
void collectDeadVariables(DISubprogram SP);
};
} // end llvm namespace

View File

@ -525,26 +525,7 @@ void DwarfDebug::collectDeadVariables() {
DISubprogram SP(Subprograms.getElement(i));
if (ProcessedSPNodes.count(SP) != 0)
continue;
assert(SP.isSubprogram() &&
"CU's subprogram list contains a non-subprogram");
assert(SP.isDefinition() &&
"CU's subprogram list contains a subprogram declaration");
DIArray Variables = SP.getVariables();
if (Variables.getNumElements() == 0)
continue;
DIE *SPDIE = AbstractSPDies.lookup(SP);
if (!SPDIE)
SPDIE = SPCU->getDIE(SP);
assert(SPDIE);
for (unsigned vi = 0, ve = Variables.getNumElements(); vi != ve; ++vi) {
DIVariable DV(Variables.getElement(vi));
assert(DV.isVariable());
DbgVariable NewVar(DV, DIExpression(nullptr), this);
auto VariableDie = SPCU->constructVariableDIE(NewVar);
SPCU->applyVariableAttributes(NewVar, *VariableDie);
SPDIE->addChild(std::move(VariableDie));
}
SPCU->collectDeadVariables(SP);
}
}
}

View File

@ -29,6 +29,7 @@ class DwarfUnit;
class DIEAbbrev;
class MCSymbol;
class DIE;
class DISubprogram;
class LexicalScope;
class StringRef;
class DwarfDebug;