diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index f80f6bc4ce4..f1ce23f13e0 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -1573,8 +1573,8 @@ bool ModuleLinker::run() { if (C.getSelectionKind() == Comdat::Any) continue; const GlobalValue *GV = SrcM->getNamedValue(C.getName()); - assert(GV); - MapValue(GV, ValueMap, RF_None, &TypeMap, &ValMaterializer); + if (GV) + MapValue(GV, ValueMap, RF_None, &TypeMap, &ValMaterializer); } // Strip replaced subprograms before mapping any metadata -- so that we're diff --git a/test/Linker/comdat10.ll b/test/Linker/comdat10.ll new file mode 100644 index 00000000000..8a32c426739 --- /dev/null +++ b/test/Linker/comdat10.ll @@ -0,0 +1,6 @@ +; RUN: llvm-link %s /dev/null -S -o - | FileCheck %s + +$c = comdat largest + +; CHECK: @c = global i32 0, comdat +@c = global i32 0, comdat