mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-25 16:29:20 +00:00
Move the ValueMap lookup inside linkFunctionBody. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223659 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
eaa2992eb2
commit
968f0454b8
@ -492,7 +492,7 @@ private:
|
|||||||
|
|
||||||
void linkAppendingVarInit(const AppendingVarInfo &AVI);
|
void linkAppendingVarInit(const AppendingVarInfo &AVI);
|
||||||
void linkGlobalInits();
|
void linkGlobalInits();
|
||||||
bool linkFunctionBody(Function *Dst, Function *Src);
|
bool linkFunctionBody(Function &Src);
|
||||||
void linkAliasBodies();
|
void linkAliasBodies();
|
||||||
void linkNamedMDNodes();
|
void linkNamedMDNodes();
|
||||||
};
|
};
|
||||||
@ -1169,27 +1169,28 @@ void ModuleLinker::linkGlobalInits() {
|
|||||||
/// Copy the source function over into the dest function and fix up references
|
/// Copy the source function over into the dest function and fix up references
|
||||||
/// to values. At this point we know that Dest is an external function, and
|
/// to values. At this point we know that Dest is an external function, and
|
||||||
/// that Src is not.
|
/// that Src is not.
|
||||||
bool ModuleLinker::linkFunctionBody(Function *Dst, Function *Src) {
|
bool ModuleLinker::linkFunctionBody(Function &Src) {
|
||||||
assert(Src && Dst && Dst->isDeclaration() && !Src->isDeclaration());
|
Function *Dst = cast<Function>(ValueMap[&Src]);
|
||||||
|
assert(Dst && Dst->isDeclaration() && !Src.isDeclaration());
|
||||||
|
|
||||||
// Materialize if needed.
|
// Materialize if needed.
|
||||||
if (std::error_code EC = Src->materialize())
|
if (std::error_code EC = Src.materialize())
|
||||||
return emitError(EC.message());
|
return emitError(EC.message());
|
||||||
|
|
||||||
// Link in the prefix data.
|
// Link in the prefix data.
|
||||||
if (Src->hasPrefixData())
|
if (Src.hasPrefixData())
|
||||||
Dst->setPrefixData(MapValue(Src->getPrefixData(), ValueMap, RF_None,
|
Dst->setPrefixData(MapValue(Src.getPrefixData(), ValueMap, RF_None,
|
||||||
&TypeMap, &ValMaterializer));
|
&TypeMap, &ValMaterializer));
|
||||||
|
|
||||||
// Link in the prologue data.
|
// Link in the prologue data.
|
||||||
if (Src->hasPrologueData())
|
if (Src.hasPrologueData())
|
||||||
Dst->setPrologueData(MapValue(Src->getPrologueData(), ValueMap, RF_None,
|
Dst->setPrologueData(MapValue(Src.getPrologueData(), ValueMap, RF_None,
|
||||||
&TypeMap, &ValMaterializer));
|
&TypeMap, &ValMaterializer));
|
||||||
|
|
||||||
|
|
||||||
// Go through and convert function arguments over, remembering the mapping.
|
// Go through and convert function arguments over, remembering the mapping.
|
||||||
Function::arg_iterator DI = Dst->arg_begin();
|
Function::arg_iterator DI = Dst->arg_begin();
|
||||||
for (Argument &Arg : Src->args()) {
|
for (Argument &Arg : Src.args()) {
|
||||||
DI->setName(Arg.getName()); // Copy the name over.
|
DI->setName(Arg.getName()); // Copy the name over.
|
||||||
|
|
||||||
// Add a mapping to our mapping.
|
// Add a mapping to our mapping.
|
||||||
@ -1198,7 +1199,7 @@ bool ModuleLinker::linkFunctionBody(Function *Dst, Function *Src) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Splice the body of the source function into the dest function.
|
// Splice the body of the source function into the dest function.
|
||||||
Dst->getBasicBlockList().splice(Dst->end(), Src->getBasicBlockList());
|
Dst->getBasicBlockList().splice(Dst->end(), Src.getBasicBlockList());
|
||||||
|
|
||||||
// At this point, all of the instructions and values of the function are now
|
// At this point, all of the instructions and values of the function are now
|
||||||
// copied over. The only problem is that they are still referencing values in
|
// copied over. The only problem is that they are still referencing values in
|
||||||
@ -1210,10 +1211,10 @@ bool ModuleLinker::linkFunctionBody(Function *Dst, Function *Src) {
|
|||||||
&ValMaterializer);
|
&ValMaterializer);
|
||||||
|
|
||||||
// There is no need to map the arguments anymore.
|
// There is no need to map the arguments anymore.
|
||||||
for (Argument &Arg : Src->args())
|
for (Argument &Arg : Src.args())
|
||||||
ValueMap.erase(&Arg);
|
ValueMap.erase(&Arg);
|
||||||
|
|
||||||
Src->Dematerialize();
|
Src.Dematerialize();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1492,8 +1493,7 @@ bool ModuleLinker::run() {
|
|||||||
if (DoNotLinkFromSource.count(&SF))
|
if (DoNotLinkFromSource.count(&SF))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Function *DF = cast<Function>(ValueMap[&SF]);
|
if (linkFunctionBody(SF))
|
||||||
if (linkFunctionBody(DF, &SF))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1518,8 +1518,7 @@ bool ModuleLinker::run() {
|
|||||||
Function *SF = LazilyLinkFunctions.back();
|
Function *SF = LazilyLinkFunctions.back();
|
||||||
LazilyLinkFunctions.pop_back();
|
LazilyLinkFunctions.pop_back();
|
||||||
|
|
||||||
Function *DF = cast<Function>(ValueMap[SF]);
|
if (linkFunctionBody(*SF))
|
||||||
if (linkFunctionBody(DF, SF))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user