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

Brian Gaeke gaeke at cs.uiuc.edu
Wed Feb 25 17:02:34 PST 2004


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.123 -> 1.124

---
Log message:

Represent va_list in interpreter as a (ec-stack-depth . var-arg-index)
pair, and look up varargs in the execution stack every time, instead of
just pushing iterators (which can be invalidated during callFunction())
around.  (union GenericValue now has a "pair of uints" member, to support
this mechanism.) Fixes Bug 234.


---
Diffs of the changes:  (+14 -11)

Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.123 llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.124
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.123	Thu Feb 12 23:48:00 2004
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp	Wed Feb 25 17:01:48 2004
@@ -774,9 +774,13 @@
     switch (F->getIntrinsicID()) {
     case Intrinsic::not_intrinsic:
       break;
-    case Intrinsic::va_start:  // va_start: implemented by getFirstVarArg()
-      SetValue(CS.getInstruction(), getFirstVarArg(), SF);
+    case Intrinsic::va_start: { // va_start
+      GenericValue ArgIndex;
+      ArgIndex.UIntPairVal.first = ECStack.size() - 1;
+      ArgIndex.UIntPairVal.second = 0;
+      SetValue(CS.getInstruction(), ArgIndex, SF);
       return;
+    }
     case Intrinsic::va_end:    // va_end is a noop for the interpreter
       return;
     case Intrinsic::va_copy:   // va_copy: dest = src
@@ -960,14 +964,12 @@
 void Interpreter::visitVANextInst(VANextInst &I) {
   ExecutionContext &SF = ECStack.back();
 
-  // Get the incoming valist parameter.  LLI treats the valist as a pointer 
-  // to the next argument.
+  // Get the incoming valist parameter.  LLI treats the valist as a
+  // (ec-stack-depth var-arg-index) pair.
   GenericValue VAList = getOperandValue(I.getOperand(0), SF);
   
   // Move the pointer to the next vararg.
-  GenericValue *ArgPtr = (GenericValue *) GVTOP (VAList);
-  ++ArgPtr;
-  VAList = PTOGV (ArgPtr);
+  ++VAList.UIntPairVal.second;
   SetValue(&I, VAList, SF);
 }
 
@@ -977,11 +979,12 @@
 void Interpreter::visitVAArgInst(VAArgInst &I) {
   ExecutionContext &SF = ECStack.back();
 
-  // Get the incoming valist parameter.  LLI treats the valist as a pointer 
-  // to the next argument.
+  // Get the incoming valist parameter.  LLI treats the valist as a
+  // (ec-stack-depth var-arg-index) pair.
   GenericValue VAList = getOperandValue(I.getOperand(0), SF);
-  assert (GVTOP (VAList) != 0 && "VAList was null in vaarg instruction");
-  GenericValue Dest, Src = *(GenericValue *) GVTOP (VAList);
+  GenericValue Dest;
+  GenericValue Src = ECStack[VAList.UIntPairVal.first]
+	.VarArgs[VAList.UIntPairVal.second];
   const Type *Ty = I.getType();
   switch (Ty->getPrimitiveID()) {
     IMPLEMENT_VAARG(UByte);





More information about the llvm-commits mailing list