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
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
index af465c0..d820873 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
@@ -485,6 +485,28 @@
virtual DwarfCompileUnit &getCU() = 0;
+ /// \brief Return whether this compilation unit has the
+ /// one-definition-rule (ODR). In C++ this allows the compiler to
+ /// perform type unique during LTO.
+ bool hasODR() const {
+ switch (getLanguage()) {
+ case dwarf::DW_LANG_C_plus_plus:
+ case dwarf::DW_LANG_C_plus_plus_03:
+ case dwarf::DW_LANG_C_plus_plus_11:
+ // For all we care, the C++ part of the language has the ODR and
+ // ObjC methods are not represented in a way that they could be
+ // confused with C++ member functions.
+ case dwarf::DW_LANG_ObjC_plus_plus:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ /// \brief Unique C++ member function declarations based on their
+ /// context+mangled name.
+ DISubprogram getOdrUniqueSubprogram(DIScope Context, DISubprogram SP) const;
+
protected:
/// getOrCreateStaticMemberDIE - Create new static data member DIE.
DIE *getOrCreateStaticMemberDIE(DIDerivedType DT);