summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 51f25ec0fe6..e5d71f3cea8 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -298,10 +298,15 @@ void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute,
Entry);
}
-DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N) {
- DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator, (dwarf::Tag)Tag));
+DIE *DwarfUnit::createDIE(unsigned Tag, const DINode *N) {
+ DIE *Die = DIE::get(DIEValueAllocator, (dwarf::Tag)Tag);
if (N)
- insertDIE(N, &Die);
+ insertDIE(N, Die);
+ return Die;
+}
+
+DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N) {
+ DIE &Die = Parent.addChild(createDIE(Tag, N));
return Die;
}
@@ -725,15 +730,18 @@ DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
// Construct the context before querying for the existence of the DIE in case
// such construction creates the DIE.
+ // For Local Scope, do not construct context DIE.
auto *Context = resolve(Ty->getScope());
- DIE *ContextDIE = getOrCreateContextDIE(Context);
- assert(ContextDIE);
+ bool IsLocalScope = Context && isa<DILocalScope>(Context);
+ DIE *ContextDIE = IsLocalScope ? nullptr : getOrCreateContextDIE(Context);
+ assert(ContextDIE || IsLocalScope);
if (DIE *TyDIE = getDIE(Ty))
return TyDIE;
- // Create new type.
- DIE &TyDIE = createAndAddDIE(Ty->getTag(), *ContextDIE, Ty);
+ // Create new type and add to map.
+ DIE &TyDIE = IsLocalScope ? *createDIE(Ty->getTag(), Ty)
+ : createAndAddDIE(Ty->getTag(), *ContextDIE, Ty);
updateAcceleratorTables(Context, Ty, TyDIE);
OpenPOWER on IntegriCloud