forked from OSchip/llvm-project
Fix linking of prologue data.
It would crash when the function was lazy linked. llvm-svn: 223656
This commit is contained in:
parent
999a8d89f8
commit
869d1ce811
|
@ -1177,6 +1177,17 @@ bool ModuleLinker::linkFunctionBody(Function *Dst, Function *Src) {
|
|||
if (std::error_code EC = Src->materialize())
|
||||
return emitError(EC.message());
|
||||
|
||||
// Link in the prefix data.
|
||||
if (Src->hasPrefixData())
|
||||
Dst->setPrefixData(MapValue(Src->getPrefixData(), ValueMap, RF_None,
|
||||
&TypeMap, &ValMaterializer));
|
||||
|
||||
// Link in the prologue data.
|
||||
if (Src->hasPrologueData())
|
||||
Dst->setPrologueData(MapValue(Src->getPrologueData(), ValueMap, RF_None,
|
||||
&TypeMap, &ValMaterializer));
|
||||
|
||||
|
||||
// Go through and convert function arguments over, remembering the mapping.
|
||||
Function::arg_iterator DI = Dst->arg_begin();
|
||||
for (Function::arg_iterator I = Src->arg_begin(), E = Src->arg_end();
|
||||
|
@ -1485,17 +1496,6 @@ bool ModuleLinker::run() {
|
|||
continue;
|
||||
|
||||
Function *DF = cast<Function>(ValueMap[&SF]);
|
||||
|
||||
// Link in the prefix data.
|
||||
if (SF.hasPrefixData())
|
||||
DF->setPrefixData(MapValue(SF.getPrefixData(), ValueMap, RF_None,
|
||||
&TypeMap, &ValMaterializer));
|
||||
|
||||
// Link in the prologue data.
|
||||
if (SF.hasPrologueData())
|
||||
DF->setPrologueData(MapValue(SF.getPrologueData(), ValueMap, RF_None,
|
||||
&TypeMap, &ValMaterializer));
|
||||
|
||||
if (linkFunctionBody(DF, &SF))
|
||||
return true;
|
||||
}
|
||||
|
@ -1522,13 +1522,6 @@ bool ModuleLinker::run() {
|
|||
LazilyLinkFunctions.pop_back();
|
||||
|
||||
Function *DF = cast<Function>(ValueMap[SF]);
|
||||
if (SF->hasPrefixData()) {
|
||||
// Link in the prefix data.
|
||||
DF->setPrefixData(MapValue(SF->getPrefixData(), ValueMap, RF_None,
|
||||
&TypeMap, &ValMaterializer));
|
||||
}
|
||||
|
||||
// Link in function body.
|
||||
if (linkFunctionBody(DF, SF))
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,21 @@
|
|||
; RUN: echo > %t.ll
|
||||
; RUN: llvm-link %t.ll %s -S -o - | FileCheck %s
|
||||
; RUN: llvm-link %s -S -o - | FileCheck %s
|
||||
|
||||
@i = linkonce_odr global i32 1
|
||||
@g1 = global void()* @f2
|
||||
; CHECK: @g1 = global void ()* @f2
|
||||
|
||||
; CHECK: define void @f() prologue i32* @i
|
||||
define void @f() prologue i32* @i {
|
||||
@p1 = global i8 42
|
||||
; CHECK: @p1 = global i8 42
|
||||
|
||||
@p2 = internal global i8 43
|
||||
; CHECK: @p2 = internal global i8 43
|
||||
|
||||
define void @f1() prologue i8* @p1 {
|
||||
ret void
|
||||
}
|
||||
; CHECK: define void @f1() prologue i8* @p1 {
|
||||
|
||||
define internal void @f2() prologue i8* @p2 {
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: define internal void @f2() prologue i8* @p2 {
|
||||
|
|
Loading…
Reference in New Issue