From beadd56a7d4fb234699b95575fcbf2a8ff64498e Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 8 Dec 2014 18:05:48 +0000 Subject: Don't crash when the key of a comdat is lazily linked. llvm-svn: 223673 --- llvm/lib/Linker/LinkModules.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'llvm/lib/Linker/LinkModules.cpp') diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index 06710240c94..331fdad9000 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -1482,6 +1482,15 @@ bool ModuleLinker::run() { for (unsigned i = 0, e = AppendingVars.size(); i != e; ++i) linkAppendingVarInit(AppendingVars[i]); + for (const auto &Entry : DstM->getComdatSymbolTable()) { + const Comdat &C = Entry.getValue(); + if (C.getSelectionKind() == Comdat::Any) + continue; + const GlobalValue *GV = SrcM->getNamedValue(C.getName()); + assert(GV); + MapValue(GV, ValueMap, RF_None, &TypeMap, &ValMaterializer); + } + // Link in the function bodies that are defined in the source module into // DstM. for (Function &SF : *SrcM) { -- cgit v1.2.3