LLVM  4.0.0
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 
30 #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/Support/Casting.h"
40 #include "llvm/IR/Use.h"
41 #include "llvm/IR/User.h"
42 #include "llvm/IR/Value.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  /// CallSiteBase::get - This static method is sort of like a constructor. It
69  /// will create an appropriate call site for a Call or Invoke instruction, but
70  /// it can also create a null initialized CallSiteBase object for something
71  /// which is NOT a call site.
72  ///
73  static CallSiteBase get(ValTy *V) {
74  if (InstrTy *II = dyn_cast<InstrTy>(V)) {
75  if (II->getOpcode() == Instruction::Call)
76  return CallSiteBase(static_cast<CallTy*>(II));
77  else if (II->getOpcode() == Instruction::Invoke)
78  return CallSiteBase(static_cast<InvokeTy*>(II));
79  }
80  return CallSiteBase();
81  }
82 
83 public:
84  /// isCall - true if a CallInst is enclosed.
85  /// Note that !isCall() does not mean it is an InvokeInst enclosed,
86  /// it also could signify a NULL Instruction pointer.
87  bool isCall() const { return I.getInt(); }
88 
89  /// isInvoke - true if a InvokeInst is enclosed.
90  ///
91  bool isInvoke() const { return getInstruction() && !I.getInt(); }
92 
93  InstrTy *getInstruction() const { return I.getPointer(); }
94  InstrTy *operator->() const { return I.getPointer(); }
95  explicit operator bool() const { return I.getPointer(); }
96 
97  /// Get the basic block containing the call site
98  BBTy* getParent() const { return getInstruction()->getParent(); }
99 
100  /// getCalledValue - Return the pointer to function that is being called.
101  ///
102  ValTy *getCalledValue() const {
103  assert(getInstruction() && "Not a call or invoke instruction!");
104  return *getCallee();
105  }
106 
107  /// getCalledFunction - Return the function being called if this is a direct
108  /// call, otherwise return null (if it's an indirect call).
109  ///
110  FunTy *getCalledFunction() const {
111  return dyn_cast<FunTy>(getCalledValue());
112  }
113 
114  /// setCalledFunction - Set the callee to the specified value.
115  ///
117  assert(getInstruction() && "Not a call or invoke instruction!");
118  *getCallee() = V;
119  }
120 
121  /// Return the intrinsic ID of the intrinsic called by this CallSite,
122  /// or Intrinsic::not_intrinsic if the called function is not an
123  /// intrinsic, or if this CallSite is an indirect call.
125  if (auto *F = getCalledFunction())
126  return F->getIntrinsicID();
127  // Don't use Intrinsic::not_intrinsic, as it will require pulling
128  // Intrinsics.h into every header that uses CallSite.
129  return static_cast<Intrinsic::ID>(0);
130  }
131 
132  /// isCallee - Determine whether the passed iterator points to the
133  /// callee operand's Use.
135  return isCallee(&UI.getUse());
136  }
137 
138  /// Determine whether this Use is the callee operand's Use.
139  bool isCallee(const Use *U) const { return getCallee() == U; }
140 
141  /// \brief Determine whether the passed iterator points to an argument
142  /// operand.
144  return isArgOperand(&UI.getUse());
145  }
146 
147  /// \brief Determine whether the passed use points to an argument operand.
148  bool isArgOperand(const Use *U) const {
149  assert(getInstruction() == U->getUser());
150  return arg_begin() <= U && U < arg_end();
151  }
152 
153  /// \brief Determine whether the passed iterator points to a bundle operand.
155  return isBundleOperand(&UI.getUse());
156  }
157 
158  /// \brief Determine whether the passed use points to a bundle operand.
159  bool isBundleOperand(const Use *U) const {
160  assert(getInstruction() == U->getUser());
161  if (!hasOperandBundles())
162  return false;
163  unsigned OperandNo = U - (*this)->op_begin();
164  return getBundleOperandsStartIndex() <= OperandNo &&
165  OperandNo < getBundleOperandsEndIndex();
166  }
167 
168  /// \brief Determine whether the passed iterator points to a data operand.
170  return isDataOperand(&UI.getUse());
171  }
172 
173  /// \brief Determine whether the passed use points to a data operand.
174  bool isDataOperand(const Use *U) const {
175  return data_operands_begin() <= U && U < data_operands_end();
176  }
177 
178  ValTy *getArgument(unsigned ArgNo) const {
179  assert(arg_begin() + ArgNo < arg_end() && "Argument # out of range!");
180  return *(arg_begin() + ArgNo);
181  }
182 
183  void setArgument(unsigned ArgNo, Value* newVal) {
184  assert(getInstruction() && "Not a call or invoke instruction!");
185  assert(arg_begin() + ArgNo < arg_end() && "Argument # out of range!");
186  getInstruction()->setOperand(ArgNo, newVal);
187  }
188 
189  /// Given a value use iterator, returns the argument that corresponds to it.
190  /// Iterator must actually correspond to an argument.
192  return getArgumentNo(&I.getUse());
193  }
194 
195  /// Given a use for an argument, get the argument number that corresponds to
196  /// it.
197  unsigned getArgumentNo(const Use *U) const {
198  assert(getInstruction() && "Not a call or invoke instruction!");
199  assert(isArgOperand(U) && "Argument # out of range!");
200  return U - arg_begin();
201  }
202 
203  /// arg_iterator - The type of iterator to use when looping over actual
204  /// arguments at this call site.
205  typedef IterTy arg_iterator;
206 
208  return make_range(arg_begin(), arg_end());
209  }
210  bool arg_empty() const { return arg_end() == arg_begin(); }
211  unsigned arg_size() const { return unsigned(arg_end() - arg_begin()); }
212 
213  /// Given a value use iterator, returns the data operand that corresponds to
214  /// it.
215  /// Iterator must actually correspond to a data operand.
217  return getDataOperandNo(&UI.getUse());
218  }
219 
220  /// Given a use for a data operand, get the data operand number that
221  /// corresponds to it.
222  unsigned getDataOperandNo(const Use *U) const {
223  assert(getInstruction() && "Not a call or invoke instruction!");
224  assert(isDataOperand(U) && "Data operand # out of range!");
225  return U - data_operands_begin();
226  }
227 
228  /// Type of iterator to use when looping over data operands at this call site
229  /// (see below).
230  typedef IterTy data_operand_iterator;
231 
232  /// data_operands_begin/data_operands_end - Return iterators iterating over
233  /// the call / invoke argument list and bundle operands. For invokes, this is
234  /// the set of instruction operands except the invoke target and the two
235  /// successor blocks; and for calls this is the set of instruction operands
236  /// except the call target.
237 
238  IterTy data_operands_begin() const {
239  assert(getInstruction() && "Not a call or invoke instruction!");
240  return (*this)->op_begin();
241  }
242  IterTy data_operands_end() const {
243  assert(getInstruction() && "Not a call or invoke instruction!");
244  return (*this)->op_end() - (isCall() ? 1 : 3);
245  }
248  }
249  bool data_operands_empty() const {
251  }
252  unsigned data_operands_size() const {
253  return std::distance(data_operands_begin(), data_operands_end());
254  }
255 
256  /// getType - Return the type of the instruction that generated this call site
257  ///
258  Type *getType() const { return (*this)->getType(); }
259 
260  /// getCaller - Return the caller function for this call site
261  ///
262  FunTy *getCaller() const { return (*this)->getParent()->getParent(); }
263 
264  /// \brief Tests if this call site must be tail call optimized. Only a
265  /// CallInst can be tail call optimized.
266  bool isMustTailCall() const {
267  return isCall() && cast<CallInst>(getInstruction())->isMustTailCall();
268  }
269 
270  /// \brief Tests if this call site is marked as a tail call.
271  bool isTailCall() const {
272  return isCall() && cast<CallInst>(getInstruction())->isTailCall();
273  }
274 
275 #define CALLSITE_DELEGATE_GETTER(METHOD) \
276  InstrTy *II = getInstruction(); \
277  return isCall() \
278  ? cast<CallInst>(II)->METHOD \
279  : cast<InvokeInst>(II)->METHOD
280 
281 #define CALLSITE_DELEGATE_SETTER(METHOD) \
282  InstrTy *II = getInstruction(); \
283  if (isCall()) \
284  cast<CallInst>(II)->METHOD; \
285  else \
286  cast<InvokeInst>(II)->METHOD
287 
288  unsigned getNumArgOperands() const {
290  }
291 
292  ValTy *getArgOperand(unsigned i) const {
294  }
295 
296  ValTy *getReturnedArgOperand() const {
298  }
299 
300  bool isInlineAsm() const {
301  if (isCall())
302  return cast<CallInst>(getInstruction())->isInlineAsm();
303  return false;
304  }
305 
306  /// getCallingConv/setCallingConv - get or set the calling convention of the
307  /// call.
310  }
313  }
314 
317  }
318 
321  }
322 
323  /// getAttributes/setAttributes - get or set the parameter attributes of
324  /// the call.
327  }
330  }
331 
334  }
335 
336  void addAttribute(unsigned i, Attribute Attr) {
338  }
339 
342  }
343 
344  void removeAttribute(unsigned i, StringRef Kind) {
346  }
347 
348  /// \brief Return true if this function has the given attribute.
351  }
352 
353  /// \brief Return true if this function has the given attribute.
354  bool hasFnAttr(StringRef Kind) const {
356  }
357 
358  /// \brief Return true if the call or the callee has the given attribute.
359  bool paramHasAttr(unsigned i, Attribute::AttrKind Kind) const {
361  }
362 
365  }
366 
367  Attribute getAttribute(unsigned i, StringRef Kind) const {
369  }
370 
371  /// \brief Return true if the data operand at index \p i directly or
372  /// indirectly has the attribute \p A.
373  ///
374  /// Normal call or invoke arguments have per operand attributes, as specified
375  /// in the attribute set attached to this instruction, while operand bundle
376  /// operands may have some attributes implied by the type of its containing
377  /// operand bundle.
380  }
381 
382  /// @brief Extract the alignment for a call or parameter (0=unknown).
383  uint16_t getParamAlignment(uint16_t i) const {
385  }
386 
387  /// @brief Extract the number of dereferenceable bytes for a call or
388  /// parameter (0=unknown).
389  uint64_t getDereferenceableBytes(uint16_t i) const {
391  }
392 
393  /// @brief Extract the number of dereferenceable_or_null bytes for a call or
394  /// parameter (0=unknown).
395  uint64_t getDereferenceableOrNullBytes(uint16_t i) const {
397  }
398 
399  /// @brief Determine if the parameter or return value is marked with NoAlias
400  /// attribute.
401  /// @param n The parameter to check. 1 is the first parameter, 0 is the return
402  bool doesNotAlias(unsigned n) const {
404  }
405 
406  /// \brief Return true if the call should not be treated as a call to a
407  /// builtin.
408  bool isNoBuiltin() const {
410  }
411 
412  /// @brief Return true if the call should not be inlined.
413  bool isNoInline() const {
415  }
416  void setIsNoInline(bool Value = true) {
418  }
419 
420  /// @brief Determine if the call does not access memory.
421  bool doesNotAccessMemory() const {
423  }
426  }
427 
428  /// @brief Determine if the call does not access or only reads memory.
429  bool onlyReadsMemory() const {
431  }
434  }
435 
436  /// @brief Determine if the call does not access or only writes memory.
437  bool doesNotReadMemory() const {
439  }
442  }
443 
444  /// @brief Determine if the call can access memmory only using pointers based
445  /// on its arguments.
446  bool onlyAccessesArgMemory() const {
448  }
451  }
452 
453  /// @brief Determine if the call cannot return.
454  bool doesNotReturn() const {
456  }
459  }
460 
461  /// @brief Determine if the call cannot unwind.
462  bool doesNotThrow() const {
464  }
467  }
468 
469  /// @brief Determine if the call can be duplicated.
470  bool cannotDuplicate() const {
472  }
475  }
476 
477  /// @brief Determine if the call is convergent.
478  bool isConvergent() const {
480  }
481  void setConvergent() {
483  }
486  }
487 
488  unsigned getNumOperandBundles() const {
490  }
491 
492  bool hasOperandBundles() const {
494  }
495 
496  unsigned getBundleOperandsStartIndex() const {
498  }
499 
500  unsigned getBundleOperandsEndIndex() const {
502  }
503 
504  unsigned getNumTotalBundleOperands() const {
506  }
507 
508  OperandBundleUse getOperandBundleAt(unsigned Index) const {
510  }
511 
514  }
515 
518  }
519 
522  }
523 
524  bool isBundleOperand(unsigned Idx) const {
526  }
527 
528  IterTy arg_begin() const {
530  }
531 
532  IterTy arg_end() const {
534  }
535 
536 #undef CALLSITE_DELEGATE_GETTER
537 #undef CALLSITE_DELEGATE_SETTER
538 
540  const Instruction *II = getInstruction();
541  // Since this is actually a getter that "looks like" a setter, don't use the
542  // above macros to avoid confusion.
543  if (isCall())
544  cast<CallInst>(II)->getOperandBundlesAsDefs(Defs);
545  else
546  cast<InvokeInst>(II)->getOperandBundlesAsDefs(Defs);
547  }
548 
549  /// @brief Determine whether this data operand is not captured.
550  bool doesNotCapture(unsigned OpNo) const {
551  return dataOperandHasImpliedAttr(OpNo + 1, Attribute::NoCapture);
552  }
553 
554  /// @brief Determine whether this argument is passed by value.
555  bool isByValArgument(unsigned ArgNo) const {
556  return paramHasAttr(ArgNo + 1, Attribute::ByVal);
557  }
558 
559  /// @brief Determine whether this argument is passed in an alloca.
560  bool isInAllocaArgument(unsigned ArgNo) const {
561  return paramHasAttr(ArgNo + 1, Attribute::InAlloca);
562  }
563 
564  /// @brief Determine whether this argument is passed by value or in an alloca.
565  bool isByValOrInAllocaArgument(unsigned ArgNo) const {
566  return paramHasAttr(ArgNo + 1, Attribute::ByVal) ||
567  paramHasAttr(ArgNo + 1, Attribute::InAlloca);
568  }
569 
570  /// @brief Determine if there are is an inalloca argument. Only the last
571  /// argument can have the inalloca attribute.
572  bool hasInAllocaArgument() const {
573  return paramHasAttr(arg_size(), Attribute::InAlloca);
574  }
575 
576  bool doesNotAccessMemory(unsigned OpNo) const {
577  return dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadNone);
578  }
579 
580  bool onlyReadsMemory(unsigned OpNo) const {
582  dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadNone);
583  }
584 
585  /// @brief Return true if the return value is known to be not null.
586  /// This may be because it has the nonnull attribute, or because at least
587  /// one byte is dereferenceable and the pointer is in addrspace(0).
588  bool isReturnNonNull() const {
589  if (paramHasAttr(0, Attribute::NonNull))
590  return true;
591  else if (getDereferenceableBytes(0) > 0 &&
592  getType()->getPointerAddressSpace() == 0)
593  return true;
594 
595  return false;
596  }
597 
598  /// hasArgument - Returns true if this CallSite passes the given Value* as an
599  /// argument to the called function.
600  bool hasArgument(const Value *Arg) const {
601  for (arg_iterator AI = this->arg_begin(), E = this->arg_end(); AI != E;
602  ++AI)
603  if (AI->get() == Arg)
604  return true;
605  return false;
606  }
607 
608 private:
609  IterTy getCallee() const {
610  if (isCall()) // Skip Callee
611  return cast<CallInst>(getInstruction())->op_end() - 1;
612  else // Skip BB, BB, Callee
613  return cast<InvokeInst>(getInstruction())->op_end() - 3;
614  }
615 };
616 
617 class CallSite : public CallSiteBase<Function, BasicBlock, Value, User, Use,
618  Instruction, CallInst, InvokeInst,
619  User::op_iterator> {
620 public:
621  CallSite() = default;
625  explicit CallSite(Instruction *II) : CallSiteBase(II) {}
626  explicit CallSite(Value *V) : CallSiteBase(V) {}
627 
628  bool operator==(const CallSite &CS) const { return I == CS.I; }
629  bool operator!=(const CallSite &CS) const { return I != CS.I; }
630  bool operator<(const CallSite &CS) const {
631  return getInstruction() < CS.getInstruction();
632  }
633 
634 private:
635  friend struct DenseMapInfo<CallSite>;
636 
637  User::op_iterator getCallee() const;
638 };
639 
640 template <> struct DenseMapInfo<CallSite> {
642 
644  CallSite CS;
645  CS.I = BaseInfo::getEmptyKey();
646  return CS;
647  }
648 
650  CallSite CS;
651  CS.I = BaseInfo::getTombstoneKey();
652  return CS;
653  }
654 
655  static unsigned getHashValue(const CallSite &CS) {
656  return BaseInfo::getHashValue(CS.I);
657  }
658 
659  static bool isEqual(const CallSite &LHS, const CallSite &RHS) {
660  return LHS == RHS;
661  }
662 };
663 
664 /// ImmutableCallSite - establish a view to a call site for examination
665 class ImmutableCallSite : public CallSiteBase<> {
666 public:
667  ImmutableCallSite() = default;
670  explicit ImmutableCallSite(const Instruction *II) : CallSiteBase(II) {}
671  explicit ImmutableCallSite(const Value *V) : CallSiteBase(V) {}
673 };
674 
675 } // end namespace llvm
676 
677 #endif // LLVM_IR_CALLSITE_H
void setConvergent()
Definition: CallSite.h:481
IterTy arg_end() const
Definition: CallSite.h:532
Attribute getAttribute(unsigned i, StringRef Kind) const
Definition: CallSite.h:367
FunTy * getCaller() const
getCaller - Return the caller function for this call site
Definition: CallSite.h:262
ImmutableCallSite(const Value *V)
Definition: CallSite.h:671
ImmutableCallSite(const Instruction *II)
Definition: CallSite.h:670
unsigned getBundleOperandsStartIndex() const
Definition: CallSite.h:496
void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Definition: CallSite.h:539
static CallSite getEmptyKey()
Definition: CallSite.h:643
unsigned getNumOperandBundles() const
Definition: CallSite.h:488
size_t i
CallSite(Instruction *II)
Definition: CallSite.h:625
bool doesNotCapture(unsigned OpNo) const
Determine whether this data operand is not captured.
Definition: CallSite.h:550
Various leaf nodes.
Definition: ISDOpcodes.h:60
bool data_operands_empty() const
Definition: CallSite.h:249
void setDoesNotAccessMemory()
Definition: CallSite.h:424
#define CALLSITE_DELEGATE_GETTER(METHOD)
Definition: CallSite.h:275
CallSiteBase(ValTy *II)
Definition: CallSite.h:65
unsigned getBundleOperandsEndIndex() const
Definition: CallSite.h:500
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
BBTy * getParent() const
Get the basic block containing the call site.
Definition: CallSite.h:98
This class represents a function call, abstracting a target machine's calling convention.
bool cannotDuplicate() const
Determine if the call can be duplicated.
Definition: CallSite.h:470
bool isConvergent() const
Determine if the call is convergent.
Definition: CallSite.h:478
bool hasInAllocaArgument() const
Determine if there are is an inalloca argument.
Definition: CallSite.h:572
void setAttributes(AttributeSet PAL)
Definition: CallSite.h:328
Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const
Definition: CallSite.h:363
static unsigned getHashValue(const CallSite &CS)
Definition: CallSite.h:655
uint64_t getDereferenceableBytes(uint16_t i) const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
Definition: CallSite.h:389
InstrTy * operator->() const
Definition: CallSite.h:94
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
Definition: CallSite.h:429
bool isCallee(const Use *U) const
Determine whether this Use is the callee operand's Use.
Definition: CallSite.h:139
CallSiteBase(CallTy *CI)
Definition: CallSite.h:63
bool isMustTailCall() const
Tests if this call site must be tail call optimized.
Definition: CallSite.h:266
This defines the Use class.
bool isByValOrInAllocaArgument(unsigned ArgNo) const
Determine whether this argument is passed by value or in an alloca.
Definition: CallSite.h:565
CallSite(InvokeInst *II)
Definition: CallSite.h:624
unsigned arg_size() const
Definition: CallSite.h:211
PointerIntPair< InstrTy *, 1, bool > I
Definition: CallSite.h:60
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
Definition: CallSite.h:408
unsigned getDataOperandNo(Value::const_user_iterator UI) const
Given a value use iterator, returns the data operand that corresponds to it.
Definition: CallSite.h:216
bool doesNotReturn() const
Determine if the call cannot return.
Definition: CallSite.h:454
bool isBundleOperand(Value::const_user_iterator UI) const
Determine whether the passed iterator points to a bundle operand.
Definition: CallSite.h:154
bool isArgOperand(Value::const_user_iterator UI) const
Determine whether the passed iterator points to an argument operand.
Definition: CallSite.h:143
bool operator==(const CallSite &CS) const
Definition: CallSite.h:628
bool onlyReadsMemory(unsigned OpNo) const
Definition: CallSite.h:580
bool doesNotAlias(unsigned n) const
Determine if the parameter or return value is marked with NoAlias attribute.
Definition: CallSite.h:402
CallSite()=default
A Use represents the edge between a Value definition and its users.
Definition: Use.h:56
CallSite(Value *V)
Definition: CallSite.h:626
ValTy * getCalledValue() const
getCalledValue - Return the pointer to function that is being called.
Definition: CallSite.h:102
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:32
bool isCall() const
isCall - true if a CallInst is enclosed.
Definition: CallSite.h:87
This file contains the simple types necessary to represent the attributes associated with functions a...
bool isArgOperand(const Use *U) const
Determine whether the passed use points to an argument operand.
Definition: CallSite.h:148
void setArgument(unsigned ArgNo, Value *newVal)
Definition: CallSite.h:183
void setOnlyAccessesArgMemory()
Definition: CallSite.h:449
IterTy data_operands_begin() const
data_operands_begin/data_operands_end - Return iterators iterating over the call / invoke argument li...
Definition: CallSite.h:238
bool isBundleOperand(unsigned Idx) const
Definition: CallSite.h:524
Class to represent function types.
Definition: DerivedTypes.h:102
#define F(x, y, z)
Definition: MD5.cpp:51
CallingConv::ID getCallingConv() const
getCallingConv/setCallingConv - get or set the calling convention of the call.
Definition: CallSite.h:308
bool isInlineAsm() const
Definition: CallSite.h:300
PointerTy getPointer() const
Function Alias Analysis false
void mutateFunctionType(FunctionType *Ty) const
Definition: CallSite.h:319
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
IntType getInt() const
void setDoesNotReadMemory()
Definition: CallSite.h:440
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
bool hasOperandBundles() const
Definition: CallSite.h:492
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:222
CallSite(CallSiteBase B)
Definition: CallSite.h:622
bool isInvoke() const
isInvoke - true if a InvokeInst is enclosed.
Definition: CallSite.h:91
ValTy * getReturnedArgOperand() const
Definition: CallSite.h:296
iterator_range< IterTy > args() const
Definition: CallSite.h:207
Optional< OperandBundleUse > getOperandBundle(StringRef Name) const
Definition: CallSite.h:512
FunctionType * getFunctionType() const
Definition: CallSite.h:315
bool arg_empty() const
Definition: CallSite.h:210
void setIsNoInline(bool Value=true)
Definition: CallSite.h:416
void addAttribute(unsigned i, Attribute Attr)
Definition: CallSite.h:336
bool isReturnNonNull() const
Return true if the return value is known to be not null.
Definition: CallSite.h:588
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
unsigned getArgumentNo(Value::const_user_iterator I) const
Given a value use iterator, returns the argument that corresponds to it.
Definition: CallSite.h:191
bool isNoInline() const
Return true if the call should not be inlined.
Definition: CallSite.h:413
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:378
uint16_t getParamAlignment(uint16_t i) const
Extract the alignment for a call or parameter (0=unknown).
Definition: CallSite.h:383
bool isDataOperand(const Use *U) const
Determine whether the passed use points to a data operand.
Definition: CallSite.h:174
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
Definition: CallSite.h:555
iterator_range< IterTy > data_ops() const
Definition: CallSite.h:246
void setCallingConv(CallingConv::ID CC)
Definition: CallSite.h:311
bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if this function has the given attribute.
Definition: CallSite.h:349
CallSite(CallInst *CI)
Definition: CallSite.h:623
unsigned getNumTotalBundleOperands() const
Definition: CallSite.h:504
void setNotConvergent()
Definition: CallSite.h:484
Type * getType() const
getType - Return the type of the instruction that generated this call site
Definition: CallSite.h:258
Optional< OperandBundleUse > getOperandBundle(uint32_t ID) const
Definition: CallSite.h:516
ImmutableCallSite(CallSite CS)
Definition: CallSite.h:672
IterTy arg_iterator
arg_iterator - The type of iterator to use when looping over actual arguments at this call site...
Definition: CallSite.h:205
OperandBundleUse getOperandBundleAt(unsigned Index) const
Definition: CallSite.h:508
static bool isEqual(const CallSite &LHS, const CallSite &RHS)
Definition: CallSite.h:659
unsigned countOperandBundlesOfType(uint32_t ID) const
Definition: CallSite.h:520
bool doesNotAccessMemory() const
Determine if the call does not access memory.
Definition: CallSite.h:421
AttributeSet getAttributes() const
getAttributes/setAttributes - get or set the parameter attributes of the call.
Definition: CallSite.h:325
void setCannotDuplicate()
Definition: CallSite.h:473
IterTy arg_begin() const
Definition: CallSite.h:528
static CallSite getTombstoneKey()
Definition: CallSite.h:649
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool operator!=(const CallSite &CS) const
Definition: CallSite.h:629
bool isDataOperand(Value::const_user_iterator UI) const
Determine whether the passed iterator points to a data operand.
Definition: CallSite.h:169
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
Definition: CallSite.h:446
bool doesNotReadMemory() const
Determine if the call does not access or only writes memory.
Definition: CallSite.h:437
InstrTy * getInstruction() const
Definition: CallSite.h:93
void removeAttribute(unsigned i, StringRef Kind)
Definition: CallSite.h:344
ValTy * getArgument(unsigned ArgNo) const
Definition: CallSite.h:178
ImmutableCallSite(const InvokeInst *II)
Definition: CallSite.h:669
void setDoesNotThrow()
Definition: CallSite.h:465
bool isBundleOperand(const Use *U) const
Determine whether the passed use points to a bundle operand.
Definition: CallSite.h:159
unsigned data_operands_size() const
Definition: CallSite.h:252
unsigned getArgumentNo(const Use *U) const
Given a use for an argument, get the argument number that corresponds to it.
Definition: CallSite.h:197
A range adaptor for a pair of iterators.
unsigned getNumArgOperands() const
Definition: CallSite.h:288
ImmutableCallSite(const CallInst *CI)
Definition: CallSite.h:668
void setDoesNotReturn()
Definition: CallSite.h:457
A lightweight accessor for an operand bundle meant to be passed around by value.
Definition: InstrTypes.h:1206
void addAttribute(unsigned i, Attribute::AttrKind Kind)
Definition: CallSite.h:332
bool doesNotAccessMemory(unsigned OpNo) const
Definition: CallSite.h:576
could "use" a pointer
bool hasFnAttr(StringRef Kind) const
Return true if this function has the given attribute.
Definition: CallSite.h:354
bool isInAllocaArgument(unsigned ArgNo) const
Determine whether this argument is passed in an alloca.
Definition: CallSite.h:560
bool hasArgument(const Value *Arg) const
hasArgument - Returns true if this CallSite passes the given Value* as an argument to the called func...
Definition: CallSite.h:600
Basic Alias true
user_iterator_impl< const User > const_user_iterator
Definition: Value.h:341
#define CALLSITE_DELEGATE_SETTER(METHOD)
Definition: CallSite.h:281
CallSiteBase(InvokeTy *II)
Definition: CallSite.h:64
ImmutableCallSite - establish a view to a call site for examination.
Definition: CallSite.h:665
bool paramHasAttr(unsigned i, Attribute::AttrKind Kind) const
Return true if the call or the callee has the given attribute.
Definition: CallSite.h:359
void removeAttribute(unsigned i, Attribute::AttrKind Kind)
Definition: CallSite.h:340
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:287
bool operator<(const CallSite &CS) const
Definition: CallSite.h:630
uint64_t getDereferenceableOrNullBytes(uint16_t i) const
Extract the number of dereferenceable_or_null bytes for a call or parameter (0=unknown).
Definition: CallSite.h:395
const unsigned Kind
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
FunTy * getCalledFunction() const
getCalledFunction - Return the function being called if this is a direct call, otherwise return null ...
Definition: CallSite.h:110
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of the intrinsic called by this CallSite, or Intrinsic::not_intrinsic if the ...
Definition: CallSite.h:124
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:537
LLVM Value Representation.
Definition: Value.h:71
void setOnlyReadsMemory()
Definition: CallSite.h:432
ValTy * getArgOperand(unsigned i) const
Definition: CallSite.h:292
Invoke instruction.
bool isTailCall() const
Tests if this call site is marked as a tail call.
Definition: CallSite.h:271
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
IterTy data_operands_end() const
Definition: CallSite.h:242
void setCalledFunction(Value *V)
setCalledFunction - Set the callee to the specified value.
Definition: CallSite.h:116
bool doesNotThrow() const
Determine if the call cannot unwind.
Definition: CallSite.h:462
bool isCallee(Value::const_user_iterator UI) const
isCallee - Determine whether the passed iterator points to the callee operand's Use.
Definition: CallSite.h:134
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...
Definition: Attributes.h:67
IterTy data_operand_iterator
Type of iterator to use when looping over data operands at this call site (see below).
Definition: CallSite.h:230
const Use * const_op_iterator
Definition: User.h:201