/// 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
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,
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 {
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
// Set the Value of this Instruction.
SetValue(&I, Dest, SF);
+
+ // Move the pointer to the next vararg.
+ ++VAList.UIntPairVal.second;
}
//===----------------------------------------------------------------------===//