Change LLI's internal representation of va_list to a pointer to the next
argument to be returned by va_arg. This allows va_lists to be passed
between different LLVM procedures (though it is unlikely that an LLI
va_list would make sense to an external function, except by chance.)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9965 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp
index aa32983..d668ee7 100644
--- a/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -812,13 +812,14 @@
 void Interpreter::visitVANextInst(VANextInst &I) {
   ExecutionContext &SF = ECStack.back();
 
-  // Get the incoming valist element.  LLI treats the valist as an integer.
+  // Get the incoming valist parameter.  LLI treats the valist as a pointer 
+  // to the next argument.
   GenericValue VAList = getOperandValue(I.getOperand(0), SF);
   
-  // Move to the next operand.
-  unsigned Argument = VAList.IntVal++;
-  assert(Argument < SF.VarArgs.size() &&
-         "Accessing past the last vararg argument!");
+  // Move the pointer to the next vararg.
+  GenericValue *ArgPtr = (GenericValue *) GVTOP (VAList);
+  ++ArgPtr;
+  VAList = PTOGV (ArgPtr);
   SetValue(&I, VAList, SF);
 }
 
@@ -828,12 +829,11 @@
 void Interpreter::visitVAArgInst(VAArgInst &I) {
   ExecutionContext &SF = ECStack.back();
 
-  // Get the incoming valist element.  LLI treats the valist as an integer.
+  // Get the incoming valist parameter.  LLI treats the valist as a pointer 
+  // to the next argument.
   GenericValue VAList = getOperandValue(I.getOperand(0), SF);
-  unsigned Argument = VAList.IntVal;
-  assert(Argument < SF.VarArgs.size() &&
-         "Accessing past the last vararg argument!");
-  GenericValue Dest, Src = SF.VarArgs[Argument];
+  assert (GVTOP (VAList) != 0 && "VAList was null in vaarg instruction");
+  GenericValue Dest, Src = *(GenericValue *) GVTOP (VAList);
   const Type *Ty = I.getType();
   switch (Ty->getPrimitiveID()) {
     IMPLEMENT_VAARG(UByte);