protected:
PointerIntPair<InstrTy*, 1, bool> I;
public:
- CallSiteBase() : I(0, false) {}
+ CallSiteBase() : I(nullptr, false) {}
CallSiteBase(CallTy *CI) : I(CI, true) { assert(CI); }
CallSiteBase(InvokeTy *II) : I(II, false) { assert(II); }
CallSiteBase(ValTy *II) { *this = get(II); }
InstrTy *getInstruction() const { return I.getPointer(); }
InstrTy *operator->() const { return I.getPointer(); }
- LLVM_EXPLICIT operator bool() const { return I.getPointer(); }
+ explicit operator bool() const { return I.getPointer(); }
/// getCalledValue - Return the pointer to function that is being called.
///
/// isCallee - Determine whether the passed iterator points to the
/// callee operand's Use.
- ///
- bool isCallee(Value::const_use_iterator UI) const {
- return getCallee() == &UI.getUse();
+ bool isCallee(Value::const_user_iterator UI) const {
+ return isCallee(&UI.getUse());
}
+ /// Determine whether this Use is the callee operand's Use.
+ bool isCallee(const Use *U) const { return getCallee() == U; }
+
ValTy *getArgument(unsigned ArgNo) const {
assert(arg_begin() + ArgNo < arg_end() && "Argument # out of range!");
return *(arg_begin() + ArgNo);
/// Given a value use iterator, returns the argument that corresponds to it.
/// Iterator must actually correspond to an argument.
- unsigned getArgumentNo(Value::const_use_iterator I) const {
+ unsigned getArgumentNo(Value::const_user_iterator I) const {
+ return getArgumentNo(&I.getUse());
+ }
+
+ /// Given a use for an argument, get the argument number that corresponds to
+ /// it.
+ unsigned getArgumentNo(const Use *U) const {
assert(getInstruction() && "Not a call or invoke instruction!");
- assert(arg_begin() <= &I.getUse() && &I.getUse() < arg_end()
+ assert(arg_begin() <= U && U < arg_end()
&& "Argument # out of range!");
- return &I.getUse() - arg_begin();
+ return U - arg_begin();
}
/// arg_iterator - The type of iterator to use when looping over actual
///
FunTy *getCaller() const { return (*this)->getParent()->getParent(); }
+ /// \brief Tests if this call site must be tail call optimized. Only a
+ /// CallInst can be tail call optimized.
+ bool isMustTailCall() const {
+ return isCall() && cast<CallInst>(getInstruction())->isMustTailCall();
+ }
+
+ /// \brief Tests if this call site is marked as a tail call.
+ bool isTailCall() const {
+ return isCall() && cast<CallInst>(getInstruction())->isTailCall();
+ }
+
#define CALLSITE_DELEGATE_GETTER(METHOD) \
InstrTy *II = getInstruction(); \
return isCall() \
CALLSITE_DELEGATE_GETTER(getParamAlignment(i));
}
+ /// @brief Extract the number of dereferenceable bytes for a call or
+ /// parameter (0=unknown).
+ uint64_t getDereferenceableBytes(uint16_t i) const {
+ CALLSITE_DELEGATE_GETTER(getDereferenceableBytes(i));
+ }
+
/// \brief Return true if the call should not be treated as a call to a
/// builtin.
bool isNoBuiltin() const {
paramHasAttr(ArgNo + 1, Attribute::ReadNone);
}
+ /// @brief Return true if the return value is known to be not null.
+ /// This may be because it has the nonnull attribute, or because at least
+ /// one byte is dereferenceable and the pointer is in addrspace(0).
+ bool isReturnNonNull() const {
+ if (paramHasAttr(0, Attribute::NonNull))
+ return true;
+ else if (getDereferenceableBytes(0) > 0 &&
+ getType()->getPointerAddressSpace() == 0)
+ return true;
+
+ return false;
+ }
+
/// hasArgument - Returns true if this CallSite passes the given Value* as an
/// argument to the called function.
bool hasArgument(const Value *Arg) const {