mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-10 13:48:44 +00:00
Move materialize/Dematerialize calls to linkFunctionBody. NFC.
Just less code duplication. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223653 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -492,7 +492,7 @@ private:
|
|||||||
|
|
||||||
void linkAppendingVarInit(const AppendingVarInfo &AVI);
|
void linkAppendingVarInit(const AppendingVarInfo &AVI);
|
||||||
void linkGlobalInits();
|
void linkGlobalInits();
|
||||||
void linkFunctionBody(Function *Dst, Function *Src);
|
bool linkFunctionBody(Function *Dst, Function *Src);
|
||||||
void linkAliasBodies();
|
void linkAliasBodies();
|
||||||
void linkNamedMDNodes();
|
void linkNamedMDNodes();
|
||||||
};
|
};
|
||||||
@ -1170,9 +1170,13 @@ 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.
|
||||||
void ModuleLinker::linkFunctionBody(Function *Dst, Function *Src) {
|
bool ModuleLinker::linkFunctionBody(Function *Dst, Function *Src) {
|
||||||
assert(Src && Dst && Dst->isDeclaration() && !Src->isDeclaration());
|
assert(Src && Dst && Dst->isDeclaration() && !Src->isDeclaration());
|
||||||
|
|
||||||
|
// Materialize if needed.
|
||||||
|
if (std::error_code EC = Src->materialize())
|
||||||
|
return emitError(EC.message());
|
||||||
|
|
||||||
// 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 (Function::arg_iterator I = Src->arg_begin(), E = Src->arg_end();
|
for (Function::arg_iterator I = Src->arg_begin(), E = Src->arg_end();
|
||||||
@ -1200,6 +1204,8 @@ void ModuleLinker::linkFunctionBody(Function *Dst, Function *Src) {
|
|||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
ValueMap.erase(I);
|
ValueMap.erase(I);
|
||||||
|
|
||||||
|
Src->Dematerialize();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Insert all of the aliases in Src into the Dest module.
|
/// Insert all of the aliases in Src into the Dest module.
|
||||||
@ -1485,16 +1491,12 @@ bool ModuleLinker::run() {
|
|||||||
DF->setPrologueData(MapValue(
|
DF->setPrologueData(MapValue(
|
||||||
SF->getPrologueData(), ValueMap, RF_None, &TypeMap, &ValMaterializer));
|
SF->getPrologueData(), ValueMap, RF_None, &TypeMap, &ValMaterializer));
|
||||||
|
|
||||||
// Materialize if needed.
|
|
||||||
if (std::error_code EC = SF->materialize())
|
|
||||||
return emitError(EC.message());
|
|
||||||
|
|
||||||
// Skip if no body (function is external).
|
// Skip if no body (function is external).
|
||||||
if (SF->isDeclaration())
|
if (SF->isDeclaration())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
linkFunctionBody(DF, SF);
|
if (linkFunctionBody(DF, SF))
|
||||||
SF->Dematerialize();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve all uses of aliases with aliasees.
|
// Resolve all uses of aliases with aliasees.
|
||||||
@ -1525,14 +1527,9 @@ bool ModuleLinker::run() {
|
|||||||
&TypeMap, &ValMaterializer));
|
&TypeMap, &ValMaterializer));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Materialize if needed.
|
|
||||||
if (std::error_code EC = SF->materialize())
|
|
||||||
return emitError(EC.message());
|
|
||||||
|
|
||||||
// Link in function body.
|
// Link in function body.
|
||||||
assert(!SF->isDeclaration());
|
if (linkFunctionBody(DF, SF))
|
||||||
linkFunctionBody(DF, SF);
|
return true;
|
||||||
SF->Dematerialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user