diff options
author | Evan Cheng <evan.cheng@apple.com> | 2008-11-13 21:50:50 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2008-11-13 21:50:50 +0000 |
commit | 704bff9e6cf0070924eb11d9e81e5ba6962ae4ef (patch) | |
tree | 41c99a43f86dac6eb917fefe7a91a30c772b4ff4 /lib/ExecutionEngine/JIT | |
parent | 550f5afb68ce8f034991863cac65bef22a6554da (diff) | |
download | external_llvm-704bff9e6cf0070924eb11d9e81e5ba6962ae4ef.zip external_llvm-704bff9e6cf0070924eb11d9e81e5ba6962ae4ef.tar.gz external_llvm-704bff9e6cf0070924eb11d9e81e5ba6962ae4ef.tar.bz2 |
Always emit a function pointer as a pointer to the function stub (if there is one). This makes it possible to compare function pointer values in lazy compilation mode. This fixes PR3043.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59265 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/JIT')
-rw-r--r-- | lib/ExecutionEngine/JIT/JITEmitter.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp index 14705a4..dd81f32 100644 --- a/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -115,6 +115,10 @@ namespace { TheJITResolver = 0; } + /// getFunctionStubIfAvailable - This returns a pointer to a function stub + /// if it has already been created. + void *getFunctionStubIfAvailable(Function *F); + /// getFunctionStub - This returns a pointer to a function stub, creating /// one on demand as needed. void *getFunctionStub(Function *F); @@ -151,6 +155,16 @@ namespace { JITResolver *JITResolver::TheJITResolver = 0; +/// getFunctionStubIfAvailable - This returns a pointer to a function stub +/// if it has already been created. +void *JITResolver::getFunctionStubIfAvailable(Function *F) { + MutexGuard locked(TheJIT->lock); + + // If we already have a stub for this function, recycle it. + void *&Stub = state.getFunctionToStubMap(locked)[F]; + return Stub; +} + /// getFunctionStub - This returns a pointer to a function stub, creating /// one on demand as needed. void *JITResolver::getFunctionStub(Function *F) { @@ -596,7 +610,12 @@ void *JITEmitter::getPointerToGlobal(GlobalValue *V, void *Reference, // If we have already compiled the function, return a pointer to its body. Function *F = cast<Function>(V); - void *ResultPtr = TheJIT->getPointerToGlobalIfAvailable(F); + void *ResultPtr; + if (!DoesntNeedStub) + // Return the function stub if it's already created. + ResultPtr = Resolver.getFunctionStubIfAvailable(F); + else + ResultPtr = TheJIT->getPointerToGlobalIfAvailable(F); if (ResultPtr) return ResultPtr; if (F->isDeclaration() && !F->hasNotBeenReadFromBitcode()) { |