diff options
author | Adrian Prantl <aprantl@apple.com> | 2014-03-14 23:08:25 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2014-03-14 23:08:25 +0000 |
commit | d1e6a4e1895e322a6a630349b32f7fb22467a94f (patch) | |
tree | 7eab520f7d5e4c5380cffc9c0f7d6dd3eff0ae01 /llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | |
parent | 5a4b90deaebfb3e35ad29b410109a1f736bad56f (diff) | |
download | bcm5719-llvm-d1e6a4e1895e322a6a630349b32f7fb22467a94f.tar.gz bcm5719-llvm-d1e6a4e1895e322a6a630349b32f7fb22467a94f.zip |
Debug Info: Fix LTO type uniquing for C++ member declarations
based on the ODR.
This adds an OdrMemberMap to DwarfDebug which is used to unique C++
member function declarations based on the unique identifier of their
containing class and their mangled name.
We can't use the usual DIRef mechanism here because DIScopes are indexed
using their entire MDNode, including decl_file and decl_line, which need
not be unique (see testcase).
Prior to this change multiple redundant member function declarations would
end up in the same uniqued DW_TAG_class_type.
llvm-svn: 203982
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index dbdcf9d2e11..836beb89b45 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1405,12 +1405,33 @@ DIE *DwarfUnit::getOrCreateNameSpace(DINameSpace NS) { return NDie; } +/// Unique C++ member function declarations based on their +/// context and mangled name. +DISubprogram +DwarfUnit::getOdrUniqueSubprogram(DIScope Context, DISubprogram SP) const { + if (!hasODR() || + !Context.isCompositeType() || + SP.getLinkageName().empty() || + SP.isDefinition()) + return SP; + // Create a key with the UID of the parent class and this SP's name. + Twine Key = SP.getContext().getName() + SP.getLinkageName(); + const MDNode *&Entry = DD->getOrCreateOdrMember(Key.str()); + if (!Entry) + Entry = &*SP; + + return DISubprogram(Entry); +} + /// getOrCreateSubprogramDIE - Create new DIE using SP. DIE *DwarfUnit::getOrCreateSubprogramDIE(DISubprogram SP) { // Construct the context before querying for the existence of the DIE in case // such construction creates the DIE (as is the case for member function // declarations). - DIE *ContextDIE = getOrCreateContextDIE(resolve(SP.getContext())); + DIScope Context = resolve(SP.getContext()); + DIE *ContextDIE = getOrCreateContextDIE(Context); + // Unique declarations based on the ODR, where applicable. + SP = getOdrUniqueSubprogram(Context, SP); DIE *SPDie = getDIE(SP); if (SPDie) |