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