/// arguments at this call site.
typedef IterTy arg_iterator;
- /// arg_begin/arg_end - Return iterators corresponding to the actual argument
- /// list for a call site.
- IterTy arg_begin() const {
- assert(getInstruction() && "Not a call or invoke instruction!");
- // Skip non-arguments
- return (*this)->op_begin();
- }
-
- IterTy arg_end() const { return (*this)->op_end() - getArgumentEndOffset(); }
iterator_range<IterTy> args() const {
return make_range(arg_begin(), arg_end());
}
CALLSITE_DELEGATE_GETTER(getOperandBundle(ID));
}
+ IterTy arg_begin() const {
+ CALLSITE_DELEGATE_GETTER(arg_begin());
+ }
+
+ IterTy arg_end() const {
+ CALLSITE_DELEGATE_GETTER(arg_end());
+ }
+
#undef CALLSITE_DELEGATE_GETTER
#undef CALLSITE_DELEGATE_SETTER
}
private:
- unsigned getArgumentEndOffset() const {
- if (isCall()) {
- // Skip [ operand bundles ], Callee
- auto *CI = cast<CallInst>(getInstruction());
- return 1 + CI->getNumTotalBundleOperands();
- } else {
- // Skip [ operand bundles ], BB, BB, Callee
- auto *II = cast<InvokeInst>(getInstruction());
- return 3 + II->getNumTotalBundleOperands();
- }
- }
-
IterTy getCallee() const {
if (isCall()) // Skip Callee
return cast<CallInst>(getInstruction())->op_end() - 1;
setOperand(i, v);
}
- /// arg_operands - iteration adapter for range-for loops.
+ /// \brief Return the iterator pointing to the beginning of the argument list.
+ op_iterator arg_begin() { return op_begin(); }
+
+ /// \brief Return the iterator pointing to the end of the argument list.
+ op_iterator arg_end() {
+ // [ call args ], [ operand bundles ], callee
+ return op_end() - getNumTotalBundleOperands() - 1;
+ };
+
+ /// \brief Iteration adapter for range-for loops.
iterator_range<op_iterator> arg_operands() {
- // The last operand in the op list is the callee - it's not one of the args
- // so we don't want to iterate over it.
- return make_range(op_begin(), op_end() - getNumTotalBundleOperands() - 1);
+ return make_range(arg_begin(), arg_end());
}
- /// arg_operands - iteration adapter for range-for loops.
+ /// \brief Return the iterator pointing to the beginning of the argument list.
+ const_op_iterator arg_begin() const { return op_begin(); }
+
+ /// \brief Return the iterator pointing to the end of the argument list.
+ const_op_iterator arg_end() const {
+ // [ call args ], [ operand bundles ], callee
+ return op_end() - getNumTotalBundleOperands() - 1;
+ };
+
+ /// \brief Iteration adapter for range-for loops.
iterator_range<const_op_iterator> arg_operands() const {
- return make_range(op_begin(), op_end() - getNumTotalBundleOperands() - 1);
+ return make_range(arg_begin(), arg_end());
}
/// \brief Wrappers for getting the \c Use of a call argument.
setOperand(i, v);
}
- /// arg_operands - iteration adapter for range-for loops.
+ /// \brief Return the iterator pointing to the beginning of the argument list.
+ op_iterator arg_begin() { return op_begin(); }
+
+ /// \brief Return the iterator pointing to the end of the argument list.
+ op_iterator arg_end() {
+ // [ invoke args ], [ operand bundles ], normal dest, unwind dest, callee
+ return op_end() - getNumTotalBundleOperands() - 3;
+ };
+
+ /// \brief Iteration adapter for range-for loops.
iterator_range<op_iterator> arg_operands() {
- return make_range(op_begin(), op_end() - getNumTotalBundleOperands() - 3);
+ return make_range(arg_begin(), arg_end());
}
- /// arg_operands - iteration adapter for range-for loops.
+ /// \brief Return the iterator pointing to the beginning of the argument list.
+ const_op_iterator arg_begin() const { return op_begin(); }
+
+ /// \brief Return the iterator pointing to the end of the argument list.
+ const_op_iterator arg_end() const {
+ // [ invoke args ], [ operand bundles ], normal dest, unwind dest, callee
+ return op_end() - getNumTotalBundleOperands() - 3;
+ };
+
+ /// \brief Iteration adapter for range-for loops.
iterator_range<const_op_iterator> arg_operands() const {
- return make_range(op_begin(), op_end() - getNumTotalBundleOperands() - 3);
+ return make_range(arg_begin(), arg_end());
}
/// \brief Wrappers for getting the \c Use of a invoke argument.
CallInst *CallInst::Create(CallInst *CI, ArrayRef<OperandBundleDef> OpB,
Instruction *InsertPt) {
- CallSite CS(CI);
- std::vector<Value *> Args(CS.arg_begin(), CS.arg_end());
+ std::vector<Value *> Args(CI->arg_begin(), CI->arg_end());
auto *NewCI = CallInst::Create(CI->getCalledValue(), Args, OpB, CI->getName(),
InsertPt);
InvokeInst *InvokeInst::Create(InvokeInst *II, ArrayRef<OperandBundleDef> OpB,
Instruction *InsertPt) {
- CallSite CS(II);
- std::vector<Value *> Args(CS.arg_begin(), CS.arg_end());
+ std::vector<Value *> Args(II->arg_begin(), II->arg_end());
auto *NewII = InvokeInst::Create(II->getCalledValue(), II->getNormalDest(),
II->getUnwindDest(), Args, OpB,
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
if (InvokeInst *II = dyn_cast<InvokeInst>(BB->getTerminator()))
if (II->doesNotThrow() && canSimplifyInvokeNoUnwind(F)) {
- CallSite CS(II);
- SmallVector<Value*, 8> Args(CS.arg_begin(), CS.arg_end());
+ SmallVector<Value*, 8> Args(II->arg_begin(), II->arg_end());
SmallVector<OperandBundleDef, 1> OpBundles;
II->getOperandBundlesAsDefs(OpBundles);
BB->getInstList().pop_back();
// Create the new invoke instruction.
- ImmutableCallSite CS(CI);
- SmallVector<Value*, 8> InvokeArgs(CS.arg_begin(), CS.arg_end());
+ SmallVector<Value*, 8> InvokeArgs(CI->arg_begin(), CI->arg_end());
SmallVector<OperandBundleDef, 1> OpBundles;
- CS.getOperandBundlesAsDefs(OpBundles);
+ CI->getOperandBundlesAsDefs(OpBundles);
// Note: we're round tripping operand bundles through memory here, and that
// can potentially be avoided with a cleverer API design that we do not have
/// changeToCall - Convert the specified invoke into a normal call.
static void changeToCall(InvokeInst *II) {
- CallSite CS(II);
- SmallVector<Value*, 8> Args(CS.arg_begin(), CS.arg_end());
+ SmallVector<Value*, 8> Args(II->arg_begin(), II->arg_end());
SmallVector<OperandBundleDef, 1> OpBundles;
II->getOperandBundlesAsDefs(OpBundles);
CallInst *NewCall = CallInst::Create(II->getCalledValue(), Args, OpBundles,