diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index 3e7a3e72b09..98213c882df 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -866,16 +866,19 @@ void Interpreter::visitCallSite(CallSite CS) { // If it is an unknown intrinsic function, use the intrinsic lowering // class to transform it into hopefully tasty LLVM code. // - Instruction *Prev = CS.getInstruction()->getPrev(); + BasicBlock::iterator me(CS.getInstruction()); BasicBlock *Parent = CS.getInstruction()->getParent(); + bool atBegin(Parent->begin() == me); + if (!atBegin) + --me; IL->LowerIntrinsicCall(cast(CS.getInstruction())); // Restore the CurInst pointer to the first instruction newly inserted, if // any. - if (!Prev) { + if (atBegin) { SF.CurInst = Parent->begin(); } else { - SF.CurInst = Prev; + SF.CurInst = me; ++SF.CurInst; } return;