@@ -902,13 +902,13 @@ void Interpreter::popStackAndReturnValueToCaller(Type *RetTy,
902902 // If we have a previous stack frame, and we have a previous call,
903903 // fill in the return value...
904904 ExecutionContext &CallingSF = ECStack.back ();
905- if (Instruction *I = CallingSF.Caller . getInstruction () ) {
905+ if (CallingSF.Caller ) {
906906 // Save result...
907- if (!CallingSF.Caller . getType ()->isVoidTy ())
908- SetValue (I , Result, CallingSF);
909- if (InvokeInst *II = dyn_cast<InvokeInst> (I ))
907+ if (!CallingSF.Caller -> getType ()->isVoidTy ())
908+ SetValue (CallingSF. Caller , Result, CallingSF);
909+ if (InvokeInst *II = dyn_cast<InvokeInst>(CallingSF. Caller ))
910910 SwitchToNewBasicBlock (II->getNormalDest (), CallingSF);
911- CallingSF.Caller = CallSite (); // We returned from the call...
911+ CallingSF.Caller = nullptr ; // We returned from the call...
912912 }
913913 }
914914}
@@ -1113,64 +1113,59 @@ void Interpreter::visitStoreInst(StoreInst &I) {
11131113// Miscellaneous Instruction Implementations
11141114// ===----------------------------------------------------------------------===//
11151115
1116- void Interpreter::visitCallSite (CallSite CS ) {
1116+ void Interpreter::visitVAStartInst (VAStartInst &I ) {
11171117 ExecutionContext &SF = ECStack.back ();
1118+ GenericValue ArgIndex;
1119+ ArgIndex.UIntPairVal .first = ECStack.size () - 1 ;
1120+ ArgIndex.UIntPairVal .second = 0 ;
1121+ SetValue (&I, ArgIndex, SF);
1122+ }
11181123
1119- // Check to see if this is an intrinsic function call...
1120- Function *F = CS.getCalledFunction ();
1121- if (F && F->isDeclaration ())
1122- switch (F->getIntrinsicID ()) {
1123- case Intrinsic::not_intrinsic:
1124- break ;
1125- case Intrinsic::vastart: { // va_start
1126- GenericValue ArgIndex;
1127- ArgIndex.UIntPairVal .first = ECStack.size () - 1 ;
1128- ArgIndex.UIntPairVal .second = 0 ;
1129- SetValue (CS.getInstruction (), ArgIndex, SF);
1130- return ;
1131- }
1132- case Intrinsic::vaend: // va_end is a noop for the interpreter
1133- return ;
1134- case Intrinsic::vacopy: // va_copy: dest = src
1135- SetValue (CS.getInstruction (), getOperandValue (*CS.arg_begin (), SF), SF);
1136- return ;
1137- default :
1138- // If it is an unknown intrinsic function, use the intrinsic lowering
1139- // class to transform it into hopefully tasty LLVM code.
1140- //
1141- BasicBlock::iterator me (CS.getInstruction ());
1142- BasicBlock *Parent = CS.getInstruction ()->getParent ();
1143- bool atBegin (Parent->begin () == me);
1144- if (!atBegin)
1145- --me;
1146- IL->LowerIntrinsicCall (cast<CallInst>(CS.getInstruction ()));
1147-
1148- // Restore the CurInst pointer to the first instruction newly inserted, if
1149- // any.
1150- if (atBegin) {
1151- SF.CurInst = Parent->begin ();
1152- } else {
1153- SF.CurInst = me;
1154- ++SF.CurInst ;
1155- }
1156- return ;
1157- }
1124+ void Interpreter::visitVAEndInst (VAEndInst &I) {
1125+ // va_end is a noop for the interpreter
1126+ }
11581127
1128+ void Interpreter::visitVACopyInst (VACopyInst &I) {
1129+ ExecutionContext &SF = ECStack.back ();
1130+ SetValue (&I, getOperandValue (*I.arg_begin (), SF), SF);
1131+ }
11591132
1160- SF.Caller = CS;
1133+ void Interpreter::visitIntrinsicInst (IntrinsicInst &I) {
1134+ ExecutionContext &SF = ECStack.back ();
1135+
1136+ // If it is an unknown intrinsic function, use the intrinsic lowering
1137+ // class to transform it into hopefully tasty LLVM code.
1138+ //
1139+ BasicBlock::iterator Me (&I);
1140+ BasicBlock *Parent = I.getParent ();
1141+ bool atBegin (Parent->begin () == Me);
1142+ if (!atBegin)
1143+ --Me;
1144+ IL->LowerIntrinsicCall (&I);
1145+
1146+ // Restore the CurInst pointer to the first instruction newly inserted, if
1147+ // any.
1148+ if (atBegin) {
1149+ SF.CurInst = Parent->begin ();
1150+ } else {
1151+ SF.CurInst = Me;
1152+ ++SF.CurInst ;
1153+ }
1154+ }
1155+
1156+ void Interpreter::visitCallBase (CallBase &I) {
1157+ ExecutionContext &SF = ECStack.back ();
1158+
1159+ SF.Caller = &I;
11611160 std::vector<GenericValue> ArgVals;
1162- const unsigned NumArgs = SF.Caller . arg_size ();
1161+ const unsigned NumArgs = SF.Caller -> arg_size ();
11631162 ArgVals.reserve (NumArgs);
1164- uint16_t pNum = 1 ;
1165- for (CallSite::arg_iterator i = SF.Caller .arg_begin (),
1166- e = SF.Caller .arg_end (); i != e; ++i, ++pNum) {
1167- Value *V = *i;
1163+ for (Value *V : SF.Caller ->args ())
11681164 ArgVals.push_back (getOperandValue (V, SF));
1169- }
11701165
11711166 // To handle indirect calls, we must get the pointer value from the argument
11721167 // and treat it as a function pointer.
1173- GenericValue SRC = getOperandValue (SF.Caller . getCalledValue (), SF);
1168+ GenericValue SRC = getOperandValue (SF.Caller -> getCalledValue (), SF);
11741169 callFunction ((Function*)GVTOP (SRC), ArgVals);
11751170}
11761171
@@ -2120,8 +2115,8 @@ GenericValue Interpreter::getOperandValue(Value *V, ExecutionContext &SF) {
21202115// callFunction - Execute the specified function...
21212116//
21222117void Interpreter::callFunction (Function *F, ArrayRef<GenericValue> ArgVals) {
2123- assert ((ECStack.empty () || !ECStack.back ().Caller . getInstruction () ||
2124- ECStack.back ().Caller . arg_size () == ArgVals.size ()) &&
2118+ assert ((ECStack.empty () || !ECStack.back ().Caller ||
2119+ ECStack.back ().Caller -> arg_size () == ArgVals.size ()) &&
21252120 " Incorrect number of arguments passed into function call!" );
21262121 // Make a new stack frame... and fill it in.
21272122 ECStack.emplace_back ();
0 commit comments