[llvm-commits] CVS: llvm/lib/ExecutionEngine/JIT/JIT.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Aug 15 16:35:00 PDT 2004
Changes in directory llvm/lib/ExecutionEngine/JIT:
JIT.cpp updated: 1.38 -> 1.39
---
Log message:
These only really work if returning int or void
---
Diffs of the changes: (+20 -16)
Index: llvm/lib/ExecutionEngine/JIT/JIT.cpp
diff -u llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.38 llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.39
--- llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.38 Sun Aug 15 18:31:43 2004
+++ llvm/lib/ExecutionEngine/JIT/JIT.cpp Sun Aug 15 18:34:48 2004
@@ -63,23 +63,27 @@
void *FPtr = getPointerToFunction(F);
assert(FPtr && "Pointer to fn's code was null after getPointerToFunction");
+ const Type *RetTy = F->getReturnType();
- if (ArgValues.size() == 3) {
- int (*PF)(int, char **, const char **) =
- (int(*)(int, char **, const char **))FPtr;
-
- // Call the function.
- 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;
- } else if (ArgValues.size() == 0) {
- int (*PF)() = (int(*)())FPtr;
- rv.IntVal = PF();
- return rv;
+ // Handle some common cases first.
+ if (RetTy == Type::IntTy || RetTy == Type::UIntTy || RetTy == Type::VoidTy) {
+ if (ArgValues.size() == 3) {
+ int (*PF)(int, char **, const char **) =
+ (int(*)(int, char **, const char **))FPtr;
+
+ // Call the function.
+ 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;
+ } else if (ArgValues.size() == 0) {
+ int (*PF)() = (int(*)())FPtr;
+ rv.IntVal = PF();
+ return rv;
+ }
}
// FIXME: This code should handle a couple of common cases efficiently, but
More information about the llvm-commits
mailing list