Add the subprogram DIEs to the context they're created with only
if they're a declaration, otherwise they're owned by the compile
unit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192861 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index b6ea6a4..fb9e599 100644
--- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -1321,9 +1321,6 @@
DeclDie = getOrCreateSubprogramDIE(SPDecl);
}
- // Add to context owner.
- ContextDIE->addChild(SPDie);
-
// Add function template parameters.
addTemplateParams(*SPDie, SP.getTemplateParams());
@@ -1333,9 +1330,15 @@
// Refer function declaration directly.
addDIEEntry(SPDie, dwarf::DW_AT_specification, DeclDie);
+ // Add subprogram definitions to the CU die directly.
+ CUDie.get()->addChild(SPDie);
+
return SPDie;
}
+ // Add to context owner.
+ ContextDIE->addChild(SPDie);
+
// Add the linkage name if we have one.
StringRef LinkageName = SP.getLinkageName();
if (!LinkageName.empty())