[llvm] r223673 - Don't crash when the key of a comdat is lazily linked.
Rafael Espindola
rafael.espindola at gmail.com
Mon Dec 8 10:05:48 PST 2014
Author: rafael
Date: Mon Dec 8 12:05:48 2014
New Revision: 223673
URL: http://llvm.org/viewvc/llvm-project?rev=223673&view=rev
Log:
Don't crash when the key of a comdat is lazily linked.
Modified:
llvm/trunk/lib/Linker/LinkModules.cpp
llvm/trunk/test/Linker/comdat9.ll
Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=223673&r1=223672&r2=223673&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Mon Dec 8 12:05:48 2014
@@ -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) {
Modified: llvm/trunk/test/Linker/comdat9.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/comdat9.ll?rev=223673&r1=223672&r2=223673&view=diff
==============================================================================
--- llvm/trunk/test/Linker/comdat9.ll (original)
+++ llvm/trunk/test/Linker/comdat9.ll Mon Dec 8 12:05:48 2014
@@ -6,8 +6,14 @@ define internal void @f() comdat $c {
ret void
}
-; CHECK: $c = comdat any
-; CHECK: @a = alias void ()* @f
-; CHECK: define internal void @f() comdat $c {
-; CHECK: ret void
-; CHECK: }
+; CHECK-DAG: $c = comdat any
+; CHECK-DAG: @a = alias void ()* @f
+; CHECK-DAG: define internal void @f() comdat $c
+
+$f2 = comdat largest
+define internal void @f2() comdat $f2 {
+ ret void
+}
+
+; CHECK-DAG: $f2 = comdat largest
+; CHECK-DAG: define internal void @f2() comdat $f2
More information about the llvm-commits
mailing list