From 1f2f3c3434cca74a67358c1de18a82e2f98497e9 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Sat, 12 Apr 2014 01:44:42 +0000 Subject: Debug info: (bugfix) C++ C/Dtors can be compiled to multiple functions, therefore, their declaration cannot have one DW_AT_linkage_name. The specific instances however can and should have that attribute. This patch reorders the code in DwarfUnit::getOrCreateSubprogramDIE() to emit linkage names for C/Dtors. rdar://problem/16362674. llvm-svn: 206096 --- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 82e9bb008a0..2302abef31d 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1467,20 +1467,25 @@ DIE *DwarfUnit::getOrCreateSubprogramDIE(DISubprogram SP) { // Add function template parameters. addTemplateParams(*SPDie, SP.getTemplateParams()); - // If this DIE is going to refer declaration info using AT_specification - // then there is no need to add other attributes. - if (DeclDie) { + if (DeclDie) // Refer function declaration directly. addDIEEntry(SPDie, dwarf::DW_AT_specification, DeclDie); - return SPDie; + // Add the linkage name if we have one and it isn't in the Decl. + StringRef LinkageName = SP.getLinkageName(); + if (!LinkageName.empty()) { + if (SPDecl.isSubprogram() && !SPDecl.getLinkageName().empty()) + assert(SPDecl.getLinkageName() == SP.getLinkageName() && + "decl has a linkage name and it is different"); + else + addString(SPDie, dwarf::DW_AT_MIPS_linkage_name, + GlobalValue::getRealLinkageName(LinkageName)); } - // Add the linkage name if we have one. - StringRef LinkageName = SP.getLinkageName(); - if (!LinkageName.empty()) - addString(SPDie, dwarf::DW_AT_MIPS_linkage_name, - GlobalValue::getRealLinkageName(LinkageName)); + // If this DIE is going to refer declaration info using AT_specification + // then there is no need to add other attributes. + if (DeclDie) + return SPDie; // Constructors and operators for anonymous aggregates do not have names. if (!SP.getName().empty()) -- cgit v1.2.3