Linker: Do not expect comdat to exist in source module.
authorPeter Collingbourne <peter@pcc.me.uk>
Mon, 22 Jun 2015 21:46:51 +0000 (21:46 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Mon, 22 Jun 2015 21:46:51 +0000 (21:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240341 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Linker/LinkModules.cpp
test/Linker/comdat10.ll [new file with mode: 0644]

index f80f6bc4ce457e7b7f8b5d83ea85788202ee61cc..f1ce23f13e01e61625ed8d873f327f1130fd9d8f 100644 (file)
@@ -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 (file)
index 0000000..8a32c42
--- /dev/null
@@ -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