Interpret the new varargs intrinsics correctly
authorChris Lattner <sabre@nondot.org>
Sat, 18 Oct 2003 05:55:25 +0000 (05:55 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 18 Oct 2003 05:55:25 +0000 (05:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9222 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/Interpreter/Execution.cpp
lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
lib/ExecutionEngine/Interpreter/Interpreter.h

index 7d9d727e76674ecdd824cc7639af1e1a9bdd3d60..69e746d1591bdc90aceb7455f32e2dd03ea2604b 100644 (file)
@@ -845,27 +845,17 @@ void Interpreter::visitCastInst(CastInst &I) {
   SetValue(&I, executeCastOperation(I.getOperand(0), I.getType(), SF), SF);
 }
 
-void Interpreter::visitVarArgInst(VarArgInst &I) {
+void Interpreter::visitVANextInst(VANextInst &I) {
   ExecutionContext &SF = ECStack.back();
 
-  // Get the pointer to the valist element.  LLI treats the valist in memory as
-  // an integer.
-  GenericValue VAListPtr = getOperandValue(I.getOperand(0), SF);
-
-  // Load the pointer
-  GenericValue VAList = 
-    TheEE->LoadValueFromMemory((GenericValue *)GVTOP(VAListPtr), Type::UIntTy);
-
+  // Get the incoming valist element.  LLI treats the valist as an integer.
+  GenericValue VAList = getOperandValue(I.getOperand(0), SF);
+  
+  // Move to the next operand.
   unsigned Argument = VAList.IntVal++;
-
-  // Update the valist to point to the next argument...
-  TheEE->StoreValueToMemory(VAList, (GenericValue *)GVTOP(VAListPtr),
-                            Type::UIntTy);
-
-  // Set the value...
   assert(Argument < SF.VarArgs.size() &&
          "Accessing past the last vararg argument!");
-  SetValue(&I, SF.VarArgs[Argument], SF);
+  SetValue(&I, VAList, SF);
 }
 
 //===----------------------------------------------------------------------===//
index b92e3c6a02364b5f8df0802e0f1025fa76fdcdf3..44ba87f3b31e7e6e7bb87cf53d777eb807d1a882 100644 (file)
@@ -687,14 +687,12 @@ GenericValue lle_X_fprintf(FunctionType *M, const vector<GenericValue> &Args) {
 // LLVM Intrinsic Functions...
 //===----------------------------------------------------------------------===//
 
-// void llvm.va_start(<va_list> *) - Implement the va_start operation...
+// <va_list> llvm.va_start() - Implement the va_start operation...
 GenericValue llvm_va_start(FunctionType *F, const vector<GenericValue> &Args) {
-  assert(Args.size() == 1);
-  GenericValue *VAListP = (GenericValue *)GVTOP(Args[0]);
+  assert(Args.size() == 0);
   GenericValue Val;
   Val.UIntVal = 0;   // Start at the first '...' argument...
-  TheInterpreter->StoreValueToMemory(Val, VAListP, Type::UIntTy);
-  return GenericValue();
+  return Val;
 }
 
 // void llvm.va_end(<va_list> *) - Implement the va_end operation...
@@ -703,13 +701,10 @@ GenericValue llvm_va_end(FunctionType *F, const vector<GenericValue> &Args) {
   return GenericValue();    // Noop!
 }
 
-// void llvm.va_copy(<va_list> *, <va_list>) - Implement the va_copy
-// operation...
+// <va_list> llvm.va_copy(<va_list>) - Implement the va_copy operation...
 GenericValue llvm_va_copy(FunctionType *F, const vector<GenericValue> &Args) {
-  assert(Args.size() == 2);
-  GenericValue *DestVAList = (GenericValue*)GVTOP(Args[0]);
-  TheInterpreter->StoreValueToMemory(Args[1], DestVAList, Type::UIntTy);
-  return GenericValue();
+  assert(Args.size() == 1);
+  return Args[0];
 }
 
 } // End extern "C"
index 61d391a360a7bc849ad3d634b4a32f25ac622cc5..62ac1f0d3fd588566a01a6b0ab0901de3d81f9b5 100644 (file)
@@ -131,7 +131,7 @@ public:
   void visitCallInst(CallInst &I);
   void visitShl(ShiftInst &I);
   void visitShr(ShiftInst &I);
-  void visitVarArgInst(VarArgInst &I);
+  void visitVANextInst(VANextInst &I);
   void visitInstruction(Instruction &I) {
     std::cerr << I;
     assert(0 && "Instruction not interpretable yet!");