LLVM  9.0.0svn
CallSite.h
Go to the documentation of this file.
1 //===- CallSite.h - Abstract Call & Invoke instrs ---------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the CallSite class, which is a handy wrapper for code that
10 // wants to treat Call and Invoke instructions in a generic way. When in non-
11 // mutation context (e.g. an analysis) ImmutableCallSite should be used.
12 // Finally, when some degree of customization is necessary between these two
13 // extremes, CallSiteBase<> can be supplied with fine-tuned parameters.
14 //
15 // NOTE: These classes are supposed to have "value semantics". So they should be
16 // passed by value, not by reference; they should not be "new"ed or "delete"d.
17 // They are efficiently copyable, assignable and constructable, with cost
18 // equivalent to copying a pointer (notice that they have only a single data
19 // member). The internal representation carries a flag which indicates which of
20 // the two variants is enclosed. This allows for cheaper checks when various
21 // accessors of CallSite are employed.
22 //
23 //===----------------------------------------------------------------------===//
24 
25 #ifndef LLVM_IR_CALLSITE_H
26 #define LLVM_IR_CALLSITE_H
27 
28 #include "llvm/ADT/Optional.h"
31 #include "llvm/IR/Attributes.h"
32 #include "llvm/IR/CallingConv.h"
33 #include "llvm/IR/Function.h"
34 #include "llvm/IR/InstrTypes.h"
35 #include "llvm/IR/Instruction.h"
36 #include "llvm/IR/Instructions.h"
37 #include "llvm/IR/Use.h"
38 #include "llvm/IR/User.h"
39 #include "llvm/IR/Value.h"
40 #include "llvm/Support/Casting.h"
41 #include <cassert>
42 #include <cstdint>
43 #include <iterator>
44 
45 namespace llvm {
46 
47 namespace Intrinsic {
48 enum ID : unsigned;
49 }
50 
51 template <typename FunTy = const Function,
52  typename BBTy = const BasicBlock,
53  typename ValTy = const Value,
54  typename UserTy = const User,
55  typename UseTy = const Use,
56  typename InstrTy = const Instruction,
57  typename CallTy = const CallInst,
58  typename InvokeTy = const InvokeInst,
59  typename IterTy = User::const_op_iterator>
60 class CallSiteBase {
61 protected:
63 
64  CallSiteBase() = default;
65  CallSiteBase(CallTy *CI) : I(CI, true) { assert(CI); }
66  CallSiteBase(InvokeTy *II) : I(II, false) { assert(II); }
67  explicit CallSiteBase(ValTy *II) { *this = get(II); }
68 
69 private:
70  /// This static method is like a constructor. It will create an appropriate
71  /// call site for a Call or Invoke instruction, but it can also create a null
72  /// initialized CallSiteBase object for something which is NOT a call site.
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  /// Return true if a CallInst is enclosed. Note that !isCall() does not mean
85  /// an InvokeInst is enclosed. It may also signify a NULL instruction pointer.
86  bool isCall() const { return I.getInt(); }
87 
88  /// Return true if a InvokeInst is enclosed.
89  bool isInvoke() const { return getInstruction() && !I.getInt(); }
90 
91  InstrTy *getInstruction() const { return I.getPointer(); }
92  InstrTy *operator->() const { return I.getPointer(); }
93  explicit operator bool() const { return I.getPointer(); }
94 
95  /// Get the basic block containing the call site.
96  BBTy* getParent() const { return getInstruction()->getParent(); }
97 
98  /// Return the pointer to function that is being called.
99  ValTy *getCalledValue() const {
100  assert(getInstruction() && "Not a call or invoke instruction!");
101  return *getCallee();
102  }
103 
104  /// Return the function being called if this is a direct call, otherwise
105  /// return null (if it's an indirect call).
106  FunTy *getCalledFunction() const {
107  return dyn_cast<FunTy>(getCalledValue());
108  }
109 
110  /// Return true if the callsite is an indirect call.
111  bool isIndirectCall() const {
112  const Value *V = getCalledValue();
113  if (!V)
114  return false;
115  if (isa<FunTy>(V) || isa<Constant>(V))
116  return false;
117  if (const CallInst *CI = dyn_cast<CallInst>(getInstruction())) {
118  if (CI->isInlineAsm())
119  return false;
120  }
121  return true;
122  }
123 
124  /// Set the callee to the specified value.
126  assert(getInstruction() && "Not a call or invoke instruction!");
127  *getCallee() = V;
128  }
129 
130  /// Return the intrinsic ID of the intrinsic called by this CallSite,
131  /// or Intrinsic::not_intrinsic if the called function is not an
132  /// intrinsic, or if this CallSite is an indirect call.
134  if (auto *F = getCalledFunction())
135  return F->getIntrinsicID();
136  // Don't use Intrinsic::not_intrinsic, as it will require pulling
137  // Intrinsics.h into every header that uses CallSite.
138  return static_cast<Intrinsic::ID>(0);
139  }
140 
141  /// Determine whether the passed iterator points to the callee operand's Use.
143  return isCallee(&UI.getUse());
144  }
145 
146  /// Determine whether this Use is the callee operand's Use.
147  bool isCallee(const Use *U) const { return getCallee() == U; }
148 
149  /// Determine whether the passed iterator points to an argument operand.
151  return isArgOperand(&UI.getUse());
152  }
153 
154  /// Determine whether the passed use points to an argument operand.
155  bool isArgOperand(const Use *U) const {
156  assert(getInstruction() == U->getUser());
157  return arg_begin() <= U && U < arg_end();
158  }
159 
160  /// Determine whether the passed iterator points to a bundle operand.
162  return isBundleOperand(&UI.getUse());
163  }
164 
165  /// Determine whether the passed use points to a bundle operand.
166  bool isBundleOperand(const Use *U) const {
167  assert(getInstruction() == U->getUser());
168  if (!hasOperandBundles())
169  return false;
170  unsigned OperandNo = U - (*this)->op_begin();
171  return getBundleOperandsStartIndex() <= OperandNo &&
172  OperandNo < getBundleOperandsEndIndex();
173  }
174 
175  /// Determine whether the passed iterator points to a data operand.
177  return isDataOperand(&UI.getUse());
178  }
179 
180  /// Determine whether the passed use points to a data operand.
181  bool isDataOperand(const Use *U) const {
182  return data_operands_begin() <= U && U < data_operands_end();
183  }
184 
185  ValTy *getArgument(unsigned ArgNo) const {
186  assert(arg_begin() + ArgNo < arg_end() && "Argument # out of range!");
187  return *(arg_begin() + ArgNo);
188  }
189 
190  void setArgument(unsigned ArgNo, Value* newVal) {
191  assert(getInstruction() && "Not a call or invoke instruction!");
192  assert(arg_begin() + ArgNo < arg_end() && "Argument # out of range!");
193  getInstruction()->setOperand(ArgNo, newVal);
194  }
195 
196  /// Given a value use iterator, returns the argument that corresponds to it.
197  /// Iterator must actually correspond to an argument.
199  return getArgumentNo(&I.getUse());
200  }
201 
202  /// Given a use for an argument, get the argument number that corresponds to
203  /// it.
204  unsigned getArgumentNo(const Use *U) const {
205  assert(getInstruction() && "Not a call or invoke instruction!");
206  assert(isArgOperand(U) && "Argument # out of range!");
207  return U - arg_begin();
208  }
209 
210  /// The type of iterator to use when looping over actual arguments at this
211  /// call site.
212  using arg_iterator = IterTy;
213 
215  return make_range(arg_begin(), arg_end());
216  }
217  bool arg_empty() const { return arg_end() == arg_begin(); }
218  unsigned arg_size() const { return unsigned(arg_end() - arg_begin()); }
219 
220  /// Given a value use iterator, return the data operand corresponding to it.
221  /// Iterator must actually correspond to a data operand.
223  return getDataOperandNo(&UI.getUse());
224  }
225 
226  /// Given a use for a data operand, get the data operand number that
227  /// corresponds to it.
228  unsigned getDataOperandNo(const Use *U) const {
229  assert(getInstruction() && "Not a call or invoke instruction!");
230  assert(isDataOperand(U) && "Data operand # out of range!");
231  return U - data_operands_begin();
232  }
233 
234  /// Type of iterator to use when looping over data operands at this call site
235  /// (see below).
236  using data_operand_iterator = IterTy;
237 
238  /// data_operands_begin/data_operands_end - Return iterators iterating over
239  /// the call / invoke argument list and bundle operands. For invokes, this is
240  /// the set of instruction operands except the invoke target and the two
241  /// successor blocks; and for calls this is the set of instruction operands
242  /// except the call target.
243 
244  IterTy data_operands_begin() const {
245  assert(getInstruction() && "Not a call or invoke instruction!");
246  return (*this)->op_begin();
247  }
248  IterTy data_operands_end() const {
249  assert(getInstruction() && "Not a call or invoke instruction!");
250  return (*this)->op_end() - (isCall() ? 1 : 3);
251  }
253  return make_range(data_operands_begin(), data_operands_end());
254  }
255  bool data_operands_empty() const {
256  return data_operands_end() == data_operands_begin();
257  }
258  unsigned data_operands_size() const {
259  return std::distance(data_operands_begin(), data_operands_end());
260  }
261 
262  /// Return the type of the instruction that generated this call site.
263  Type *getType() const { return (*this)->getType(); }
264 
265  /// Return the caller function for this call site.
266  FunTy *getCaller() const { return (*this)->getParent()->getParent(); }
267 
268  /// Tests if this call site must be tail call optimized. Only a CallInst can
269  /// be tail call optimized.
270  bool isMustTailCall() const {
271  return isCall() && cast<CallInst>(getInstruction())->isMustTailCall();
272  }
273 
274  /// Tests if this call site is marked as a tail call.
275  bool isTailCall() const {
276  return isCall() && cast<CallInst>(getInstruction())->isTailCall();
277  }
278 
279 #define CALLSITE_DELEGATE_GETTER(METHOD) \
280  InstrTy *II = getInstruction(); \
281  return isCall() \
282  ? cast<CallInst>(II)->METHOD \
283  : cast<InvokeInst>(II)->METHOD
284 
285 #define CALLSITE_DELEGATE_SETTER(METHOD) \
286  InstrTy *II = getInstruction(); \
287  if (isCall()) \
288  cast<CallInst>(II)->METHOD; \
289  else \
290  cast<InvokeInst>(II)->METHOD
291 
292  unsigned getNumArgOperands() const {
293  CALLSITE_DELEGATE_GETTER(getNumArgOperands());
294  }
295 
296  ValTy *getArgOperand(unsigned i) const {
297  CALLSITE_DELEGATE_GETTER(getArgOperand(i));
298  }
299 
300  ValTy *getReturnedArgOperand() const {
301  CALLSITE_DELEGATE_GETTER(getReturnedArgOperand());
302  }
303 
304  bool isInlineAsm() const {
305  if (isCall())
306  return cast<CallInst>(getInstruction())->isInlineAsm();
307  return false;
308  }
309 
310  /// Get the calling convention of the call.
312  CALLSITE_DELEGATE_GETTER(getCallingConv());
313  }
314  /// Set the calling convention of the call.
316  CALLSITE_DELEGATE_SETTER(setCallingConv(CC));
317  }
318 
320  CALLSITE_DELEGATE_GETTER(getFunctionType());
321  }
322 
324  CALLSITE_DELEGATE_SETTER(mutateFunctionType(Ty));
325  }
326 
327  /// Get the parameter attributes of the call.
330  }
331  /// Set the parameter attributes of the call.
333  CALLSITE_DELEGATE_SETTER(setAttributes(PAL));
334  }
335 
337  CALLSITE_DELEGATE_SETTER(addAttribute(i, Kind));
338  }
339 
340  void addAttribute(unsigned i, Attribute Attr) {
341  CALLSITE_DELEGATE_SETTER(addAttribute(i, Attr));
342  }
343 
344  void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) {
345  CALLSITE_DELEGATE_SETTER(addParamAttr(ArgNo, Kind));
346  }
347 
349  CALLSITE_DELEGATE_SETTER(removeAttribute(i, Kind));
350  }
351 
352  void removeAttribute(unsigned i, StringRef Kind) {
353  CALLSITE_DELEGATE_SETTER(removeAttribute(i, Kind));
354  }
355 
356  void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) {
357  CALLSITE_DELEGATE_SETTER(removeParamAttr(ArgNo, Kind));
358  }
359 
360  /// Return true if this function has the given attribute.
362  CALLSITE_DELEGATE_GETTER(hasFnAttr(Kind));
363  }
364 
365  /// Return true if this function has the given attribute.
366  bool hasFnAttr(StringRef Kind) const {
367  CALLSITE_DELEGATE_GETTER(hasFnAttr(Kind));
368  }
369 
370  /// Return true if this return value has the given attribute.
372  CALLSITE_DELEGATE_GETTER(hasRetAttr(Kind));
373  }
374 
375  /// Return true if the call or the callee has the given attribute.
376  bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
377  CALLSITE_DELEGATE_GETTER(paramHasAttr(ArgNo, Kind));
378  }
379 
381  CALLSITE_DELEGATE_GETTER(getAttribute(i, Kind));
382  }
383 
384  Attribute getAttribute(unsigned i, StringRef Kind) const {
385  CALLSITE_DELEGATE_GETTER(getAttribute(i, Kind));
386  }
387 
388  /// Return true if the data operand at index \p i directly or indirectly has
389  /// the attribute \p A.
390  ///
391  /// Normal call or invoke arguments have per operand attributes, as specified
392  /// in the attribute set attached to this instruction, while operand bundle
393  /// operands may have some attributes implied by the type of its containing
394  /// operand bundle.
396  CALLSITE_DELEGATE_GETTER(dataOperandHasImpliedAttr(i, Kind));
397  }
398 
399  /// Extract the alignment of the return value.
400  unsigned getRetAlignment() const {
401  CALLSITE_DELEGATE_GETTER(getRetAlignment());
402  }
403 
404  /// Extract the alignment for a call or parameter (0=unknown).
405  unsigned getParamAlignment(unsigned ArgNo) const {
406  CALLSITE_DELEGATE_GETTER(getParamAlignment(ArgNo));
407  }
408 
409  /// Extract the number of dereferenceable bytes for a call or parameter
410  /// (0=unknown).
411  uint64_t getDereferenceableBytes(unsigned i) const {
412  CALLSITE_DELEGATE_GETTER(getDereferenceableBytes(i));
413  }
414 
415  /// Extract the number of dereferenceable_or_null bytes for a call or
416  /// parameter (0=unknown).
417  uint64_t getDereferenceableOrNullBytes(unsigned i) const {
418  CALLSITE_DELEGATE_GETTER(getDereferenceableOrNullBytes(i));
419  }
420 
421  /// Determine if the return value is marked with NoAlias attribute.
422  bool returnDoesNotAlias() const {
423  CALLSITE_DELEGATE_GETTER(returnDoesNotAlias());
424  }
425 
426  /// Return true if the call should not be treated as a call to a builtin.
427  bool isNoBuiltin() const {
428  CALLSITE_DELEGATE_GETTER(isNoBuiltin());
429  }
430 
431  /// Return true if the call requires strict floating point semantics.
432  bool isStrictFP() const {
433  CALLSITE_DELEGATE_GETTER(isStrictFP());
434  }
435 
436  /// Return true if the call should not be inlined.
437  bool isNoInline() const {
438  CALLSITE_DELEGATE_GETTER(isNoInline());
439  }
440  void setIsNoInline(bool Value = true) {
441  CALLSITE_DELEGATE_SETTER(setIsNoInline(Value));
442  }
443 
444  /// Determine if the call does not access memory.
445  bool doesNotAccessMemory() const {
446  CALLSITE_DELEGATE_GETTER(doesNotAccessMemory());
447  }
450  }
451 
452  /// Determine if the call does not access or only reads memory.
453  bool onlyReadsMemory() const {
454  CALLSITE_DELEGATE_GETTER(onlyReadsMemory());
455  }
458  }
459 
460  /// Determine if the call does not access or only writes memory.
461  bool doesNotReadMemory() const {
462  CALLSITE_DELEGATE_GETTER(doesNotReadMemory());
463  }
465  CALLSITE_DELEGATE_SETTER(setDoesNotReadMemory());
466  }
467 
468  /// Determine if the call can access memmory only using pointers based
469  /// on its arguments.
470  bool onlyAccessesArgMemory() const {
471  CALLSITE_DELEGATE_GETTER(onlyAccessesArgMemory());
472  }
475  }
476 
477  /// Determine if the function may only access memory that is
478  /// inaccessible from the IR.
480  CALLSITE_DELEGATE_GETTER(onlyAccessesInaccessibleMemory());
481  }
483  CALLSITE_DELEGATE_SETTER(setOnlyAccessesInaccessibleMemory());
484  }
485 
486  /// Determine if the function may only access memory that is
487  /// either inaccessible from the IR or pointed to by its arguments.
489  CALLSITE_DELEGATE_GETTER(onlyAccessesInaccessibleMemOrArgMem());
490  }
492  CALLSITE_DELEGATE_SETTER(setOnlyAccessesInaccessibleMemOrArgMem());
493  }
494 
495  /// Determine if the call cannot return.
496  bool doesNotReturn() const {
497  CALLSITE_DELEGATE_GETTER(doesNotReturn());
498  }
500  CALLSITE_DELEGATE_SETTER(setDoesNotReturn());
501  }
502 
503  /// Determine if the call cannot unwind.
504  bool doesNotThrow() const {
505  CALLSITE_DELEGATE_GETTER(doesNotThrow());
506  }
509  }
510 
511  /// Determine if the call can be duplicated.
512  bool cannotDuplicate() const {
513  CALLSITE_DELEGATE_GETTER(cannotDuplicate());
514  }
517  }
518 
519  /// Determine if the call is convergent.
520  bool isConvergent() const {
521  CALLSITE_DELEGATE_GETTER(isConvergent());
522  }
523  void setConvergent() {
524  CALLSITE_DELEGATE_SETTER(setConvergent());
525  }
527  CALLSITE_DELEGATE_SETTER(setNotConvergent());
528  }
529 
530  unsigned getNumOperandBundles() const {
531  CALLSITE_DELEGATE_GETTER(getNumOperandBundles());
532  }
533 
534  bool hasOperandBundles() const {
535  CALLSITE_DELEGATE_GETTER(hasOperandBundles());
536  }
537 
538  unsigned getBundleOperandsStartIndex() const {
539  CALLSITE_DELEGATE_GETTER(getBundleOperandsStartIndex());
540  }
541 
542  unsigned getBundleOperandsEndIndex() const {
543  CALLSITE_DELEGATE_GETTER(getBundleOperandsEndIndex());
544  }
545 
546  unsigned getNumTotalBundleOperands() const {
547  CALLSITE_DELEGATE_GETTER(getNumTotalBundleOperands());
548  }
549 
551  CALLSITE_DELEGATE_GETTER(getOperandBundleAt(Index));
552  }
553 
555  CALLSITE_DELEGATE_GETTER(getOperandBundle(Name));
556  }
557 
559  CALLSITE_DELEGATE_GETTER(getOperandBundle(ID));
560  }
561 
563  CALLSITE_DELEGATE_GETTER(countOperandBundlesOfType(ID));
564  }
565 
566  bool isBundleOperand(unsigned Idx) const {
567  CALLSITE_DELEGATE_GETTER(isBundleOperand(Idx));
568  }
569 
570  IterTy arg_begin() const {
571  CALLSITE_DELEGATE_GETTER(arg_begin());
572  }
573 
574  IterTy arg_end() const {
575  CALLSITE_DELEGATE_GETTER(arg_end());
576  }
577 
578 #undef CALLSITE_DELEGATE_GETTER
579 #undef CALLSITE_DELEGATE_SETTER
580 
582  const Instruction *II = getInstruction();
583  // Since this is actually a getter that "looks like" a setter, don't use the
584  // above macros to avoid confusion.
585  if (isCall())
586  cast<CallInst>(II)->getOperandBundlesAsDefs(Defs);
587  else
588  cast<InvokeInst>(II)->getOperandBundlesAsDefs(Defs);
589  }
590 
591  /// Determine whether this data operand is not captured.
592  bool doesNotCapture(unsigned OpNo) const {
593  return dataOperandHasImpliedAttr(OpNo + 1, Attribute::NoCapture);
594  }
595 
596  /// Determine whether this argument is passed by value.
597  bool isByValArgument(unsigned ArgNo) const {
598  return paramHasAttr(ArgNo, Attribute::ByVal);
599  }
600 
601  /// Determine whether this argument is passed in an alloca.
602  bool isInAllocaArgument(unsigned ArgNo) const {
603  return paramHasAttr(ArgNo, Attribute::InAlloca);
604  }
605 
606  /// Determine whether this argument is passed by value or in an alloca.
607  bool isByValOrInAllocaArgument(unsigned ArgNo) const {
608  return paramHasAttr(ArgNo, Attribute::ByVal) ||
609  paramHasAttr(ArgNo, Attribute::InAlloca);
610  }
611 
612  /// Determine if there are is an inalloca argument. Only the last argument can
613  /// have the inalloca attribute.
614  bool hasInAllocaArgument() const {
615  return !arg_empty() && paramHasAttr(arg_size() - 1, Attribute::InAlloca);
616  }
617 
618  bool doesNotAccessMemory(unsigned OpNo) const {
619  return dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadNone);
620  }
621 
622  bool onlyReadsMemory(unsigned OpNo) const {
623  return dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadOnly) ||
624  dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadNone);
625  }
626 
627  bool doesNotReadMemory(unsigned OpNo) const {
628  return dataOperandHasImpliedAttr(OpNo + 1, Attribute::WriteOnly) ||
629  dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadNone);
630  }
631 
632  /// Return true if the return value is known to be not null.
633  /// This may be because it has the nonnull attribute, or because at least
634  /// one byte is dereferenceable and the pointer is in addrspace(0).
635  bool isReturnNonNull() const {
636  if (hasRetAttr(Attribute::NonNull))
637  return true;
638  else if (getDereferenceableBytes(AttributeList::ReturnIndex) > 0 &&
639  !NullPointerIsDefined(getCaller(),
640  getType()->getPointerAddressSpace()))
641  return true;
642 
643  return false;
644  }
645 
646  /// Returns true if this CallSite passes the given Value* as an argument to
647  /// the called function.
648  bool hasArgument(const Value *Arg) const {
649  for (arg_iterator AI = this->arg_begin(), E = this->arg_end(); AI != E;
650  ++AI)
651  if (AI->get() == Arg)
652  return true;
653  return false;
654  }
655 
656 private:
657  IterTy getCallee() const {
658  return cast<CallBase>(getInstruction())->op_end() - 1;
659  }
660 };
661 
662 class CallSite : public CallSiteBase<Function, BasicBlock, Value, User, Use,
663  Instruction, CallInst, InvokeInst,
664  User::op_iterator> {
665 public:
666  CallSite() = default;
670  explicit CallSite(Instruction *II) : CallSiteBase(II) {}
671  explicit CallSite(Value *V) : CallSiteBase(V) {}
672 
673  bool operator==(const CallSite &CS) const { return I == CS.I; }
674  bool operator!=(const CallSite &CS) const { return I != CS.I; }
675  bool operator<(const CallSite &CS) const {
676  return getInstruction() < CS.getInstruction();
677  }
678 
679 private:
680  friend struct DenseMapInfo<CallSite>;
681 
682  User::op_iterator getCallee() const;
683 };
684 
685 /// AbstractCallSite
686 ///
687 /// An abstract call site is a wrapper that allows to treat direct,
688 /// indirect, and callback calls the same. If an abstract call site
689 /// represents a direct or indirect call site it behaves like a stripped
690 /// down version of a normal call site object. The abstract call site can
691 /// also represent a callback call, thus the fact that the initially
692 /// called function (=broker) may invoke a third one (=callback callee).
693 /// In this case, the abstract call site hides the middle man, hence the
694 /// broker function. The result is a representation of the callback call,
695 /// inside the broker, but in the context of the original call to the broker.
696 ///
697 /// There are up to three functions involved when we talk about callback call
698 /// sites. The caller (1), which invokes the broker function. The broker
699 /// function (2), that will invoke the callee zero or more times. And finally
700 /// the callee (3), which is the target of the callback call.
701 ///
702 /// The abstract call site will handle the mapping from parameters to arguments
703 /// depending on the semantic of the broker function. However, it is important
704 /// to note that the mapping is often partial. Thus, some arguments of the
705 /// call/invoke instruction are mapped to parameters of the callee while others
706 /// are not.
708 public:
709 
710  /// The encoding of a callback with regards to the underlying instruction.
711  struct CallbackInfo {
712 
713  /// For direct/indirect calls the parameter encoding is empty. If it is not,
714  /// the abstract call site represents a callback. In that case, the first
715  /// element of the encoding vector represents which argument of the call
716  /// site CS is the callback callee. The remaining elements map parameters
717  /// (identified by their position) to the arguments that will be passed
718  /// through (also identified by position but in the call site instruction).
719  ///
720  /// NOTE that we use LLVM argument numbers (starting at 0) and not
721  /// clang/soruce argument numbers (starting at 1). The -1 entries represent
722  /// unknown values that are passed to the callee.
725 
726  };
727 
728 private:
729 
730  /// The underlying call site:
731  /// caller -> callee, if this is a direct or indirect call site
732  /// caller -> broker function, if this is a callback call site
733  CallSite CS;
734 
735  /// The encoding of a callback with regards to the underlying instruction.
736  CallbackInfo CI;
737 
738 public:
739  /// Sole constructor for abstract call sites (ACS).
740  ///
741  /// An abstract call site can only be constructed through a llvm::Use because
742  /// each operand (=use) of an instruction could potentially be a different
743  /// abstract call site. Furthermore, even if the value of the llvm::Use is the
744  /// same, and the user is as well, the abstract call sites might not be.
745  ///
746  /// If a use is not associated with an abstract call site the constructed ACS
747  /// will evaluate to false if converted to a boolean.
748  ///
749  /// If the use is the callee use of a call or invoke instruction, the
750  /// constructed abstract call site will behave as a llvm::CallSite would.
751  ///
752  /// If the use is not a callee use of a call or invoke instruction, the
753  /// callback metadata is used to determine the argument <-> parameter mapping
754  /// as well as the callee of the abstract call site.
755  AbstractCallSite(const Use *U);
756 
757  /// Conversion operator to conveniently check for a valid/initialized ACS.
758  explicit operator bool() const { return (bool)CS; }
759 
760  /// Return the underlying instruction.
761  Instruction *getInstruction() const { return CS.getInstruction(); }
762 
763  /// Return the call site abstraction for the underlying instruction.
764  CallSite getCallSite() const { return CS; }
765 
766  /// Return true if this ACS represents a direct call.
767  bool isDirectCall() const {
768  return !isCallbackCall() && !CS.isIndirectCall();
769  }
770 
771  /// Return true if this ACS represents an indirect call.
772  bool isIndirectCall() const {
773  return !isCallbackCall() && CS.isIndirectCall();
774  }
775 
776  /// Return true if this ACS represents a callback call.
777  bool isCallbackCall() const {
778  // For a callback call site the callee is ALWAYS stored first in the
779  // transitive values vector. Thus, a non-empty vector indicates a callback.
780  return !CI.ParameterEncoding.empty();
781  }
782 
783  /// Return true if @p UI is the use that defines the callee of this ACS.
785  return isCallee(&UI.getUse());
786  }
787 
788  /// Return true if @p U is the use that defines the callee of this ACS.
789  bool isCallee(const Use *U) const {
790  if (isDirectCall())
791  return CS.isCallee(U);
792 
794  "Callback without parameter encoding!");
795 
796  return (int)CS.getArgumentNo(U) == CI.ParameterEncoding[0];
797  }
798 
799  /// Return the number of parameters of the callee.
800  unsigned getNumArgOperands() const {
801  if (isDirectCall())
802  return CS.getNumArgOperands();
803  // Subtract 1 for the callee encoding.
804  return CI.ParameterEncoding.size() - 1;
805  }
806 
807  /// Return the operand index of the underlying instruction associated with @p
808  /// Arg.
810  return getCallArgOperandNo(Arg.getArgNo());
811  }
812 
813  /// Return the operand index of the underlying instruction associated with
814  /// the function parameter number @p ArgNo or -1 if there is none.
815  int getCallArgOperandNo(unsigned ArgNo) const {
816  if (isDirectCall())
817  return ArgNo;
818  // Add 1 for the callee encoding.
819  return CI.ParameterEncoding[ArgNo + 1];
820  }
821 
822  /// Return the operand of the underlying instruction associated with @p Arg.
824  return getCallArgOperand(Arg.getArgNo());
825  }
826 
827  /// Return the operand of the underlying instruction associated with the
828  /// function parameter number @p ArgNo or nullptr if there is none.
829  Value *getCallArgOperand(unsigned ArgNo) const {
830  if (isDirectCall())
831  return CS.getArgOperand(ArgNo);
832  // Add 1 for the callee encoding.
833  return CI.ParameterEncoding[ArgNo + 1] >= 0
834  ? CS.getArgOperand(CI.ParameterEncoding[ArgNo + 1])
835  : nullptr;
836  }
837 
838  /// Return the operand index of the underlying instruction associated with the
839  /// callee of this ACS. Only valid for callback calls!
841  assert(isCallbackCall());
842  assert(CI.ParameterEncoding.size() && CI.ParameterEncoding[0] > 0);
843  return CI.ParameterEncoding[0];
844  }
845 
846  /// Return the pointer to function that is being called.
848  if (isDirectCall())
849  return CS.getCalledValue();
850  return CS.getArgOperand(getCallArgOperandNoForCallee());
851  }
852 
853  /// Return the function being called if this is a direct call, otherwise
854  /// return null (if it's an indirect call).
856  Value *V = getCalledValue();
857  return V ? dyn_cast<Function>(V->stripPointerCasts()) : nullptr;
858  }
859 };
860 
861 template <> struct DenseMapInfo<CallSite> {
863 
865  CallSite CS;
866  CS.I = BaseInfo::getEmptyKey();
867  return CS;
868  }
869 
871  CallSite CS;
872  CS.I = BaseInfo::getTombstoneKey();
873  return CS;
874  }
875 
876  static unsigned getHashValue(const CallSite &CS) {
877  return BaseInfo::getHashValue(CS.I);
878  }
879 
880  static bool isEqual(const CallSite &LHS, const CallSite &RHS) {
881  return LHS == RHS;
882  }
883 };
884 
885 /// Establish a view to a call site for examination.
886 class ImmutableCallSite : public CallSiteBase<> {
887 public:
888  ImmutableCallSite() = default;
891  explicit ImmutableCallSite(const Instruction *II) : CallSiteBase(II) {}
892  explicit ImmutableCallSite(const Value *V) : CallSiteBase(V) {}
893  ImmutableCallSite(CallSite CS) : CallSiteBase(CS.getInstruction()) {}
894 };
895 
896 } // end namespace llvm
897 
898 #endif // LLVM_IR_CALLSITE_H
void setConvergent()
Definition: CallSite.h:523
uint64_t getDereferenceableBytes(unsigned i) const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
Definition: CallSite.h:411
bool isCallee(const Use *U) const
Return true if U is the use that defines the callee of this ACS.
Definition: CallSite.h:789
unsigned getArgumentNo(const Use *U) const
Given a use for an argument, get the argument number that corresponds to it.
Definition: CallSite.h:204
ImmutableCallSite(const Value *V)
Definition: CallSite.h:892
int getCallArgOperandNo(Argument &Arg) const
Return the operand index of the underlying instruction associated with Arg.
Definition: CallSite.h:809
ImmutableCallSite(const Instruction *II)
Definition: CallSite.h:891
bool isInlineAsm() const
Definition: CallSite.h:304
static CallSite getEmptyKey()
Definition: CallSite.h:864
This class represents an incoming formal argument to a Function.
Definition: Argument.h:29
unsigned arg_size() const
Definition: CallSite.h:218
CallingConv::ID getCallingConv() const
Get the calling convention of the call.
Definition: CallSite.h:311
This class represents lattice values for constants.
Definition: AllocatorList.h:23
CallSite(Instruction *II)
Definition: CallSite.h:670
unsigned getParamAlignment(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
Definition: CallSite.h:405
PointerTy getPointer() const
bool operator!=(const CallSite &CS) const
Definition: CallSite.h:674
Various leaf nodes.
Definition: ISDOpcodes.h:59
bool onlyReadsMemory(unsigned OpNo) const
Definition: CallSite.h:622
bool isInAllocaArgument(unsigned ArgNo) const
Determine whether this argument is passed in an alloca.
Definition: CallSite.h:602
bool isBundleOperand(Value::const_user_iterator UI) const
Determine whether the passed iterator points to a bundle operand.
Definition: CallSite.h:161
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:228
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
Definition: CallSite.h:470
Attribute getAttribute(unsigned i, StringRef Kind) const
Definition: CallSite.h:384
void setDoesNotAccessMemory()
Definition: CallSite.h:448
bool returnDoesNotAlias() const
Determine if the return value is marked with NoAlias attribute.
Definition: CallSite.h:422
#define CALLSITE_DELEGATE_GETTER(METHOD)
Definition: CallSite.h:279
CallSiteBase(ValTy *II)
Definition: CallSite.h:67
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
Value * getCallArgOperand(Argument &Arg) const
Return the operand of the underlying instruction associated with Arg.
Definition: CallSite.h:823
This class represents a function call, abstracting a target machine&#39;s calling convention.
iterator_range< IterTy > args() const
Definition: CallSite.h:214
Optional< OperandBundleUse > getOperandBundle(uint32_t ID) const
Definition: CallSite.h:558
static unsigned getHashValue(const CallSite &CS)
Definition: CallSite.h:876
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:395
unsigned getBundleOperandsEndIndex() const
Definition: CallSite.h:542
F(f)
uint64_t getDereferenceableOrNullBytes(unsigned i) const
Extract the number of dereferenceable_or_null bytes for a call or parameter (0=unknown).
Definition: CallSite.h:417
block Block Frequency true
bool isCallee(const Use *U) const
Determine whether this Use is the callee operand&#39;s Use.
Definition: CallSite.h:147
CallSiteBase(CallTy *CI)
Definition: CallSite.h:65
bool isIndirectCall() const
Return true if the callsite is an indirect call.
Definition: CallSite.h:111
This defines the Use class.
The encoding of a callback with regards to the underlying instruction.
Definition: CallSite.h:711
CallSite(InvokeInst *II)
Definition: CallSite.h:669
bool isNoInline() const
Return true if the call should not be inlined.
Definition: CallSite.h:437
unsigned getBundleOperandsStartIndex() const
Definition: CallSite.h:538
PointerIntPair< InstrTy *, 1, bool > I
Definition: CallSite.h:62
void setOnlyAccessesInaccessibleMemory()
Definition: CallSite.h:482
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
Definition: CallSite.h:453
bool arg_empty() const
Definition: CallSite.h:217
bool doesNotReturn() const
Determine if the call cannot return.
Definition: CallSite.h:496
amdgpu Simplify well known AMD library false Value Value const Twine & Name
InstrTy * operator->() const
Definition: CallSite.h:92
unsigned data_operands_size() const
Definition: CallSite.h:258
A Use represents the edge between a Value definition and its users.
Definition: Use.h:55
CallSite(Value *V)
Definition: CallSite.h:671
bool isArgOperand(Value::const_user_iterator UI) const
Determine whether the passed iterator points to an argument operand.
Definition: CallSite.h:150
IterTy arg_end() const
Definition: CallSite.h:574
bool isArgOperand(const Use *U) const
Determine whether the passed use points to an argument operand.
Definition: CallSite.h:155
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:41
This file contains the simple types necessary to represent the attributes associated with functions a...
InstrTy * getInstruction() const
Definition: CallSite.h:91
bool isReturnNonNull() const
Return true if the return value is known to be not null.
Definition: CallSite.h:635
bool hasInAllocaArgument() const
Determine if there are is an inalloca argument.
Definition: CallSite.h:614
void setArgument(unsigned ArgNo, Value *newVal)
Definition: CallSite.h:190
int getCallArgOperandNo(unsigned ArgNo) const
Return the operand index of the underlying instruction associated with the function parameter number ...
Definition: CallSite.h:815
void setOnlyAccessesArgMemory()
Definition: CallSite.h:473
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
ValTy * getCalledValue() const
Return the pointer to function that is being called.
Definition: CallSite.h:99
IterTy data_operands_end() const
Definition: CallSite.h:248
Class to represent function types.
Definition: DerivedTypes.h:102
static bool setDoesNotThrow(Function &F)
IntType getInt() const
ValTy * getArgOperand(unsigned i) const
Definition: CallSite.h:296
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
Definition: CallSite.h:427
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of the intrinsic called by this CallSite, or Intrinsic::not_intrinsic if the ...
Definition: CallSite.h:133
unsigned getDataOperandNo(Value::const_user_iterator UI) const
Given a value use iterator, return the data operand corresponding to it.
Definition: CallSite.h:222
bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return true if the call or the callee has the given attribute.
Definition: CallSite.h:376
ParameterEncodingTy ParameterEncoding
Definition: CallSite.h:724
static bool isDirectCall(Use &U)
void setDoesNotReadMemory()
Definition: CallSite.h:464
bool isCall() const
Return true if a CallInst is enclosed.
Definition: CallSite.h:86
CallSite(CallSiteBase B)
Definition: CallSite.h:667
Optional< OperandBundleUse > getOperandBundle(StringRef Name) const
Definition: CallSite.h:554
bool isBundleOperand(const Use *U) const
Determine whether the passed use points to a bundle operand.
Definition: CallSite.h:166
void setAttributes(AttributeList PAL)
Set the parameter attributes of the call.
Definition: CallSite.h:332
bool isStrictFP() const
Return true if the call requires strict floating point semantics.
Definition: CallSite.h:432
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void setIsNoInline(bool Value=true)
Definition: CallSite.h:440
void addAttribute(unsigned i, Attribute Attr)
Definition: CallSite.h:340
Instruction * getInstruction() const
Return the underlying instruction.
Definition: CallSite.h:761
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
bool isIndirectCall() const
Return true if this ACS represents an indirect call.
Definition: CallSite.h:772
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if this function has the given attribute.
Definition: CallSite.h:361
bool doesNotReadMemory(unsigned OpNo) const
Definition: CallSite.h:627
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Definition: CallSite.h:356
static bool setOnlyReadsMemory(Function &F)
Function * 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:855
bool hasOperandBundles() const
Definition: CallSite.h:534
unsigned getNumTotalBundleOperands() const
Definition: CallSite.h:546
void setCallingConv(CallingConv::ID CC)
Set the calling convention of the call.
Definition: CallSite.h:315
bool isDataOperand(const Use *U) const
Determine whether the passed use points to a data operand.
Definition: CallSite.h:181
CallSite(CallInst *CI)
Definition: CallSite.h:668
bool isCallee(Value::const_user_iterator UI) const
Return true if UI is the use that defines the callee of this ACS.
Definition: CallSite.h:784
bool isDataOperand(Value::const_user_iterator UI) const
Determine whether the passed iterator points to a data operand.
Definition: CallSite.h:176
bool hasFnAttr(StringRef Kind) const
Return true if this function has the given attribute.
Definition: CallSite.h:366
bool operator<(const CallSite &CS) const
Definition: CallSite.h:675
static bool setDoesNotAccessMemory(Function &F)
void setNotConvergent()
Definition: CallSite.h:526
bool doesNotCapture(unsigned OpNo) const
Determine whether this data operand is not captured.
Definition: CallSite.h:592
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:648
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, and aliases.
Definition: Value.cpp:528
unsigned getNumArgOperands() const
Definition: CallSite.h:292
size_t size() const
Definition: SmallVector.h:52
unsigned getNumArgOperands() const
Return the number of parameters of the callee.
Definition: CallSite.h:800
Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const
Definition: CallSite.h:380
ImmutableCallSite(CallSite CS)
Definition: CallSite.h:893
static bool isEqual(const CallSite &LHS, const CallSite &RHS)
Definition: CallSite.h:880
bool doesNotAccessMemory(unsigned OpNo) const
Definition: CallSite.h:618
bool isInvoke() const
Return true if a InvokeInst is enclosed.
Definition: CallSite.h:89
void setCannotDuplicate()
Definition: CallSite.h:515
static CallSite getTombstoneKey()
Definition: CallSite.h:870
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool data_operands_empty() const
Definition: CallSite.h:255
bool doesNotReadMemory() const
Determine if the call does not access or only writes memory.
Definition: CallSite.h:461
ValTy * getArgument(unsigned ArgNo) const
Definition: CallSite.h:185
OperandBundleUse getOperandBundleAt(unsigned Index) const
Definition: CallSite.h:550
void removeAttribute(unsigned i, StringRef Kind)
Definition: CallSite.h:352
IterTy arg_begin() const
Definition: CallSite.h:570
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type *> Tys=None)
Return the function type for an intrinsic.
Definition: Function.cpp:975
void setOnlyAccessesInaccessibleMemOrArgMem()
Definition: CallSite.h:491
ImmutableCallSite(const InvokeInst *II)
Definition: CallSite.h:890
void setDoesNotThrow()
Definition: CallSite.h:507
bool onlyAccessesInaccessibleMemory() const
Determine if the function may only access memory that is inaccessible from the IR.
Definition: CallSite.h:479
IterTy data_operands_begin() const
data_operands_begin/data_operands_end - Return iterators iterating over the call / invoke argument li...
Definition: CallSite.h:244
bool isCallbackCall() const
Return true if this ACS represents a callback call.
Definition: CallSite.h:777
static const Function * getCalledFunction(const Value *V, bool LookThroughBitCast, bool &IsNoBuiltin)
bool NullPointerIsDefined(const Function *F, unsigned AS=0)
Check whether null pointer dereferencing is considered undefined behavior for a given function or an ...
Definition: Function.cpp:1436
BBTy * getParent() const
Get the basic block containing the call site.
Definition: CallSite.h:96
A range adaptor for a pair of iterators.
ImmutableCallSite(const CallInst *CI)
Definition: CallSite.h:889
bool isBundleOperand(unsigned Idx) const
Definition: CallSite.h:566
int getCallArgOperandNoForCallee() const
Return the operand index of the underlying instruction associated with the callee of this ACS...
Definition: CallSite.h:840
void setDoesNotReturn()
Definition: CallSite.h:499
unsigned getArgNo() const
Return the index of this formal argument in its containing function.
Definition: Argument.h:47
A lightweight accessor for an operand bundle meant to be passed around by value.
Definition: InstrTypes.h:913
void addAttribute(unsigned i, Attribute::AttrKind Kind)
Definition: CallSite.h:336
bool operator==(const CallSite &CS) const
Definition: CallSite.h:673
bool doesNotAccessMemory() const
Determine if the call does not access memory.
Definition: CallSite.h:445
user_iterator_impl< const User > const_user_iterator
Definition: Value.h:369
amdgpu Simplify well known AMD library false Value Value * Arg
could "use" a pointer
unsigned countOperandBundlesOfType(uint32_t ID) const
Definition: CallSite.h:562
FunTy * getCaller() const
Return the caller function for this call site.
Definition: CallSite.h:266
unsigned getNumOperandBundles() const
Definition: CallSite.h:530
bool cannotDuplicate() const
Determine if the call can be duplicated.
Definition: CallSite.h:512
#define CALLSITE_DELEGATE_SETTER(METHOD)
Definition: CallSite.h:285
CallSiteBase(InvokeTy *II)
Definition: CallSite.h:66
LLVM_NODISCARD bool empty() const
Definition: SmallVector.h:55
void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Definition: CallSite.h:581
iterator_range< IterTy > data_ops() const
Definition: CallSite.h:252
const Use * const_op_iterator
Definition: User.h:225
Establish a view to a call site for examination.
Definition: CallSite.h:886
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:106
static bool setOnlyAccessesArgMemory(Function &F)
#define I(x, y, z)
Definition: MD5.cpp:58
bool doesNotThrow() const
Determine if the call cannot unwind.
Definition: CallSite.h:504
void removeAttribute(unsigned i, Attribute::AttrKind Kind)
Definition: CallSite.h:348
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:322
bool isByValOrInAllocaArgument(unsigned ArgNo) const
Determine whether this argument is passed by value or in an alloca.
Definition: CallSite.h:607
Type * getType() const
Return the type of the instruction that generated this call site.
Definition: CallSite.h:263
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
Definition: CallSite.h:597
static void setCannotDuplicate(CoroIdInst *CoroId)
Definition: CoroEarly.cpp:146
Value * getCalledValue() const
Return the pointer to function that is being called.
Definition: CallSite.h:847
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:106
const unsigned Kind
CallSite getCallSite() const
Return the call site abstraction for the underlying instruction.
Definition: CallSite.h:764
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getRetAlignment() const
Extract the alignment of the return value.
Definition: CallSite.h:400
Value * getCallArgOperand(unsigned ArgNo) const
Return the operand of the underlying instruction associated with the function parameter number ArgNo ...
Definition: CallSite.h:829
bool isTailCall() const
Tests if this call site is marked as a tail call.
Definition: CallSite.h:275
AbstractCallSite.
Definition: CallSite.h:707
bool hasRetAttr(Attribute::AttrKind Kind) const
Return true if this return value has the given attribute.
Definition: CallSite.h:371
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:565
LLVM Value Representation.
Definition: Value.h:72
FunctionType * getFunctionType() const
Definition: CallSite.h:319
void setOnlyReadsMemory()
Definition: CallSite.h:456
unsigned getArgumentNo(Value::const_user_iterator I) const
Given a value use iterator, returns the argument that corresponds to it.
Definition: CallSite.h:198
Invoke instruction.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
AttributeList getAttributes() const
Get the parameter attributes of the call.
Definition: CallSite.h:328
bool isConvergent() const
Determine if the call is convergent.
Definition: CallSite.h:520
bool isDirectCall() const
Return true if this ACS represents a direct call.
Definition: CallSite.h:767
ValTy * getReturnedArgOperand() const
Definition: CallSite.h:300
bool isMustTailCall() const
Tests if this call site must be tail call optimized.
Definition: CallSite.h:270
void setCalledFunction(Value *V)
Set the callee to the specified value.
Definition: CallSite.h:125
void mutateFunctionType(FunctionType *Ty) const
Definition: CallSite.h:323
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Definition: CallSite.h:344
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...
Definition: Attributes.h:69
bool onlyAccessesInaccessibleMemOrArgMem() const
Determine if the function may only access memory that is either inaccessible from the IR or pointed t...
Definition: CallSite.h:488
bool isCallee(Value::const_user_iterator UI) const
Determine whether the passed iterator points to the callee operand&#39;s Use.
Definition: CallSite.h:142