[llvm-commits] CVS: llvm/tools/lli/Interpreter/Execution.cpp Interpreter.h
Chris Lattner
lattner at cs.uiuc.edu
Thu May 8 11:08:01 PDT 2003
Changes in directory llvm/tools/lli/Interpreter:
Execution.cpp updated: 1.84 -> 1.85
Interpreter.h updated: 1.25 -> 1.26
---
Log message:
Add support for recording arguments passed through the ... of a varargs function
---
Diffs of the changes:
Index: llvm/tools/lli/Interpreter/Execution.cpp
diff -u llvm/tools/lli/Interpreter/Execution.cpp:1.84 llvm/tools/lli/Interpreter/Execution.cpp:1.85
--- llvm/tools/lli/Interpreter/Execution.cpp:1.84 Thu Apr 24 23:21:19 2003
+++ llvm/tools/lli/Interpreter/Execution.cpp Thu May 8 11:06:52 2003
@@ -1038,14 +1038,14 @@
//===----------------------------------------------------------------------===//
// callMethod - Execute the specified function...
//
-void Interpreter::callMethod(Function *M,
+void Interpreter::callMethod(Function *F,
const std::vector<GenericValue> &ArgVals) {
assert((ECStack.empty() || ECStack.back().Caller == 0 ||
ECStack.back().Caller->getNumOperands()-1 == ArgVals.size()) &&
"Incorrect number of arguments passed into function call!");
- if (M->isExternal()) {
- GenericValue Result = callExternalMethod(M, ArgVals);
- const Type *RetTy = M->getReturnType();
+ if (F->isExternal()) {
+ GenericValue Result = callExternalMethod(F, ArgVals);
+ const Type *RetTy = F->getReturnType();
// Copy the result back into the result variable if we are not returning
// void.
@@ -1057,7 +1057,7 @@
SF.Caller = 0; // We returned from the call...
} else if (!QuietMode) {
// print it.
- CW << "Function " << M->getType() << " \"" << M->getName()
+ CW << "Function " << F->getType() << " \"" << F->getName()
<< "\" returned ";
print(RetTy, Result);
std::cout << "\n";
@@ -1074,12 +1074,12 @@
// the function. Also calculate the number of values for each type slot
// active.
//
- MethodInfo *MethInfo = (MethodInfo*)M->getOrCreateAnnotation(MethodInfoAID);
+ MethodInfo *MethInfo = (MethodInfo*)F->getOrCreateAnnotation(MethodInfoAID);
ECStack.push_back(ExecutionContext()); // Make a new stack frame...
ExecutionContext &StackFrame = ECStack.back(); // Fill it in...
- StackFrame.CurMethod = M;
- StackFrame.CurBB = M->begin();
+ StackFrame.CurMethod = F;
+ StackFrame.CurBB = F->begin();
StackFrame.CurInst = StackFrame.CurBB->begin();
StackFrame.MethInfo = MethInfo;
@@ -1097,11 +1097,17 @@
// Run through the function arguments and initialize their values...
- assert(ArgVals.size() == M->asize() &&
+ assert((ArgVals.size() == F->asize() ||
+ (ArgVals.size() > F->asize() && F->getFunctionType()->isVarArg())) &&
"Invalid number of values passed to function invocation!");
+
+ // Handle non-varargs arguments...
unsigned i = 0;
- for (Function::aiterator AI = M->abegin(), E = M->aend(); AI != E; ++AI, ++i)
+ for (Function::aiterator AI = F->abegin(), E = F->aend(); AI != E; ++AI, ++i)
SetValue(AI, ArgVals[i], StackFrame);
+
+ // Handle varargs arguments...
+ StackFrame.VarArgs.assign(ArgVals.begin()+i, ArgVals.end());
}
// executeInstruction - Interpret a single instruction, increment the "PC", and
Index: llvm/tools/lli/Interpreter/Interpreter.h
diff -u llvm/tools/lli/Interpreter/Interpreter.h:1.25 llvm/tools/lli/Interpreter/Interpreter.h:1.26
--- llvm/tools/lli/Interpreter/Interpreter.h:1.25 Mon Dec 23 17:59:41 2002
+++ llvm/tools/lli/Interpreter/Interpreter.h Thu May 8 11:06:52 2003
@@ -68,6 +68,7 @@
BasicBlock::iterator CurInst; // The next instruction to execute
MethodInfo *MethInfo; // The MethInfo annotation for the function
std::vector<ValuePlaneTy> Values;// ValuePlanes for each type
+ std::vector<GenericValue> VarArgs; // Values passed through an ellipsis
BasicBlock *PrevBB; // The previous BB or null if in first BB
CallInst *Caller; // Holds the call that called subframes.
More information about the llvm-commits
mailing list