From bbdd02cc303d0f38f7739b64f419d645ca17b533 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Tue, 29 Oct 2013 00:58:04 +0000 Subject: Debug Info: use createAndAddDIE for newly-created Subprogram DIEs. More patches will be submitted to convert "new DIE(" to use createAddAndDIE in DwarfCompileUnit.cpp. This will simplify implementation of addDIEEntry where we have to decide between ref4 and ref_addr, because DIEs that can be shared across CU will be added to a CU already. Reviewed off-list by Eric. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193567 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp') diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index f58bddf99c..8528ab7edf 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -1356,12 +1356,14 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) { if (SPDie) return SPDie; - SPDie = new DIE(dwarf::DW_TAG_subprogram); + DISubprogram SPDecl = SP.getFunctionDeclaration(); + if (SPDecl.isSubprogram()) + // Add subprogram definitions to the CU die directly. + ContextDIE = CUDie.get(); // DW_TAG_inlined_subroutine may refer to this DIE. - insertDIE(SP, SPDie); + SPDie = createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE, SP); - DISubprogram SPDecl = SP.getFunctionDeclaration(); DIE *DeclDie = NULL; if (SPDecl.isSubprogram()) DeclDie = getOrCreateSubprogramDIE(SPDecl); @@ -1375,15 +1377,9 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) { // Refer function declaration directly. addDIEEntry(SPDie, dwarf::DW_AT_specification, DeclDie); - // Add subprogram definitions to the CU die directly. - addDie(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()) -- cgit v1.2.3