Don't crash when the key of a comdat is lazily linked.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223673 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2014-12-08 18:05:48 +00:00
parent 70b0751080
commit dcc44c64c1
2 changed files with 20 additions and 5 deletions

View File

@ -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) {

View File

@ -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