LLVM  6.0.0svn
CallSite.h
Go to the documentation of this file.
1 //===- CallSite.h - Abstract Call & Invoke instrs ---------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the CallSite class, which is a handy wrapper for code that
11 // wants to treat Call and Invoke instructions in a generic way. When in non-
12 // mutation context (e.g. an analysis) ImmutableCallSite should be used.
13 // Finally, when some degree of customization is necessary between these two
14 // extremes, CallSiteBase<> can be supplied with fine-tuned parameters.
15 //
16 // NOTE: These classes are supposed to have "value semantics". So they should be
17 // passed by value, not by reference; they should not be "new"ed or "delete"d.
18 // They are efficiently copyable, assignable and constructable, with cost
19 // equivalent to copying a pointer (notice that they have only a single data
20 // member). The internal representation carries a flag which indicates which of
21 // the two variants is enclosed. This allows for cheaper checks when various
22 // accessors of CallSite are employed.
23 //
24 //===----------------------------------------------------------------------===//
25 
26 #ifndef LLVM_IR_CALLSITE_H
27 #define LLVM_IR_CALLSITE_H
28 
29 #include "llvm/ADT/Optional.h"
32 #include "llvm/IR/Attributes.h"
33 #include "llvm/IR/CallingConv.h"
34 #include "llvm/IR/Function.h"
35 #include "llvm/IR/InstrTypes.h"
36 #include "llvm/IR/Instruction.h"
37 #include "llvm/IR/Instructions.h"
38 #include "llvm/IR/Intrinsics.h"
39 #include "llvm/IR/Use.h"
40 #include "llvm/IR/User.h"
41 #include "llvm/IR/Value.h"
42 #include "llvm/Support/Casting.h"
43 #include <cassert>
44 #include <cstdint>
45 #include <iterator>
46 
47 namespace llvm {
48 
49 template <typename FunTy = const Function,
50  typename BBTy = const BasicBlock,
51  typename ValTy = const Value,
52  typename UserTy = const User,
53  typename UseTy = const Use,
54  typename InstrTy = const Instruction,
55  typename CallTy = const CallInst,
56  typename InvokeTy = const InvokeInst,
57  typename IterTy = User::const_op_iterator>
58 class CallSiteBase {
59 protected:
61 
62  CallSiteBase() : I(nullptr, false) {}
63  CallSiteBase(CallTy *CI) : I(CI, true) { assert(CI); }
64  CallSiteBase(InvokeTy *II) : I(II, false) { assert(II); }
65  explicit CallSiteBase(ValTy *II) { *this = get(II); }
66 
67 private:
68  /// This static method is like a constructor. It will create an appropriate
69  /// call site for a Call or Invoke instruction, but it can also create a null
70  /// initialized CallSiteBase object for something which is NOT a call site.
71  static CallSiteBase get(ValTy *V) {
72  if (InstrTy *II = dyn_cast<InstrTy>(V)) {
73  if (II->getOpcode() == Instruction::Call)
74  return CallSiteBase(static_cast<CallTy*>(II));
75  else if (II->getOpcode() == Instruction::Invoke)
76  return CallSiteBase(static_cast<InvokeTy*>(II));
77  }
78  return CallSiteBase();
79  }
80 
81 public:
82  /// Return true if a CallInst is enclosed. Note that !isCall() does not mean
83  /// an InvokeInst is enclosed. It may also signify a NULL instruction pointer.
84  bool isCall() const { return I.getInt(); }
85 
86  /// Return true if a InvokeInst is enclosed.
87  bool isInvoke() const { return getInstruction() && !I.getInt(); }
88 
89  InstrTy *getInstruction() const { return I.getPointer(); }
90  InstrTy *operator->() const { return I.getPointer(); }
91  explicit operator bool() const { return I.getPointer(); }
92 
93  /// Get the basic block containing the call site.
94  BBTy* getParent() const { return getInstruction()->getParent(); }
95 
96  /// Return the pointer to function that is being called.
97  ValTy *getCalledValue() const {
98  assert(getInstruction() && "Not a call or invoke instruction!");
99  return *getCallee();
100  }
101 
102  /// Return the function being called if this is a direct call, otherwise
103  /// return null (if it's an indirect call).
104  FunTy *getCalledFunction() const {
105  return dyn_cast<FunTy>(getCalledValue());
106  }
107 
108  /// Return true if the callsite is an indirect call.
109  bool isIndirectCall() const {
110  Value *V = getCalledValue();
111  if (!V)
112  return false;
113  if (isa<FunTy>(V) || isa<Constant>(V))
114  return false;
115  if (CallInst *CI = dyn_cast<CallInst>(getInstruction())) {
116  if (CI->isInlineAsm())
117  return false;
118  }
119  return true;
120  }
121 
122  /// Set the callee to the specified value.
124  assert(getInstruction() && "Not a call or invoke instruction!");
125  *getCallee() = V;
126  }
127 
128  /// Return the intrinsic ID of the intrinsic called by this CallSite,
129  /// or Intrinsic::not_intrinsic if the called function is not an
130  /// intrinsic, or if this CallSite is an indirect call.
132  if (auto *F = getCalledFunction())
133  return F->getIntrinsicID();
134  // Don't use Intrinsic::not_intrinsic, as it will require pulling
135  // Intrinsics.h into every header that uses CallSite.
136  return static_cast<Intrinsic::ID>(0);
137  }
138 
139  /// Determine whether the passed iterator points to the callee operand's Use.
141  return isCallee(&UI.getUse());
142  }
143 
144  /// Determine whether this Use is the callee operand's Use.
145  bool isCallee(const Use *U) const { return getCallee() == U; }
146 
147  /// Determine whether the passed iterator points to an argument operand.
149  return isArgOperand(&UI.getUse());
150  }
151 
152  /// Determine whether the passed use points to an argument operand.
153  bool isArgOperand(const Use *U) const {
154  assert(getInstruction() == U->getUser());
155  return arg_begin() <= U && U < arg_end();
156  }
157 
158  /// Determine whether the passed iterator points to a bundle operand.
160  return isBundleOperand(&UI.getUse());
161  }
162 
163  /// Determine whether the passed use points to a bundle operand.
164  bool isBundleOperand(const Use *U) const {
165  assert(getInstruction() == U->getUser());
166  if (!hasOperandBundles())
167  return false;
168  unsigned OperandNo = U - (*this)->op_begin();
169  return getBundleOperandsStartIndex() <= OperandNo &&
170  OperandNo < getBundleOperandsEndIndex();
171  }
172 
173  /// Determine whether the passed iterator points to a data operand.
175  return isDataOperand(&UI.getUse());
176  }
177 
178  /// Determine whether the passed use points to a data operand.
179  bool isDataOperand(const Use *U) const {
180  return data_operands_begin() <= U && U < data_operands_end();
181  }
182 
183  ValTy *getArgument(unsigned ArgNo) const {
184  assert(arg_begin() + ArgNo < arg_end() && "Argument # out of range!");
185  return *(arg_begin() + ArgNo);
186  }
187 
188  void setArgument(unsigned ArgNo, Value* newVal) {
189  assert(getInstruction() && "Not a call or invoke instruction!");
190  assert(arg_begin() + ArgNo < arg_end() && "Argument # out of range!");
191  getInstruction()->setOperand(ArgNo, newVal);
192  }
193 
194  /// Given a value use iterator, returns the argument that corresponds to it.
195  /// Iterator must actually correspond to an argument.
197  return getArgumentNo(&I.getUse());
198  }
199 
200  /// Given a use for an argument, get the argument number that corresponds to
201  /// it.
202  unsigned getArgumentNo(const Use *U) const {
203  assert(getInstruction() && "Not a call or invoke instruction!");
204  assert(isArgOperand(U) && "Argument # out of range!");
205  return U - arg_begin();
206  }
207 
208  /// The type of iterator to use when looping over actual arguments at this
209  /// call site.
210  using arg_iterator = IterTy;
211 
213  return make_range(arg_begin(), arg_end());
214  }
215  bool arg_empty() const { return arg_end() == arg_begin(); }
216  unsigned arg_size() const { return unsigned(arg_end() - arg_begin()); }
217 
218  /// Given a value use iterator, return the data operand corresponding to it.
219  /// Iterator must actually correspond to a data operand.
221  return getDataOperandNo(&UI.getUse());
222  }
223 
224  /// Given a use for a data operand, get the data operand number that
225  /// corresponds to it.
226  unsigned getDataOperandNo(const Use *U) const {
227  assert(getInstruction() && "Not a call or invoke instruction!");
228  assert(isDataOperand(U) && "Data operand # out of range!");
229  return U - data_operands_begin();
230  }
231 
232  /// Type of iterator to use when looping over data operands at this call site
233  /// (see below).
234  using data_operand_iterator = IterTy;
235 
236  /// data_operands_begin/data_operands_end - Return iterators iterating over
237  /// the call / invoke argument list and bundle operands. For invokes, this is
238  /// the set of instruction operands except the invoke target and the two
239  /// successor blocks; and for calls this is the set of instruction operands
240  /// except the call target.
241 
242  IterTy data_operands_begin() const {
243  assert(getInstruction() && "Not a call or invoke instruction!");
244  return (*this)->op_begin();
245  }
246  IterTy data_operands_end() const {
247  assert(getInstruction() && "Not a call or invoke instruction!");
248  return (*this)->op_end() - (isCall() ? 1 : 3);
249  }
252  }
253  bool data_operands_empty() const {
255  }
256  unsigned data_operands_size() const {
257  return std::distance(data_operands_begin(), data_operands_end());
258  }
259 
260  /// Return the type of the instruction that generated this call site.
261  Type *getType() const { return (*this)->getType(); }
262 
263  /// Return the caller function for this call site.
264  FunTy *getCaller() const { return (*this)->getParent()->getParent(); }
265 
266  /// Tests if this call site must be tail call optimized. Only a CallInst can
267  /// be tail call optimized.
268  bool isMustTailCall() const {
269  return isCall() && cast<CallInst>(getInstruction())->isMustTailCall();
270  }
271 
272  /// Tests if this call site is marked as a tail call.
273  bool isTailCall() const {
274  return isCall() && cast<CallInst>(getInstruction())->isTailCall();
275  }
276 
277 #define CALLSITE_DELEGATE_GETTER(METHOD) \
278  InstrTy *II = getInstruction(); \
279  return isCall() \
280  ? cast<CallInst>(II)->METHOD \
281  : cast<InvokeInst>(II)->METHOD
282 
283 #define CALLSITE_DELEGATE_SETTER(METHOD) \
284  InstrTy *II = getInstruction(); \
285  if (isCall()) \
286  cast<CallInst>(II)->METHOD; \
287  else \
288  cast<InvokeInst>(II)->METHOD
289 
290  unsigned getNumArgOperands() const {
292  }
293 
294  ValTy *getArgOperand(unsigned i) const {
296  }
297 
298  ValTy *getReturnedArgOperand() const {
300  }
301 
302  bool isInlineAsm() const {
303  if (isCall())
304  return cast<CallInst>(getInstruction())->isInlineAsm();
305  return false;
306  }
307 
308  /// Get the calling convention of the call.
311  }
312  /// Set the calling convention of the call.
315  }
316 
319  }
320 
323  }
324 
325  /// Get the parameter attributes of the call.
328  }
329  /// Set the parameter attributes of the call.
332  }
333 
336  }
337 
338  void addAttribute(unsigned i, Attribute Attr) {
340  }
341 
342  void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) {
344  }
345 
348  }
349 
350  void removeAttribute(unsigned i, StringRef Kind) {
352  }
353 
354  void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) {
356  }
357 
358  /// Return true if this function has the given attribute.
361  }
362 
363  /// Return true if this function has the given attribute.
364  bool hasFnAttr(StringRef Kind) const {
366  }
367 
368  /// Return true if this return value has the given attribute.
371  }
372 
373  /// Return true if the call or the callee has the given attribute.
374  bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
376  }
377 
380  }
381 
382  Attribute getAttribute(unsigned i, StringRef Kind) const {
384  }
385 
386  /// Return true if the data operand at index \p i directly or indirectly has
387  /// the attribute \p A.
388  ///
389  /// Normal call or invoke arguments have per operand attributes, as specified
390  /// in the attribute set attached to this instruction, while operand bundle
391  /// operands may have some attributes implied by the type of its containing
392  /// operand bundle.
395  }
396 
397  /// Extract the alignment of the return value.
398  unsigned getRetAlignment() const {
400  }
401 
402  /// Extract the alignment for a call or parameter (0=unknown).
403  unsigned getParamAlignment(unsigned ArgNo) const {
405  }
406 
407  /// Extract the number of dereferenceable bytes for a call or parameter
408  /// (0=unknown).
409  uint64_t getDereferenceableBytes(unsigned i) const {
411  }
412 
413  /// Extract the number of dereferenceable_or_null bytes for a call or
414  /// parameter (0=unknown).
415  uint64_t getDereferenceableOrNullBytes(unsigned i) const {
417  }
418 
419  /// Determine if the return value is marked with NoAlias attribute.
420  bool returnDoesNotAlias() const {
422  }
423 
424  /// Return true if the call should not be treated as a call to a builtin.
425  bool isNoBuiltin() const {
427  }
428 
429  /// Return true if the call should not be inlined.
430  bool isNoInline() const {
432  }
433  void setIsNoInline(bool Value = true) {
435  }
436 
437  /// Determine if the call does not access memory.
438  bool doesNotAccessMemory() const {
440  }
443  }
444 
445  /// Determine if the call does not access or only reads memory.
446  bool onlyReadsMemory() const {
448  }
451  }
452 
453  /// Determine if the call does not access or only writes memory.
454  bool doesNotReadMemory() const {
456  }
459  }
460 
461  /// Determine if the call can access memmory only using pointers based
462  /// on its arguments.
463  bool onlyAccessesArgMemory() const {
465  }
468  }
469 
470  /// Determine if the call cannot return.
471  bool doesNotReturn() const {
473  }
476  }
477 
478  /// Determine if the call cannot unwind.
479  bool doesNotThrow() const {
481  }
484  }
485 
486  /// Determine if the call can be duplicated.
487  bool cannotDuplicate() const {
489  }
492  }
493 
494  /// Determine if the call is convergent.
495  bool isConvergent() const {
497  }
498  void setConvergent() {
500  }
503  }
504 
505  unsigned getNumOperandBundles() const {
507  }
508 
509  bool hasOperandBundles() const {
511  }
512 
513  unsigned getBundleOperandsStartIndex() const {
515  }
516 
517  unsigned getBundleOperandsEndIndex() const {
519  }
520 
521  unsigned getNumTotalBundleOperands() const {
523  }
524 
525  OperandBundleUse getOperandBundleAt(unsigned Index) const {
527  }
528 
531  }
532 
535  }
536 
539  }
540 
541  bool isBundleOperand(unsigned Idx) const {
543  }
544 
545  IterTy arg_begin() const {
547  }
548 
549  IterTy arg_end() const {
551  }
552 
553 #undef CALLSITE_DELEGATE_GETTER
554 #undef CALLSITE_DELEGATE_SETTER
555 
557  const Instruction *II = getInstruction();
558  // Since this is actually a getter that "looks like" a setter, don't use the
559  // above macros to avoid confusion.
560  if (isCall())
561  cast<CallInst>(II)->getOperandBundlesAsDefs(Defs);
562  else
563  cast<InvokeInst>(II)->getOperandBundlesAsDefs(Defs);
564  }
565 
566  /// Determine whether this data operand is not captured.
567  bool doesNotCapture(unsigned OpNo) const {
568  return dataOperandHasImpliedAttr(OpNo + 1, Attribute::NoCapture);
569  }
570 
571  /// Determine whether this argument is passed by value.
572  bool isByValArgument(unsigned ArgNo) const {
573  return paramHasAttr(ArgNo, Attribute::ByVal);
574  }
575 
576  /// Determine whether this argument is passed in an alloca.
577  bool isInAllocaArgument(unsigned ArgNo) const {
578  return paramHasAttr(ArgNo, Attribute::InAlloca);
579  }
580 
581  /// Determine whether this argument is passed by value or in an alloca.
582  bool isByValOrInAllocaArgument(unsigned ArgNo) const {
583  return paramHasAttr(ArgNo, Attribute::ByVal) ||
584  paramHasAttr(ArgNo, Attribute::InAlloca);
585  }
586 
587  /// Determine if there are is an inalloca argument. Only the last argument can
588  /// have the inalloca attribute.
589  bool hasInAllocaArgument() const {
590  return !arg_empty() && paramHasAttr(arg_size() - 1, Attribute::InAlloca);
591  }
592 
593  bool doesNotAccessMemory(unsigned OpNo) const {
594  return dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadNone);
595  }
596 
597  bool onlyReadsMemory(unsigned OpNo) const {
598  return dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadOnly) ||
599  dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadNone);
600  }
601 
602  bool doesNotReadMemory(unsigned OpNo) const {
603  return dataOperandHasImpliedAttr(OpNo + 1, Attribute::WriteOnly) ||
604  dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadNone);
605  }
606 
607  /// Return true if the return value is known to be not null.
608  /// This may be because it has the nonnull attribute, or because at least
609  /// one byte is dereferenceable and the pointer is in addrspace(0).
610  bool isReturnNonNull() const {
611  if (hasRetAttr(Attribute::NonNull))
612  return true;
614  getType()->getPointerAddressSpace() == 0)
615  return true;
616 
617  return false;
618  }
619 
620  /// Returns true if this CallSite passes the given Value* as an argument to
621  /// the called function.
622  bool hasArgument(const Value *Arg) const {
623  for (arg_iterator AI = this->arg_begin(), E = this->arg_end(); AI != E;
624  ++AI)
625  if (AI->get() == Arg)
626  return true;
627  return false;
628  }
629 
630 private:
631  IterTy getCallee() const {
632  if (isCall()) // Skip Callee
633  return cast<CallInst>(getInstruction())->op_end() - 1;
634  else // Skip BB, BB, Callee
635  return cast<InvokeInst>(getInstruction())->op_end() - 3;
636  }
637 };
638 
639 class CallSite : public CallSiteBase<Function, BasicBlock, Value, User, Use,
640  Instruction, CallInst, InvokeInst,
641  User::op_iterator> {
642 public:
643  CallSite() = default;
647  explicit CallSite(Instruction *II) : CallSiteBase(II) {}
648  explicit CallSite(Value *V) : CallSiteBase(V) {}
649 
650  bool operator==(const CallSite &CS) const { return I == CS.I; }
651  bool operator!=(const CallSite &CS) const { return I != CS.I; }
652  bool operator<(const CallSite &CS) const {
653  return getInstruction() < CS.getInstruction();
654  }
655 
656 private:
657  friend struct DenseMapInfo<CallSite>;
658 
659  User::op_iterator getCallee() const;
660 };
661 
662 template <> struct DenseMapInfo<CallSite> {
664 
666  CallSite CS;
667  CS.I = BaseInfo::getEmptyKey();
668  return CS;
669  }
670 
672  CallSite CS;
673  CS.I = BaseInfo::getTombstoneKey();
674  return CS;
675  }
676 
677  static unsigned getHashValue(const CallSite &CS) {
678  return BaseInfo::getHashValue(CS.I);
679  }
680 
681  static bool isEqual(const CallSite &LHS, const CallSite &RHS) {
682  return LHS == RHS;
683  }
684 };
685 
686 /// Establish a view to a call site for examination.
687 class ImmutableCallSite : public CallSiteBase<> {
688 public:
689  ImmutableCallSite() = default;
692  explicit ImmutableCallSite(const Instruction *II) : CallSiteBase(II) {}
693  explicit ImmutableCallSite(const Value *V) : CallSiteBase(V) {}
695 };
696 
697 } // end namespace llvm
698 
699 #endif // LLVM_IR_CALLSITE_H
void setConvergent()
Definition: CallSite.h:498
uint64_t getDereferenceableBytes(unsigned i) const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
Definition: CallSite.h:409
unsigned getArgumentNo(const Use *U) const
Given a use for an argument, get the argument number that corresponds to it.
Definition: CallSite.h:202
ImmutableCallSite(const Value *V)
Definition: CallSite.h:693
ImmutableCallSite(const Instruction *II)
Definition: CallSite.h:692
bool isInlineAsm() const
Definition: CallSite.h:302
static CallSite getEmptyKey()
Definition: CallSite.h:665
unsigned arg_size() const
Definition: CallSite.h:216
CallingConv::ID getCallingConv() const
Get the calling convention of the call.
Definition: CallSite.h:309
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
CallSite(Instruction *II)
Definition: CallSite.h:647
unsigned getParamAlignment(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
Definition: CallSite.h:403
PointerTy getPointer() const
bool operator!=(const CallSite &CS) const
Definition: CallSite.h:651
Various leaf nodes.
Definition: ISDOpcodes.h:60
bool onlyReadsMemory(unsigned OpNo) const
Definition: CallSite.h:597
bool isInAllocaArgument(unsigned ArgNo) const
Determine whether this argument is passed in an alloca.
Definition: CallSite.h:577
bool isBundleOperand(Value::const_user_iterator UI) const
Determine whether the passed iterator points to a bundle operand.
Definition: CallSite.h:159
unsigned getDataOperandNo(const Use *U) const
Given a use for a data operand, get the data operand number that corresponds to it.
Definition: CallSite.h:226
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
Definition: CallSite.h:463
Attribute getAttribute(unsigned i, StringRef Kind) const
Definition: CallSite.h:382
void setDoesNotAccessMemory()
Definition: CallSite.h:441
bool returnDoesNotAlias() const
Determine if the return value is marked with NoAlias attribute.
Definition: CallSite.h:420
#define CALLSITE_DELEGATE_GETTER(METHOD)
Definition: CallSite.h:277
CallSiteBase(ValTy *II)
Definition: CallSite.h:65
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
This class represents a function call, abstracting a target machine&#39;s calling convention.
iterator_range< IterTy > args() const
Definition: CallSite.h:212
Optional< OperandBundleUse > getOperandBundle(uint32_t ID) const
Definition: CallSite.h:533
static unsigned getHashValue(const CallSite &CS)
Definition: CallSite.h:677
bool dataOperandHasImpliedAttr(unsigned i, Attribute::AttrKind Kind) const
Return true if the data operand at index i directly or indirectly has the attribute A...
Definition: CallSite.h:393
unsigned getBundleOperandsEndIndex() const
Definition: CallSite.h:517
uint64_t getDereferenceableOrNullBytes(unsigned i) const
Extract the number of dereferenceable_or_null bytes for a call or parameter (0=unknown).
Definition: CallSite.h:415
bool isCallee(const Use *U) const
Determine whether this Use is the callee operand&#39;s Use.
Definition: CallSite.h:145
CallSiteBase(CallTy *CI)
Definition: CallSite.h:63
bool isIndirectCall() const
Return true if the callsite is an indirect call.
Definition: CallSite.h:109
This defines the Use class.
CallSite(InvokeInst *II)
Definition: CallSite.h:646
bool isNoInline() const
Return true if the call should not be inlined.
Definition: CallSite.h:430
unsigned getBundleOperandsStartIndex() const
Definition: CallSite.h:513
PointerIntPair< InstrTy *, 1, bool > I
Definition: CallSite.h:60
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
Definition: CallSite.h:446
bool arg_empty() const
Definition: CallSite.h:215
bool doesNotReturn() const
Determine if the call cannot return.
Definition: CallSite.h:471
InstrTy * operator->() const
Definition: CallSite.h:90
unsigned data_operands_size() const
Definition: CallSite.h:256
A Use represents the edge between a Value definition and its users.
Definition: Use.h:56
CallSite(Value *V)
Definition: CallSite.h:648
bool isArgOperand(Value::const_user_iterator UI) const
Determine whether the passed iterator points to an argument operand.
Definition: CallSite.h:148
IterTy arg_end() const
Definition: CallSite.h:549
bool isArgOperand(const Use *U) const
Determine whether the passed use points to an argument operand.
Definition: CallSite.h:153
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
This file contains the simple types necessary to represent the attributes associated with functions a...
InstrTy * getInstruction() const
Definition: CallSite.h:89
bool isReturnNonNull() const
Return true if the return value is known to be not null.
Definition: CallSite.h:610
bool hasInAllocaArgument() const
Determine if there are is an inalloca argument.
Definition: CallSite.h:589
void setArgument(unsigned ArgNo, Value *newVal)
Definition: CallSite.h:188
void setOnlyAccessesArgMemory()
Definition: CallSite.h:466
ValTy * getCalledValue() const
Return the pointer to function that is being called.
Definition: CallSite.h:97
IterTy data_operands_end() const
Definition: CallSite.h:246
Class to represent function types.
Definition: DerivedTypes.h:103
#define F(x, y, z)
Definition: MD5.cpp:55
IntType getInt() const
ValTy * getArgOperand(unsigned i) const
Definition: CallSite.h:294
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
Definition: CallSite.h:425
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of the intrinsic called by this CallSite, or Intrinsic::not_intrinsic if the ...
Definition: CallSite.h:131
unsigned getDataOperandNo(Value::const_user_iterator UI) const
Given a value use iterator, return the data operand corresponding to it.
Definition: CallSite.h:220
bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return true if the call or the callee has the given attribute.
Definition: CallSite.h:374
const char * Name
void setDoesNotReadMemory()
Definition: CallSite.h:457
bool isCall() const
Return true if a CallInst is enclosed.
Definition: CallSite.h:84
CallSite(CallSiteBase B)
Definition: CallSite.h:644
Optional< OperandBundleUse > getOperandBundle(StringRef Name) const
Definition: CallSite.h:529
bool isBundleOperand(const Use *U) const
Determine whether the passed use points to a bundle operand.
Definition: CallSite.h:164
void setAttributes(AttributeList PAL)
Set the parameter attributes of the call.
Definition: CallSite.h:330
void setIsNoInline(bool Value=true)
Definition: CallSite.h:433
void addAttribute(unsigned i, Attribute Attr)
Definition: CallSite.h:338
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if this function has the given attribute.
Definition: CallSite.h:359
bool doesNotReadMemory(unsigned OpNo) const
Definition: CallSite.h:602
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Definition: CallSite.h:354
bool hasOperandBundles() const
Definition: CallSite.h:509
unsigned getNumTotalBundleOperands() const
Definition: CallSite.h:521
void setCallingConv(CallingConv::ID CC)
Set the calling convention of the call.
Definition: CallSite.h:313
bool isDataOperand(const Use *U) const
Determine whether the passed use points to a data operand.
Definition: CallSite.h:179
CallSite(CallInst *CI)
Definition: CallSite.h:645
bool isDataOperand(Value::const_user_iterator UI) const
Determine whether the passed iterator points to a data operand.
Definition: CallSite.h:174
bool hasFnAttr(StringRef Kind) const
Return true if this function has the given attribute.
Definition: CallSite.h:364
bool operator<(const CallSite &CS) const
Definition: CallSite.h:652
void setNotConvergent()
Definition: CallSite.h:501
bool doesNotCapture(unsigned OpNo) const
Determine whether this data operand is not captured.
Definition: CallSite.h:567
bool hasArgument(const Value *Arg) const
Returns true if this CallSite passes the given Value* as an argument to the called function...
Definition: CallSite.h:622
unsigned getNumArgOperands() const
Definition: CallSite.h:290
Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const
Definition: CallSite.h:378
ImmutableCallSite(CallSite CS)
Definition: CallSite.h:694
static bool isEqual(const CallSite &LHS, const CallSite &RHS)
Definition: CallSite.h:681
bool doesNotAccessMemory(unsigned OpNo) const
Definition: CallSite.h:593
bool isInvoke() const
Return true if a InvokeInst is enclosed.
Definition: CallSite.h:87
void setCannotDuplicate()
Definition: CallSite.h:490
static CallSite getTombstoneKey()
Definition: CallSite.h:671
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool data_operands_empty() const
Definition: CallSite.h:253
bool doesNotReadMemory() const
Determine if the call does not access or only writes memory.
Definition: CallSite.h:454
#define E
Definition: LargeTest.cpp:27
#define B
Definition: LargeTest.cpp:24
ValTy * getArgument(unsigned ArgNo) const
Definition: CallSite.h:183
OperandBundleUse getOperandBundleAt(unsigned Index) const
Definition: CallSite.h:525
void removeAttribute(unsigned i, StringRef Kind)
Definition: CallSite.h:350
IterTy arg_begin() const
Definition: CallSite.h:545
ImmutableCallSite(const InvokeInst *II)
Definition: CallSite.h:691
void setDoesNotThrow()
Definition: CallSite.h:482
IterTy data_operands_begin() const
data_operands_begin/data_operands_end - Return iterators iterating over the call / invoke argument li...
Definition: CallSite.h:242
BBTy * getParent() const
Get the basic block containing the call site.
Definition: CallSite.h:94
A range adaptor for a pair of iterators.
ImmutableCallSite(const CallInst *CI)
Definition: CallSite.h:690
bool isBundleOperand(unsigned Idx) const
Definition: CallSite.h:541
void setDoesNotReturn()
Definition: CallSite.h:474
A lightweight accessor for an operand bundle meant to be passed around by value.
Definition: InstrTypes.h:1169
void addAttribute(unsigned i, Attribute::AttrKind Kind)
Definition: CallSite.h:334
bool operator==(const CallSite &CS) const
Definition: CallSite.h:650
bool doesNotAccessMemory() const
Determine if the call does not access memory.
Definition: CallSite.h:438
user_iterator_impl< const User > const_user_iterator
Definition: Value.h:365
could "use" a pointer
unsigned countOperandBundlesOfType(uint32_t ID) const
Definition: CallSite.h:537
Basic Alias true
FunTy * getCaller() const
Return the caller function for this call site.
Definition: CallSite.h:264
unsigned getNumOperandBundles() const
Definition: CallSite.h:505
bool cannotDuplicate() const
Determine if the call can be duplicated.
Definition: CallSite.h:487
#define CALLSITE_DELEGATE_SETTER(METHOD)
Definition: CallSite.h:283
CallSiteBase(InvokeTy *II)
Definition: CallSite.h:64
void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Definition: CallSite.h:556
iterator_range< IterTy > data_ops() const
Definition: CallSite.h:250
const Use * const_op_iterator
Definition: User.h:210
Establish a view to a call site for examination.
Definition: CallSite.h:687
bool doesNotThrow() const
Determine if the call cannot unwind.
Definition: CallSite.h:479
void removeAttribute(unsigned i, Attribute::AttrKind Kind)
Definition: CallSite.h:346
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:323
bool isByValOrInAllocaArgument(unsigned ArgNo) const
Determine whether this argument is passed by value or in an alloca.
Definition: CallSite.h:582
Type * getType() const
Return the type of the instruction that generated this call site.
Definition: CallSite.h:261
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
Definition: CallSite.h:572
FunTy * getCalledFunction() const
Return the function being called if this is a direct call, otherwise return null (if it&#39;s an indirect...
Definition: CallSite.h:104
const unsigned Kind
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getRetAlignment() const
Extract the alignment of the return value.
Definition: CallSite.h:398
bool isTailCall() const
Tests if this call site is marked as a tail call.
Definition: CallSite.h:273
bool hasRetAttr(Attribute::AttrKind Kind) const
Return true if this return value has the given attribute.
Definition: CallSite.h:369
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:545
LLVM Value Representation.
Definition: Value.h:73
FunctionType * getFunctionType() const
Definition: CallSite.h:317
void setOnlyReadsMemory()
Definition: CallSite.h:449
unsigned getArgumentNo(Value::const_user_iterator I) const
Given a value use iterator, returns the argument that corresponds to it.
Definition: CallSite.h:196
Invoke instruction.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
AttributeList getAttributes() const
Get the parameter attributes of the call.
Definition: CallSite.h:326
bool isConvergent() const
Determine if the call is convergent.
Definition: CallSite.h:495
ValTy * getReturnedArgOperand() const
Definition: CallSite.h:298
bool isMustTailCall() const
Tests if this call site must be tail call optimized.
Definition: CallSite.h:268
void setCalledFunction(Value *V)
Set the callee to the specified value.
Definition: CallSite.h:123
void mutateFunctionType(FunctionType *Ty) const
Definition: CallSite.h:321
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Definition: CallSite.h:342
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...
Definition: Attributes.h:70
bool isCallee(Value::const_user_iterator UI) const
Determine whether the passed iterator points to the callee operand&#39;s Use.
Definition: CallSite.h:140