[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Fri Nov 7 14:46:02 PST 2003
Changes in directory llvm/lib/ExecutionEngine/Interpreter:
Execution.cpp updated: 1.111 -> 1.112
---
Log message:
popStackAndReturnValueToCaller() must advance instruction pointer to normal
destination, if returning from an invoke.
Implement 'unwind' instruction.
---
Diffs of the changes: (+24 -5)
Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.111 llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.112
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.111 Fri Nov 7 14:07:05 2003
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Fri Nov 7 14:44:58 2003
@@ -435,8 +435,10 @@
/// 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
-/// CallInst if there was a previous stack frame. This procedure may
-/// invalidate any ECStack iterators you have.
+/// 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
+/// from an invoke.
///
void Interpreter::popStackAndReturnValueToCaller (const Type *RetTy,
GenericValue Result) {
@@ -453,9 +455,11 @@
// If we have a previous stack frame, and we have a previous call,
// fill in the return value...
ExecutionContext &CallingSF = ECStack.back();
- if (CallingSF.Caller.getInstruction()) {
+ if (Instruction *I = CallingSF.Caller.getInstruction()) {
if (CallingSF.Caller.getType() != Type::VoidTy) // Save result...
- SetValue(CallingSF.Caller.getInstruction(), Result, CallingSF);
+ SetValue(I, Result, CallingSF);
+ if (InvokeInst *II = dyn_cast<InvokeInst> (I))
+ SwitchToNewBasicBlock (II->getNormalDest (), CallingSF);
CallingSF.Caller = CallSite(); // We returned from the call...
}
}
@@ -476,7 +480,22 @@
}
void Interpreter::visitUnwindInst(UnwindInst &I) {
- abort ();
+ // Unwind stack
+ Instruction *Inst;
+ do {
+ ECStack.pop_back ();
+ if (ECStack.empty ())
+ abort ();
+ Inst = ECStack.back ().Caller.getInstruction ();
+ } while (!(Inst && isa<InvokeInst> (Inst)));
+
+ // Return from invoke
+ ExecutionContext &InvokingSF = ECStack.back ();
+ InvokingSF.Caller = CallSite ();
+
+ // Go to exceptional destination BB of invoke instruction
+ SwitchToNewBasicBlock (cast<InvokeInst> (Inst)->getExceptionalDest (),
+ InvokingSF);
}
void Interpreter::visitBranchInst(BranchInst &I) {
More information about the llvm-commits
mailing list