Skip to content

Commit 4d358b5

Browse files
committed
Have getOrCreateSubprogramDIE store the DIE for a subprogram
definition in the map before calling itself to retrieve the DIE for the declaration. Without this change, if this causes getOrCreateSubprogramDIE to be recursively called on the definition, it will create multiple DIEs for that definition. Fixes PR12831. llvm-svn: 157541
1 parent f39c278 commit 4d358b5

File tree

2 files changed

+243
-5
lines changed

2 files changed

+243
-5
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,17 +1021,17 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
10211021
if (SPDie)
10221022
return SPDie;
10231023

1024+
SPDie = new DIE(dwarf::DW_TAG_subprogram);
1025+
1026+
// DW_TAG_inlined_subroutine may refer to this DIE.
1027+
insertDIE(SP, SPDie);
1028+
10241029
DISubprogram SPDecl = SP.getFunctionDeclaration();
10251030
DIE *DeclDie = NULL;
10261031
if (SPDecl.isSubprogram()) {
10271032
DeclDie = getOrCreateSubprogramDIE(SPDecl);
10281033
}
10291034

1030-
SPDie = new DIE(dwarf::DW_TAG_subprogram);
1031-
1032-
// DW_TAG_inlined_subroutine may refer to this DIE.
1033-
insertDIE(SP, SPDie);
1034-
10351035
// Add to context owner.
10361036
addToContextOwner(SPDie, SP.getContext());
10371037

0 commit comments

Comments
 (0)