aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-12-12 07:12:02 +0000
committerChris Lattner <sabre@nondot.org>2003-12-12 07:12:02 +0000
commit89af2d5a363be0ad725fc7146295b1f8f41e5cff (patch)
tree4a5597da23ba1d26e36a1c52a0dea3127b122c40
parent2e7416cb04ef722ad6cb6772f66627d50400cbb8 (diff)
downloadllvm-89af2d5a363be0ad725fc7146295b1f8f41e5cff.zip
llvm-89af2d5a363be0ad725fc7146295b1f8f41e5cff.tar.gz
llvm-89af2d5a363be0ad725fc7146295b1f8f41e5cff.tar.bz2
Implement the ExecutionEngine::getPointerToFunctionOrStub by forwarding the
request on to the TargetMachine if it supports the getJITStubForFunction method llvm-svn: 10431
-rw-r--r--llvm/lib/ExecutionEngine/JIT/VM.cpp17
-rw-r--r--llvm/lib/ExecutionEngine/JIT/VM.h6
2 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/ExecutionEngine/JIT/VM.cpp b/llvm/lib/ExecutionEngine/JIT/VM.cpp
index e71ec60..29ffa30 100644
--- a/llvm/lib/ExecutionEngine/JIT/VM.cpp
+++ b/llvm/lib/ExecutionEngine/JIT/VM.cpp
@@ -77,6 +77,23 @@ void *VM::getPointerToFunction(Function *F) {
return Addr;
}
+// getPointerToFunctionOrStub - If the specified function has been
+// code-gen'd, return a pointer to the function. If not, compile it, or use
+// a stub to implement lazy compilation if available.
+//
+void *VM::getPointerToFunctionOrStub(Function *F) {
+ // If we have already code generated the function, just return the address.
+ std::map<const GlobalValue*, void *>::iterator I = GlobalAddress.find(F);
+ if (I != GlobalAddress.end()) return I->second;
+
+ // If the target supports "stubs" for functions, get a stub now.
+ if (void *Ptr = TM.getJITStubForFunction(F, *MCE))
+ return Ptr;
+
+ // Otherwise, if the target doesn't support it, just codegen the function.
+ return getPointerToFunction(F);
+}
+
/// recompileAndRelinkFunction - This method is used to force a function
/// which has already been compiled, to be compiled again, possibly
/// after it has been modified. Then the entry to the old copy is overwritten
diff --git a/llvm/lib/ExecutionEngine/JIT/VM.h b/llvm/lib/ExecutionEngine/JIT/VM.h
index 9a17c96..dc82067 100644
--- a/llvm/lib/ExecutionEngine/JIT/VM.h
+++ b/llvm/lib/ExecutionEngine/JIT/VM.h
@@ -66,6 +66,12 @@ public:
///
void *getPointerToFunction(Function *F);
+ /// getPointerToFunctionOrStub - If the specified function has been
+ /// code-gen'd, return a pointer to the function. If not, compile it, or use
+ /// a stub to implement lazy compilation if available.
+ ///
+ void *getPointerToFunctionOrStub(Function *F);
+
/// recompileAndRelinkFunction - This method is used to force a function
/// which has already been compiled, to be compiled again, possibly
/// after it has been modified. Then the entry to the old copy is overwritten