index c743cbbb45d43ebd072e1a50851f173701c83d45..0b72e969d4bf62a05c3e237347584dfab189d8df 100644 (file)
DIE *ContextDIE = getOrCreateContextDIE(Context);
assert(ContextDIE);
+ // Unique the type. This is a noop if the type has no unique identifier.
+ Ty = DIType(resolve(Ty.getRef()));
+
DIE *TyDIE = getDIE(Ty);
if (TyDIE)
return TyDIE;
if (GenerateDwarfTypeUnits && !Ty.isForwardDecl())
if (MDString *TypeId = CTy.getIdentifier()) {
DD->addDwarfTypeUnitType(getCU(), TypeId->getString(), TyDIE, CTy);
- // Skip updating the accellerator tables since this is not the full type
+ // Skip updating the accelerator tables since this is not the full type.
return TyDIE;
}
constructTypeDIE(*TyDIE, CTy);
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)
// TAG_variable.
addString(IsStaticMember && VariableSpecDIE ? VariableSpecDIE
: VariableDIE,
- dwarf::DW_AT_MIPS_linkage_name,
+ DD->getDwarfVersion() >= 4 ? dwarf::DW_AT_linkage_name
+ : dwarf::DW_AT_MIPS_linkage_name,
GlobalValue::getRealLinkageName(LinkageName));
} else if (const ConstantInt *CI =
dyn_cast_or_null<ConstantInt>(GV.getConstant())) {