-
-
Save philipc/7e1e05de75cdeaab39b0f8d506299bbe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | |
index d904372..eea30a7 100644 | |
--- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | |
+++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | |
@@ -616,6 +616,7 @@ void DwarfCompileUnit::constructAbstractSubprogramScopeDIE( | |
auto *SP = cast<DISubprogram>(Scope->getScopeNode()); | |
DIE *ContextDIE; | |
+ DwarfCompileUnit *ContextCU = this; | |
if (includeMinimalInlineScopes()) | |
ContextDIE = &getUnitDie(); | |
@@ -626,18 +627,23 @@ void DwarfCompileUnit::constructAbstractSubprogramScopeDIE( | |
else if (auto *SPDecl = SP->getDeclaration()) { | |
ContextDIE = &getUnitDie(); | |
getOrCreateSubprogramDIE(SPDecl); | |
- } else | |
+ } else { | |
ContextDIE = getOrCreateContextDIE(resolve(SP->getScope())); | |
+ // The scope may be shared with a subprogram that has already been | |
+ // constructed in another CU, in which case we need to construct this | |
+ // subprogram in the same CU. | |
+ ContextCU = DD->lookupCU(ContextDIE->getUnitDie()); | |
+ } | |
// Passing null as the associated node because the abstract definition | |
// shouldn't be found by lookup. | |
- AbsDef = &createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE, nullptr); | |
- applySubprogramAttributesToDefinition(SP, *AbsDef); | |
+ AbsDef = &ContextCU->createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE, nullptr); | |
+ ContextCU->applySubprogramAttributesToDefinition(SP, *AbsDef); | |
- if (!includeMinimalInlineScopes()) | |
- addUInt(*AbsDef, dwarf::DW_AT_inline, None, dwarf::DW_INL_inlined); | |
- if (DIE *ObjectPointer = createAndAddScopeChildren(Scope, *AbsDef)) | |
- addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer, *ObjectPointer); | |
+ if (!ContextCU->includeMinimalInlineScopes()) | |
+ ContextCU->addUInt(*AbsDef, dwarf::DW_AT_inline, None, dwarf::DW_INL_inlined); | |
+ if (DIE *ObjectPointer = ContextCU->createAndAddScopeChildren(Scope, *AbsDef)) | |
+ ContextCU->addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer, *ObjectPointer); | |
} | |
DIE *DwarfCompileUnit::constructImportedEntityDIE( | |
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h | |
index 1e6a25e..45992a3 100644 | |
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.h | |
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h | |
@@ -539,6 +539,8 @@ public: | |
/// A helper function to check whether the DIE for a given Scope is | |
/// going to be null. | |
bool isLexicalScopeDIENull(LexicalScope *Scope); | |
+ | |
+ DwarfCompileUnit *lookupCU(const DIE *Die) { return CUDieMap.lookup(Die); } | |
}; | |
} // End of namespace llvm | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment