summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 2e5205205d..755f27867e 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -827,7 +827,14 @@ CompileUnit *DwarfDebug::constructCompileUnit(const MDNode *N) {
// Construct subprogram DIE.
void DwarfDebug::constructSubprogramDIE(CompileUnit *TheCU, const MDNode *N) {
- assert(!SPMap[N] && "Trying to create a subprogram DIE twice!");
+ // FIXME: We should only call this routine once, however, during LTO if a
+ // program is defined in multiple CUs we could end up calling it out of
+ // beginModule as we walk the CUs.
+
+ CompileUnit *&CURef = SPMap[N];
+ if (CURef)
+ return;
+ CURef = TheCU;
DISubprogram SP(N);
if (!SP.isDefinition())
@@ -836,7 +843,6 @@ void DwarfDebug::constructSubprogramDIE(CompileUnit *TheCU, const MDNode *N) {
return;
DIE *SubprogramDie = TheCU->getOrCreateSubprogramDIE(SP);
- SPMap[N] = TheCU;
// Expose as a global name.
TheCU->addGlobalName(SP.getName(), SubprogramDie, resolve(SP.getContext()));