diff options
-rw-r--r-- | lib/ExecutionEngine/Interpreter/Execution.cpp | 20 | ||||
-rw-r--r-- | lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp | 4 | ||||
-rw-r--r-- | lib/ExecutionEngine/Interpreter/Interpreter.h | 4 |
3 files changed, 15 insertions, 13 deletions
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::visitCastInst(CastInst &I) { 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::visitVANextInst(VANextInst &I) { 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); diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp index f516f5d..b547e52 100644 --- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp +++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp @@ -696,9 +696,7 @@ GenericValue lle_X_fprintf(FunctionType *M, const vector<GenericValue> &Args) { // <va_list> llvm.va_start() - Implement the va_start operation... GenericValue llvm_va_start(FunctionType *F, const vector<GenericValue> &Args) { assert(Args.size() == 0); - GenericValue Val; - Val.UIntVal = 0; // Start at the first '...' argument... - return Val; + return TheInterpreter->getFirstVarArg(); } // void llvm.va_end(<va_list> *) - Implement the va_end operation... diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.h b/lib/ExecutionEngine/Interpreter/Interpreter.h index e9015a2..380672a 100644 --- a/lib/ExecutionEngine/Interpreter/Interpreter.h +++ b/lib/ExecutionEngine/Interpreter/Interpreter.h @@ -146,6 +146,10 @@ public: AtExitHandlers.push_back(F); } + GenericValue *getFirstVarArg () { + return &(ECStack[ECStack.size () - 2].VarArgs[0]); + } + //FIXME: private: public: GenericValue executeGEPOperation(Value *Ptr, User::op_iterator I, |