mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-03 14:21:30 +00:00
Support targets that require stubs for external functions better
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18098 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -151,9 +151,22 @@ void *JITResolver::getFunctionStub(Function *F) {
|
|||||||
void *&Stub = FunctionToStubMap[F];
|
void *&Stub = FunctionToStubMap[F];
|
||||||
if (Stub) return Stub;
|
if (Stub) return Stub;
|
||||||
|
|
||||||
|
// Call the lazy resolver function unless we already KNOW it is an external
|
||||||
|
// function, in which case we just skip the lazy resolution step.
|
||||||
|
void *Actual = (void*)LazyResolverFn;
|
||||||
|
if (F->hasExternalLinkage())
|
||||||
|
Actual = TheJIT->getPointerToFunction(F);
|
||||||
|
|
||||||
// Otherwise, codegen a new stub. For now, the stub will call the lazy
|
// Otherwise, codegen a new stub. For now, the stub will call the lazy
|
||||||
// resolver function.
|
// resolver function.
|
||||||
Stub = TheJIT->getJITInfo().emitFunctionStub((void*)LazyResolverFn, MCE);
|
Stub = TheJIT->getJITInfo().emitFunctionStub(Actual, MCE);
|
||||||
|
|
||||||
|
if (F->hasExternalLinkage()) {
|
||||||
|
// If we are getting the stub for an external function, we really want the
|
||||||
|
// address of the stub in the GlobalAddressMap for the JIT, not the address
|
||||||
|
// of the external function.
|
||||||
|
TheJIT->updateGlobalMapping(F, Stub);
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG(std::cerr << "JIT: Stub emitted at [" << Stub << "] for function '"
|
DEBUG(std::cerr << "JIT: Stub emitted at [" << Stub << "] for function '"
|
||||||
<< F->getName() << "\n");
|
<< F->getName() << "\n");
|
||||||
@@ -274,7 +287,10 @@ void *Emitter::getPointerToGlobal(GlobalValue *V, void *Reference,
|
|||||||
if (F->hasExternalLinkage()) {
|
if (F->hasExternalLinkage()) {
|
||||||
// If this is an external function pointer, we can force the JIT to
|
// If this is an external function pointer, we can force the JIT to
|
||||||
// 'compile' it, which really just adds it to the map.
|
// 'compile' it, which really just adds it to the map.
|
||||||
|
if (DoesntNeedStub)
|
||||||
return TheJIT->getPointerToFunction(F);
|
return TheJIT->getPointerToFunction(F);
|
||||||
|
|
||||||
|
return getJITResolver(this).getFunctionStub(F);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Okay, the function has not been compiled yet, if the target callback
|
// Okay, the function has not been compiled yet, if the target callback
|
||||||
|
|||||||
Reference in New Issue
Block a user