For PR950:
[oota-llvm.git] / lib / ExecutionEngine / Interpreter / Execution.cpp
index 11608b6bfa72a883de2f1b3e24ed88a316e2a354..8c812f82d4da7cfb6d3d3e0a70de0945c0004f27 100644 (file)
@@ -553,7 +553,7 @@ void Interpreter::exitCalled(GenericValue GV) {
 
 /// Pop the last stack frame off of ECStack and then copy the result
 /// back into the result variable if we are not returning void. The
-/// result variable may be the ExitCode, or the Value of the calling
+/// result variable may be the ExitValue, or the Value of the calling
 /// CallInst if there was a previous stack frame. This method may
 /// invalidate any ECStack iterators you have. This method also takes
 /// care of switching to the normal destination BB, if we are returning
@@ -566,9 +566,9 @@ void Interpreter::popStackAndReturnValueToCaller (const Type *RetTy,
 
   if (ECStack.empty()) {  // Finished main.  Put result into exit code...
     if (RetTy && RetTy->isIntegral()) {          // Nonvoid return type?
-      ExitCode = Result.IntVal;   // Capture the exit code of the program
+      ExitValue = Result;   // Capture the exit value of the program
     } else {
-      ExitCode = 0;
+      memset(&ExitValue, 0, sizeof(ExitValue));
     }
   } else {
     // If we have a previous stack frame, and we have a previous call,
@@ -735,8 +735,8 @@ GenericValue Interpreter::executeGEPOperation(Value *Ptr, gep_type_iterator I,
     if (const StructType *STy = dyn_cast<StructType>(*I)) {
       const StructLayout *SLO = TD.getStructLayout(STy);
 
-      const ConstantUInt *CPU = cast<ConstantUInt>(I.getOperand());
-      unsigned Index = unsigned(CPU->getValue());
+      const ConstantInt *CPU = cast<ConstantInt>(I.getOperand());
+      unsigned Index = unsigned(CPU->getZExtValue());
 
       Total += (PointerTy)SLO->MemberOffsets[Index];
     } else {
@@ -988,18 +988,6 @@ void Interpreter::visitCastInst(CastInst &I) {
   SetValue(&I, executeCastOperation(I.getOperand(0), I.getType(), SF), SF);
 }
 
-void Interpreter::visitVANextInst(VANextInst &I) {
-  ExecutionContext &SF = ECStack.back();
-
-  // 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.
-  ++VAList.UIntPairVal.second;
-  SetValue(&I, VAList, SF);
-}
-
 #define IMPLEMENT_VAARG(TY) \
    case Type::TY##TyID: Dest.TY##Val = Src.TY##Val; break
 
@@ -1033,6 +1021,9 @@ void Interpreter::visitVAArgInst(VAArgInst &I) {
 
   // Set the Value of this Instruction.
   SetValue(&I, Dest, SF);
+
+  // Move the pointer to the next vararg.
+  ++VAList.UIntPairVal.second;
 }
 
 //===----------------------------------------------------------------------===//