diff options
Diffstat (limited to 'llvm/lib/Linker/LinkModules.cpp')
-rw-r--r-- | llvm/lib/Linker/LinkModules.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index 555aeea..2a44800 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -179,9 +179,25 @@ bool ModuleLinker::computeResultingSelectionKind(StringRef ComdatName, // Go with Dst. From = LinkFrom::Dst; break; - case Comdat::SelectionKind::NoDeduplicate: - return emitError("Linking COMDATs named '" + ComdatName + - "': nodeduplicate has been violated!"); + case Comdat::SelectionKind::NoDeduplicate: { + const GlobalVariable *DstGV; + const GlobalVariable *SrcGV; + if (getComdatLeader(DstM, ComdatName, DstGV) || + getComdatLeader(*SrcM, ComdatName, SrcGV)) + return true; + + if (SrcGV->isWeakForLinker()) { + // Go with Dst. + From = LinkFrom::Dst; + } else if (DstGV->isWeakForLinker()) { + // Go with Src. + From = LinkFrom::Src; + } else { + return emitError("Linking COMDATs named '" + ComdatName + + "': nodeduplicate has been violated!"); + } + break; + } case Comdat::SelectionKind::ExactMatch: case Comdat::SelectionKind::Largest: case Comdat::SelectionKind::SameSize: { |