aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2013-10-15 23:31:38 +0000
committerEric Christopher <echristo@gmail.com>2013-10-15 23:31:38 +0000
commitc622824ccbb74ac726c656ebc98647810d152cce (patch)
treeac026ea27e1071baff3976cd0ab170b45b55bcdf /lib/CodeGen/AsmPrinter/DwarfDebug.cpp
parent4159733c1a9a6f4aea6ea4d558ca4806a3f959d2 (diff)
downloadexternal_llvm-c622824ccbb74ac726c656ebc98647810d152cce.zip
external_llvm-c622824ccbb74ac726c656ebc98647810d152cce.tar.gz
external_llvm-c622824ccbb74ac726c656ebc98647810d152cce.tar.bz2
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
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index a9bd0b4..cee97c8 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -826,12 +826,8 @@ CompileUnit *DwarfDebug::constructCompileUnit(const MDNode *N) {
}
// Construct subprogram DIE.
-void DwarfDebug::constructSubprogramDIE(CompileUnit *TheCU,
- const MDNode *N) {
- CompileUnit *&CURef = SPMap[N];
- if (CURef)
- return;
- CURef = TheCU;
+void DwarfDebug::constructSubprogramDIE(CompileUnit *TheCU, const MDNode *N) {
+ assert(!SPMap[N] && "Trying to create a subprogram DIE twice!");
DISubprogram SP(N);
if (!SP.isDefinition())
@@ -840,6 +836,7 @@ void DwarfDebug::constructSubprogramDIE(CompileUnit *TheCU,
return;
DIE *SubprogramDie = TheCU->getOrCreateSubprogramDIE(SP);
+ SPMap[N] = TheCU;
// Expose as a global name.
TheCU->addGlobalName(SP.getName(), SubprogramDie);
@@ -974,28 +971,33 @@ void DwarfDebug::collectDeadVariables() {
DIArray Subprograms = TheCU.getSubprograms();
for (unsigned i = 0, e = Subprograms.getNumElements(); i != e; ++i) {
DISubprogram SP(Subprograms.getElement(i));
- if (ProcessedSPNodes.count(SP) != 0) continue;
- if (!SP.isSubprogram()) continue;
- if (!SP.isDefinition()) continue;
+ if (ProcessedSPNodes.count(SP) != 0)
+ continue;
+ if (!SP.isSubprogram())
+ continue;
+ if (!SP.isDefinition())
+ continue;
DIArray Variables = SP.getVariables();
- if (Variables.getNumElements() == 0) continue;
+ if (Variables.getNumElements() == 0)
+ continue;
LexicalScope *Scope =
- new LexicalScope(NULL, DIDescriptor(SP), NULL, false);
+ new LexicalScope(NULL, DIDescriptor(SP), NULL, false);
DeadFnScopeMap[SP] = Scope;
// Construct subprogram DIE and add variables DIEs.
CompileUnit *SPCU = CUMap.lookup(TheCU);
assert(SPCU && "Unable to find Compile Unit!");
- constructSubprogramDIE(SPCU, SP);
- DIE *ScopeDIE = SPCU->getDIE(SP);
+ DIE *SPDIE = SPCU->getDIE(SP);
+ assert(SPDIE && "Subprogram wasn't created?");
for (unsigned vi = 0, ve = Variables.getNumElements(); vi != ve; ++vi) {
DIVariable DV(Variables.getElement(vi));
- if (!DV.isVariable()) continue;
+ if (!DV.isVariable())
+ continue;
DbgVariable NewVar(DV, NULL, this);
if (DIE *VariableDIE =
- SPCU->constructVariableDIE(&NewVar, Scope->isAbstractScope()))
- ScopeDIE->addChild(VariableDIE);
+ SPCU->constructVariableDIE(&NewVar, Scope->isAbstractScope()))
+ SPDIE->addChild(VariableDIE);
}
}
}