diff options
author | Evan Cheng <evan.cheng@apple.com> | 2007-06-30 00:10:37 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2007-06-30 00:10:37 +0000 |
commit | a1a3cc130db2886e25cf22474ca647956240cd39 (patch) | |
tree | ae3f30bf423ad7c3891c47d5cbce7b6c6c83d2a2 /llvm/lib/ExecutionEngine | |
parent | 09ca62d5c5603457582c5f8b791383047d8f772b (diff) | |
download | bcm5719-llvm-a1a3cc130db2886e25cf22474ca647956240cd39.tar.gz bcm5719-llvm-a1a3cc130db2886e25cf22474ca647956240cd39.zip |
(For Chris): Fix failure where we rejected compiling stubs when lazy compilation is disabled.
llvm-svn: 37825
Diffstat (limited to 'llvm/lib/ExecutionEngine')
-rw-r--r-- | llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp b/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp index 99dd0c9a4d4..fc746d6df82 100644 --- a/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -618,25 +618,32 @@ void *JITResolver::JITCompilerFn(void *Stub) { "This is not a known stub!"); Function *F = (--I)->second; - // If disabled, emit a useful error message and abort. - if (TheJIT->isLazyCompilationDisabled()) { - cerr << "LLVM JIT requested to do lazy compilation of function '" - << F->getName() << "' when lazy compiles are disabled!\n"; - abort(); - } + // If we have already code generated the function, just return the address. + void *Result = TheJIT->getPointerToGlobalIfAvailable(F); + + if (!Result) { + // Otherwise we don't have it, do lazy compilation now. + + // If lazy compilation is disabled, emit a useful error message and abort. + if (TheJIT->isLazyCompilationDisabled()) { + cerr << "LLVM JIT requested to do lazy compilation of function '" + << F->getName() << "' when lazy compiles are disabled!\n"; + abort(); + } - // We might like to remove the stub from the StubToFunction map. - // We can't do that! Multiple threads could be stuck, waiting to acquire the - // lock above. As soon as the 1st function finishes compiling the function, - // the next one will be released, and needs to be able to find the function it - // needs to call. - //JR.state.getStubToFunctionMap(locked).erase(I); - - DOUT << "JIT: Lazily resolving function '" << F->getName() - << "' In stub ptr = " << Stub << " actual ptr = " - << I->first << "\n"; - - void *Result = TheJIT->getPointerToFunction(F); + // We might like to remove the stub from the StubToFunction map. + // We can't do that! Multiple threads could be stuck, waiting to acquire the + // lock above. As soon as the 1st function finishes compiling the function, + // the next one will be released, and needs to be able to find the function + // it needs to call. + //JR.state.getStubToFunctionMap(locked).erase(I); + + DOUT << "JIT: Lazily resolving function '" << F->getName() + << "' In stub ptr = " << Stub << " actual ptr = " + << I->first << "\n"; + + Result = TheJIT->getPointerToFunction(F); + } // We don't need to reuse this stub in the future, as F is now compiled. JR.state.getFunctionToStubMap(locked).erase(F); |