Minor speedup by avoiding callbacks to functions already generated
authorChris Lattner <sabre@nondot.org>
Thu, 8 May 2003 21:44:21 +0000 (21:44 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 8 May 2003 21:44:21 +0000 (21:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6052 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/JIT/Callback.cpp
lib/ExecutionEngine/JIT/JITEmitter.cpp

index 75abf435e6a528c093e0867d2daafe964388f0f4..fc13a10855b6f2c19dd27a99231636472134346a 100644 (file)
@@ -46,7 +46,6 @@ void VM::CompilationCallback() {
 #endif
 }
 
-
 void VM::registerCallback() {
   TheVM = this;
 }
index d6f75c08f7643a7275077dd922e6da7a2129302b..69e2453090da80c44db725d869e4de65d2ed4b89 100644 (file)
@@ -131,11 +131,15 @@ void Emitter::emitAddress(void *Addr, bool isPCRelative) {
 
 void Emitter::emitGlobalAddress(GlobalValue *V, bool isPCRelative) {
   if (isPCRelative) { // must be a call, this is a major hack!
-    // FIXME: Try looking up the function to see if it is already compiled!
-    TheVM.addFunctionRef(CurByte, cast<Function>(V));
-
-    // Delayed resolution...
-    emitAddress((void*)VM::CompilationCallback, isPCRelative);
+    // Try looking up the function to see if it is already compiled!
+    if (void *Addr = TheVM.getPointerToGlobalIfAvailable(V)) {
+      emitAddress(Addr, isPCRelative);
+    } else {  // Function has not yet been code generated!
+      TheVM.addFunctionRef(CurByte, cast<Function>(V));
+
+      // Delayed resolution...
+      emitAddress((void*)VM::CompilationCallback, isPCRelative);
+    }
   } else {
     emitAddress(TheVM.getPointerToGlobal(V), isPCRelative);
   }