summaryrefslogtreecommitdiffstats
path: root/lib/ExecutionEngine
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2009-12-22 23:47:23 +0000
committerJeffrey Yasskin <jyasskin@google.com>2009-12-22 23:47:23 +0000
commitc5818fb83750259f23f70e91ee9fb9b11d67160d (patch)
tree1d3b225a256beb93ab8489dc6ec22413296cbc9e /lib/ExecutionEngine
parent3dbcb55b40e3916d538fb6e21ba1662dc82c8fa6 (diff)
downloadexternal_llvm-c5818fb83750259f23f70e91ee9fb9b11d67160d.zip
external_llvm-c5818fb83750259f23f70e91ee9fb9b11d67160d.tar.gz
external_llvm-c5818fb83750259f23f70e91ee9fb9b11d67160d.tar.bz2
Partially revert r91626. Materializing extra functions to determine whether
they're available_externally broke VMKit, which was relying on the fact that functions would only be materialized when they were first called. We'll have to wait for http://llvm.org/PR5737 to really fix this. I also added a test for one of the F->isDeclaration() calls which wasn't covered by anything else in the test suite. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91943 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine')
-rw-r--r--lib/ExecutionEngine/JIT/JITEmitter.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp
index e3523ff..ef323b5 100644
--- a/lib/ExecutionEngine/JIT/JITEmitter.cpp
+++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp
@@ -59,6 +59,12 @@ STATISTIC(NumRetries, "Number of retries with more memory");
static JIT *TheJIT = 0;
+// A declaration may stop being a declaration once it's fully read from bitcode.
+// This function returns true if F is fully read and is still a declaration.
+static bool isNonGhostDeclaration(const Function *F) {
+ return F->isDeclaration() && !F->hasNotBeenReadFromBitcode();
+}
+
//===----------------------------------------------------------------------===//
// JIT lazy compilation code.
//
@@ -517,15 +523,9 @@ void *JITResolver::getLazyFunctionStub(Function *F) {
void *Actual = TheJIT->isCompilingLazily()
? (void *)(intptr_t)LazyResolverFn : (void *)0;
- // TODO: Delete this when PR5737 is fixed.
- std::string ErrorMsg;
- if (TheJIT->materializeFunction(F, &ErrorMsg)) {
- llvm_report_error("Error reading function '" + F->getName()+
- "' from bitcode file: " + ErrorMsg);
- }
// If this is an external declaration, attempt to resolve the address now
// to place in the stub.
- if (F->isDeclaration() || F->hasAvailableExternallyLinkage()) {
+ if (isNonGhostDeclaration(F) || F->hasAvailableExternallyLinkage()) {
Actual = TheJIT->getPointerToFunction(F);
// If we resolved the symbol to a null address (eg. a weak external)
@@ -558,7 +558,7 @@ void *JITResolver::getLazyFunctionStub(Function *F) {
// exist yet, add it to the JIT's work list so that we can fill in the stub
// address later.
if (!Actual && !TheJIT->isCompilingLazily())
- if (!F->isDeclaration() && !F->hasAvailableExternallyLinkage())
+ if (!isNonGhostDeclaration(F) && !F->hasAvailableExternallyLinkage())
TheJIT->addPendingFunction(F);
return Stub;
@@ -761,16 +761,9 @@ void *JITEmitter::getPointerToGlobal(GlobalValue *V, void *Reference,
void *ResultPtr = TheJIT->getPointerToGlobalIfAvailable(F);
if (ResultPtr) return ResultPtr;
- // TODO: Delete this when PR5737 is fixed.
- std::string ErrorMsg;
- if (TheJIT->materializeFunction(F, &ErrorMsg)) {
- llvm_report_error("Error reading function '" + F->getName()+
- "' from bitcode file: " + ErrorMsg);
- }
-
// If this is an external function pointer, we can force the JIT to
// 'compile' it, which really just adds it to the map.
- if (F->isDeclaration() || F->hasAvailableExternallyLinkage())
+ if (isNonGhostDeclaration(F) || F->hasAvailableExternallyLinkage())
return TheJIT->getPointerToFunction(F);
}