Sink most of DwarfDebug::constructAbstractSubprogramScopeDIE into DwarfCompileUnit
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfCompileUnit.cpp
index 6b648df28a11c5a7c74cc3eadb0e2b3e70563ce3..ceb2a12bf7a63a2fcd5f34a43eae33c840ead52d 100644 (file)
@@ -586,8 +586,12 @@ DIE *DwarfCompileUnit::createAndAddScopeChildren(LexicalScope *Scope,
   return ObjectPointer;
 }
 
-DIE &
+void
 DwarfCompileUnit::constructAbstractSubprogramScopeDIE(LexicalScope *Scope) {
+  DIE *&AbsDef = DD->getAbstractSPDies()[Scope->getScopeNode()];
+  if (AbsDef)
+    return;
+
   DISubprogram SP(Scope->getScopeNode());
 
   DIE *ContextDIE;
@@ -604,15 +608,14 @@ DwarfCompileUnit::constructAbstractSubprogramScopeDIE(LexicalScope *Scope) {
 
   // Passing null as the associated DIDescriptor because the abstract definition
   // shouldn't be found by lookup.
-  DIE &AbsDef =
-      createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE, DIDescriptor());
-  applySubprogramAttributesToDefinition(SP, AbsDef);
+  AbsDef =
+      &createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE, DIDescriptor());
+  applySubprogramAttributesToDefinition(SP, *AbsDef);
 
   if (getCUNode().getEmissionKind() != DIBuilder::LineTablesOnly)
-    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);
-  return AbsDef;
+    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);
 }
 
 std::unique_ptr<DIE>