diff options
| author | Jeffrey Yasskin <jyasskin@google.com> | 2009-10-13 21:32:57 +0000 |
|---|---|---|
| committer | Jeffrey Yasskin <jyasskin@google.com> | 2009-10-13 21:32:57 +0000 |
| commit | d162dbac7fa371fcb9d657c744865f8f95d5642e (patch) | |
| tree | 3c9546c9b764c9ebce959144aa66df5ec451b278 /llvm/lib/ExecutionEngine | |
| parent | 7373095ebf27093d88878fd1b13ee0f04750f1e1 (diff) | |
| download | bcm5719-llvm-d162dbac7fa371fcb9d657c744865f8f95d5642e.tar.gz bcm5719-llvm-d162dbac7fa371fcb9d657c744865f8f95d5642e.zip | |
Keep track of stubs that are created. This fixes PR5162 and probably PR4822 and
4406. Patch by Nick Lewycky!
llvm-svn: 84032
Diffstat (limited to 'llvm/lib/ExecutionEngine')
| -rw-r--r-- | llvm/lib/ExecutionEngine/JIT/JIT.h | 5 | ||||
| -rw-r--r-- | llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp | 15 |
2 files changed, 9 insertions, 11 deletions
diff --git a/llvm/lib/ExecutionEngine/JIT/JIT.h b/llvm/lib/ExecutionEngine/JIT/JIT.h index dfeffb516e1..525cc84f945 100644 --- a/llvm/lib/ExecutionEngine/JIT/JIT.h +++ b/llvm/lib/ExecutionEngine/JIT/JIT.h @@ -16,6 +16,7 @@ #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/PassManager.h" +#include "llvm/Support/ValueHandle.h" namespace llvm { @@ -33,7 +34,7 @@ private: /// PendingFunctions - Functions which have not been code generated yet, but /// were called from a function being code generated. - std::vector<Function*> PendingFunctions; + std::vector<AssertingVH<Function> > PendingFunctions; public: explicit JITState(ModuleProvider *MP) : PM(MP), MP(MP) {} @@ -43,7 +44,7 @@ public: } ModuleProvider *getMP() const { return MP; } - std::vector<Function*> &getPendingFunctions(const MutexGuard &L) { + std::vector<AssertingVH<Function> > &getPendingFunctions(const MutexGuard &L){ return PendingFunctions; } }; diff --git a/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp b/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp index e8314a1d866..3d69c3ff5ed 100644 --- a/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -64,7 +64,7 @@ namespace { class JITResolverState { public: typedef std::map<AssertingVH<Function>, void*> FunctionToStubMapTy; - typedef std::map<void*, Function*> StubToFunctionMapTy; + typedef std::map<void*, AssertingVH<Function> > StubToFunctionMapTy; typedef std::map<AssertingVH<GlobalValue>, void*> GlobalToIndirectSymMapTy; private: /// FunctionToStubMap - Keep track of the stub created for a particular @@ -198,9 +198,9 @@ void *JITResolver::getFunctionStub(Function *F) { // Call the lazy resolver function unless we are JIT'ing non-lazily, in which // case we must resolve the symbol now. - void *Actual = TheJIT->isLazyCompilationDisabled() + void *Actual = TheJIT->isLazyCompilationDisabled() ? (void *)0 : (void *)(intptr_t)LazyResolverFn; - + // If this is an external declaration, attempt to resolve the address now // to place in the stub. if (F->isDeclaration() && !F->hasNotBeenReadFromBitcode()) { @@ -231,14 +231,14 @@ void *JITResolver::getFunctionStub(Function *F) { // Finally, keep track of the stub-to-Function mapping so that the // JITCompilerFn knows which function to compile! state.getStubToFunctionMap(locked)[Stub] = F; - + // If we are JIT'ing non-lazily but need to call a function that does not // exist yet, add it to the JIT's work list so that we can fill in the stub // address later. if (!Actual && TheJIT->isLazyCompilationDisabled()) if (!F->isDeclaration() || F->hasNotBeenReadFromBitcode()) TheJIT->addPendingFunction(F); - + return Stub; } @@ -696,11 +696,8 @@ void *JITEmitter::getPointerToGVIndirectSym(GlobalValue *V, void *Reference, } void JITEmitter::AddStubToCurrentFunction(void *StubAddr) { - if (!TheJIT->areDlsymStubsEnabled()) - return; - assert(CurFn && "Stub added to current function, but current function is 0!"); - + SmallVectorImpl<void*> &StubsUsed = CurFnStubUses[CurFn]; StubsUsed.push_back(StubAddr); |

