[llvm-commits] CVS: llvm/lib/ExecutionEngine/JIT/JIT.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Aug 15 16:30:02 PDT 2004



Changes in directory llvm/lib/ExecutionEngine/JIT:

JIT.cpp updated: 1.36 -> 1.37
---
Log message:

Simplify code a bit, print error message always instead of asserting.


---
Diffs of the changes:  (+19 -16)

Index: llvm/lib/ExecutionEngine/JIT/JIT.cpp
diff -u llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.36 llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.37
--- llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.36	Wed Jul  7 16:20:28 2004
+++ llvm/lib/ExecutionEngine/JIT/JIT.cpp	Sun Aug 15 18:29:50 2004
@@ -58,29 +58,32 @@
 ///
 GenericValue JIT::runFunction(Function *F,
                               const std::vector<GenericValue> &ArgValues) {
-  assert (F && "Function *F was null at entry to run()");
-    GenericValue rv;
+  assert(F && "Function *F was null at entry to run()");
+  GenericValue rv;
+
+  void *FPtr = getPointerToFunction(F);
+  assert(PFtr && "Pointer to fn's code was null after getPointerToFunction");
 
   if (ArgValues.size() == 3) {
     int (*PF)(int, char **, const char **) =
-      (int(*)(int, char **, const char **))getPointerToFunction(F);
-    assert(PF && "Pointer to fn's code was null after getPointerToFunction");
+      (int(*)(int, char **, const char **))FPtr;
     
     // Call the function.
-    int ExitCode = PF(ArgValues[0].IntVal, (char **) GVTOP (ArgValues[1]),
-                      (const char **) GVTOP (ArgValues[2]));
-    
-    rv.IntVal = ExitCode;
-  } else {
-    // FIXME: This code should handle a couple of common cases efficiently, but
-    // it should also implement the general case by code-gening a new anonymous
-    // nullary function to call.
-    assert(ArgValues.size() == 1);
-    void (*PF)(int) = (void(*)(int))getPointerToFunction(F);
-    assert(PF && "Pointer to fn's code was null after getPointerToFunction");
-    PF(ArgValues[0].IntVal);
+    rv.IntVal = PF(ArgValues[0].IntVal, (char **)GVTOP(ArgValues[1]),
+                   (const char **)GVTOP(ArgValues[2]));
+    return rv;
+  } else if (ArgValues.size() == 1) {
+    int (*PF)(int) = (int(*)(int))FPtr;
+    rv.IntVal = PF(ArgValues[0].IntVal);
+    return rv;
   }
 
+  // FIXME: This code should handle a couple of common cases efficiently, but
+  // it should also implement the general case by code-gening a new anonymous
+  // nullary function to call.
+  std::cerr << "Sorry, unimplemented feature in the LLVM JIT.  See LLVM"
+            << " PR#419\n for details.\n";
+  abort();
   return rv;
 }
 






More information about the llvm-commits mailing list