mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 17:29:19 +00:00
Make sure we're not attempting to construct a subprogram DIE
twice and just look up the value. Fix the one case where we were trying to create a subprogram DIE and we should already have had one. Reflow formatting in collectDeadVariables while fixing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192749 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4159733c1a
commit
c622824ccb
@ -826,12 +826,8 @@ CompileUnit *DwarfDebug::constructCompileUnit(const MDNode *N) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Construct subprogram DIE.
|
// Construct subprogram DIE.
|
||||||
void DwarfDebug::constructSubprogramDIE(CompileUnit *TheCU,
|
void DwarfDebug::constructSubprogramDIE(CompileUnit *TheCU, const MDNode *N) {
|
||||||
const MDNode *N) {
|
assert(!SPMap[N] && "Trying to create a subprogram DIE twice!");
|
||||||
CompileUnit *&CURef = SPMap[N];
|
|
||||||
if (CURef)
|
|
||||||
return;
|
|
||||||
CURef = TheCU;
|
|
||||||
|
|
||||||
DISubprogram SP(N);
|
DISubprogram SP(N);
|
||||||
if (!SP.isDefinition())
|
if (!SP.isDefinition())
|
||||||
@ -840,6 +836,7 @@ void DwarfDebug::constructSubprogramDIE(CompileUnit *TheCU,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
DIE *SubprogramDie = TheCU->getOrCreateSubprogramDIE(SP);
|
DIE *SubprogramDie = TheCU->getOrCreateSubprogramDIE(SP);
|
||||||
|
SPMap[N] = TheCU;
|
||||||
|
|
||||||
// Expose as a global name.
|
// Expose as a global name.
|
||||||
TheCU->addGlobalName(SP.getName(), SubprogramDie);
|
TheCU->addGlobalName(SP.getName(), SubprogramDie);
|
||||||
@ -974,28 +971,33 @@ void DwarfDebug::collectDeadVariables() {
|
|||||||
DIArray Subprograms = TheCU.getSubprograms();
|
DIArray Subprograms = TheCU.getSubprograms();
|
||||||
for (unsigned i = 0, e = Subprograms.getNumElements(); i != e; ++i) {
|
for (unsigned i = 0, e = Subprograms.getNumElements(); i != e; ++i) {
|
||||||
DISubprogram SP(Subprograms.getElement(i));
|
DISubprogram SP(Subprograms.getElement(i));
|
||||||
if (ProcessedSPNodes.count(SP) != 0) continue;
|
if (ProcessedSPNodes.count(SP) != 0)
|
||||||
if (!SP.isSubprogram()) continue;
|
continue;
|
||||||
if (!SP.isDefinition()) continue;
|
if (!SP.isSubprogram())
|
||||||
|
continue;
|
||||||
|
if (!SP.isDefinition())
|
||||||
|
continue;
|
||||||
DIArray Variables = SP.getVariables();
|
DIArray Variables = SP.getVariables();
|
||||||
if (Variables.getNumElements() == 0) continue;
|
if (Variables.getNumElements() == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
LexicalScope *Scope =
|
LexicalScope *Scope =
|
||||||
new LexicalScope(NULL, DIDescriptor(SP), NULL, false);
|
new LexicalScope(NULL, DIDescriptor(SP), NULL, false);
|
||||||
DeadFnScopeMap[SP] = Scope;
|
DeadFnScopeMap[SP] = Scope;
|
||||||
|
|
||||||
// Construct subprogram DIE and add variables DIEs.
|
// Construct subprogram DIE and add variables DIEs.
|
||||||
CompileUnit *SPCU = CUMap.lookup(TheCU);
|
CompileUnit *SPCU = CUMap.lookup(TheCU);
|
||||||
assert(SPCU && "Unable to find Compile Unit!");
|
assert(SPCU && "Unable to find Compile Unit!");
|
||||||
constructSubprogramDIE(SPCU, SP);
|
DIE *SPDIE = SPCU->getDIE(SP);
|
||||||
DIE *ScopeDIE = SPCU->getDIE(SP);
|
assert(SPDIE && "Subprogram wasn't created?");
|
||||||
for (unsigned vi = 0, ve = Variables.getNumElements(); vi != ve; ++vi) {
|
for (unsigned vi = 0, ve = Variables.getNumElements(); vi != ve; ++vi) {
|
||||||
DIVariable DV(Variables.getElement(vi));
|
DIVariable DV(Variables.getElement(vi));
|
||||||
if (!DV.isVariable()) continue;
|
if (!DV.isVariable())
|
||||||
|
continue;
|
||||||
DbgVariable NewVar(DV, NULL, this);
|
DbgVariable NewVar(DV, NULL, this);
|
||||||
if (DIE *VariableDIE =
|
if (DIE *VariableDIE =
|
||||||
SPCU->constructVariableDIE(&NewVar, Scope->isAbstractScope()))
|
SPCU->constructVariableDIE(&NewVar, Scope->isAbstractScope()))
|
||||||
ScopeDIE->addChild(VariableDIE);
|
SPDIE->addChild(VariableDIE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user