26 #ifndef LLVM_IR_CALLSITE_H
27 #define LLVM_IR_CALLSITE_H
49 template <
typename FunTy =
const Function,
51 typename ValTy =
const Value,
52 typename UserTy =
const User,
53 typename UseTy =
const Use,
54 typename InstrTy =
const Instruction,
55 typename CallTy =
const CallInst,
56 typename InvokeTy =
const InvokeInst,
74 if (InstrTy *II = dyn_cast<InstrTy>(V)) {
77 else if (II->getOpcode() == Instruction::Invoke)
126 return F->getIntrinsicID();
163 unsigned OperandNo = U - (*this)->op_begin();
240 return (*this)->op_begin();
244 return (*this)->op_end() - (
isCall() ? 1 : 3);
275 #define CALLSITE_DELEGATE_GETTER(METHOD) \
276 InstrTy *II = getInstruction(); \
278 ? cast<CallInst>(II)->METHOD \
279 : cast<InvokeInst>(II)->METHOD
281 #define CALLSITE_DELEGATE_SETTER(METHOD) \
282 InstrTy *II = getInstruction(); \
284 cast<CallInst>(II)->METHOD; \
286 cast<InvokeInst>(II)->METHOD
536 #undef CALLSITE_DELEGATE_GETTER
537 #undef CALLSITE_DELEGATE_SETTER
592 getType()->getPointerAddressSpace() == 0)
603 if (AI->get() == Arg)
609 IterTy getCallee()
const {
618 Instruction, CallInst, InvokeInst,
645 CS.
I = BaseInfo::getEmptyKey();
651 CS.
I = BaseInfo::getTombstoneKey();
656 return BaseInfo::getHashValue(CS.
I);
677 #endif // LLVM_IR_CALLSITE_H
Attribute getAttribute(unsigned i, StringRef Kind) const
FunTy * getCaller() const
getCaller - Return the caller function for this call site
ImmutableCallSite(const Value *V)
ImmutableCallSite(const Instruction *II)
unsigned getBundleOperandsStartIndex() const
void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
static CallSite getEmptyKey()
unsigned getNumOperandBundles() const
CallSite(Instruction *II)
bool doesNotCapture(unsigned OpNo) const
Determine whether this data operand is not captured.
bool data_operands_empty() const
void setDoesNotAccessMemory()
#define CALLSITE_DELEGATE_GETTER(METHOD)
unsigned getBundleOperandsEndIndex() const
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
BBTy * getParent() const
Get the basic block containing the call site.
This class represents a function call, abstracting a target machine's calling convention.
bool cannotDuplicate() const
Determine if the call can be duplicated.
bool isConvergent() const
Determine if the call is convergent.
bool hasInAllocaArgument() const
Determine if there are is an inalloca argument.
void setAttributes(AttributeSet PAL)
Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const
static unsigned getHashValue(const CallSite &CS)
uint64_t getDereferenceableBytes(uint16_t i) const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
InstrTy * operator->() const
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
bool isCallee(const Use *U) const
Determine whether this Use is the callee operand's Use.
bool isMustTailCall() const
Tests if this call site must be tail call optimized.
This defines the Use class.
bool isByValOrInAllocaArgument(unsigned ArgNo) const
Determine whether this argument is passed by value or in an alloca.
unsigned arg_size() const
PointerIntPair< InstrTy *, 1, bool > I
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
unsigned getDataOperandNo(Value::const_user_iterator UI) const
Given a value use iterator, returns the data operand that corresponds to it.
bool doesNotReturn() const
Determine if the call cannot return.
bool isBundleOperand(Value::const_user_iterator UI) const
Determine whether the passed iterator points to a bundle operand.
bool isArgOperand(Value::const_user_iterator UI) const
Determine whether the passed iterator points to an argument operand.
bool operator==(const CallSite &CS) const
bool onlyReadsMemory(unsigned OpNo) const
bool doesNotAlias(unsigned n) const
Determine if the parameter or return value is marked with NoAlias attribute.
A Use represents the edge between a Value definition and its users.
ValTy * getCalledValue() const
getCalledValue - Return the pointer to function that is being called.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool isCall() const
isCall - true if a CallInst is enclosed.
This file contains the simple types necessary to represent the attributes associated with functions a...
bool isArgOperand(const Use *U) const
Determine whether the passed use points to an argument operand.
void setArgument(unsigned ArgNo, Value *newVal)
void setOnlyAccessesArgMemory()
IterTy data_operands_begin() const
data_operands_begin/data_operands_end - Return iterators iterating over the call / invoke argument li...
bool isBundleOperand(unsigned Idx) const
Class to represent function types.
CallingConv::ID getCallingConv() const
getCallingConv/setCallingConv - get or set the calling convention of the call.
PointerTy getPointer() const
Function Alias Analysis false
void mutateFunctionType(FunctionType *Ty) const
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
void setDoesNotReadMemory()
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
bool hasOperandBundles() const
unsigned getDataOperandNo(const Use *U) const
Given a use for a data operand, get the data operand number that corresponds to it.
ImmutableCallSite()=default
bool isInvoke() const
isInvoke - true if a InvokeInst is enclosed.
ValTy * getReturnedArgOperand() const
iterator_range< IterTy > args() const
Optional< OperandBundleUse > getOperandBundle(StringRef Name) const
FunctionType * getFunctionType() const
void setIsNoInline(bool Value=true)
void addAttribute(unsigned i, Attribute Attr)
bool isReturnNonNull() const
Return true if the return value is known to be not null.
The instances of the Type class are immutable: once they are created, they are never changed...
unsigned getArgumentNo(Value::const_user_iterator I) const
Given a value use iterator, returns the argument that corresponds to it.
bool isNoInline() const
Return true if the call should not be inlined.
bool dataOperandHasImpliedAttr(unsigned i, Attribute::AttrKind Kind) const
Return true if the data operand at index i directly or indirectly has the attribute A...
uint16_t getParamAlignment(uint16_t i) const
Extract the alignment for a call or parameter (0=unknown).
bool isDataOperand(const Use *U) const
Determine whether the passed use points to a data operand.
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
iterator_range< IterTy > data_ops() const
void setCallingConv(CallingConv::ID CC)
bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if this function has the given attribute.
unsigned getNumTotalBundleOperands() const
Type * getType() const
getType - Return the type of the instruction that generated this call site
Optional< OperandBundleUse > getOperandBundle(uint32_t ID) const
ImmutableCallSite(CallSite CS)
IterTy arg_iterator
arg_iterator - The type of iterator to use when looping over actual arguments at this call site...
OperandBundleUse getOperandBundleAt(unsigned Index) const
static bool isEqual(const CallSite &LHS, const CallSite &RHS)
unsigned countOperandBundlesOfType(uint32_t ID) const
bool doesNotAccessMemory() const
Determine if the call does not access memory.
AttributeSet getAttributes() const
getAttributes/setAttributes - get or set the parameter attributes of the call.
void setCannotDuplicate()
static CallSite getTombstoneKey()
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool operator!=(const CallSite &CS) const
bool isDataOperand(Value::const_user_iterator UI) const
Determine whether the passed iterator points to a data operand.
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
bool doesNotReadMemory() const
Determine if the call does not access or only writes memory.
InstrTy * getInstruction() const
void removeAttribute(unsigned i, StringRef Kind)
ValTy * getArgument(unsigned ArgNo) const
ImmutableCallSite(const InvokeInst *II)
bool isBundleOperand(const Use *U) const
Determine whether the passed use points to a bundle operand.
unsigned data_operands_size() const
unsigned getArgumentNo(const Use *U) const
Given a use for an argument, get the argument number that corresponds to it.
A range adaptor for a pair of iterators.
unsigned getNumArgOperands() const
ImmutableCallSite(const CallInst *CI)
A lightweight accessor for an operand bundle meant to be passed around by value.
void addAttribute(unsigned i, Attribute::AttrKind Kind)
bool doesNotAccessMemory(unsigned OpNo) const
bool hasFnAttr(StringRef Kind) const
Return true if this function has the given attribute.
bool isInAllocaArgument(unsigned ArgNo) const
Determine whether this argument is passed in an alloca.
bool hasArgument(const Value *Arg) const
hasArgument - Returns true if this CallSite passes the given Value* as an argument to the called func...
user_iterator_impl< const User > const_user_iterator
#define CALLSITE_DELEGATE_SETTER(METHOD)
CallSiteBase(InvokeTy *II)
ImmutableCallSite - establish a view to a call site for examination.
bool paramHasAttr(unsigned i, Attribute::AttrKind Kind) const
Return true if the call or the callee has the given attribute.
void removeAttribute(unsigned i, Attribute::AttrKind Kind)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
bool operator<(const CallSite &CS) const
uint64_t getDereferenceableOrNullBytes(uint16_t i) const
Extract the number of dereferenceable_or_null bytes for a call or parameter (0=unknown).
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
FunTy * getCalledFunction() const
getCalledFunction - Return the function being called if this is a direct call, otherwise return null ...
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of the intrinsic called by this CallSite, or Intrinsic::not_intrinsic if the ...
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
void setOnlyReadsMemory()
ValTy * getArgOperand(unsigned i) const
bool isTailCall() const
Tests if this call site is marked as a tail call.
StringRef - Represent a constant reference to a string, i.e.
IterTy data_operands_end() const
void setCalledFunction(Value *V)
setCalledFunction - Set the callee to the specified value.
bool doesNotThrow() const
Determine if the call cannot unwind.
bool isCallee(Value::const_user_iterator UI) const
isCallee - Determine whether the passed iterator points to the callee operand's Use.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...
IterTy data_operand_iterator
Type of iterator to use when looping over data operands at this call site (see below).
const Use * const_op_iterator