diff options
| author | Chris Lattner <sabre@nondot.org> | 2004-11-22 07:24:43 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2004-11-22 07:24:43 +0000 |
| commit | 50c2e117b385086bdba3d1a3c5fdcf9b7754495d (patch) | |
| tree | f7505f07ea2814bcd457d93976b73f1de1d524fc /llvm/lib/ExecutionEngine/JIT/Emitter.cpp | |
| parent | db372c707badd6503a8093d6e6fedb339286336d (diff) | |
| download | bcm5719-llvm-50c2e117b385086bdba3d1a3c5fdcf9b7754495d.tar.gz bcm5719-llvm-50c2e117b385086bdba3d1a3c5fdcf9b7754495d.zip | |
Support targets that require stubs for external functions better
llvm-svn: 18098
Diffstat (limited to 'llvm/lib/ExecutionEngine/JIT/Emitter.cpp')
| -rw-r--r-- | llvm/lib/ExecutionEngine/JIT/Emitter.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/llvm/lib/ExecutionEngine/JIT/Emitter.cpp b/llvm/lib/ExecutionEngine/JIT/Emitter.cpp index 52fb2e31ac6..c2c8875e19c 100644 --- a/llvm/lib/ExecutionEngine/JIT/Emitter.cpp +++ b/llvm/lib/ExecutionEngine/JIT/Emitter.cpp @@ -151,9 +151,22 @@ void *JITResolver::getFunctionStub(Function *F) { void *&Stub = FunctionToStubMap[F]; 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 // 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 '" << F->getName() << "\n"); @@ -274,7 +287,10 @@ void *Emitter::getPointerToGlobal(GlobalValue *V, void *Reference, if (F->hasExternalLinkage()) { // If this is an external function pointer, we can force the JIT to // 'compile' it, which really just adds it to the map. - return TheJIT->getPointerToFunction(F); + if (DoesntNeedStub) + return TheJIT->getPointerToFunction(F); + + return getJITResolver(this).getFunctionStub(F); } // Okay, the function has not been compiled yet, if the target callback |

