LLVM  mainline
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions
llvm::CallInst Class Reference

CallInst - This class represents a function call, abstracting a target machine's calling convention. More...

#include <Instructions.h>

Inheritance diagram for llvm::CallInst:
Inheritance graph
[legend]
Collaboration diagram for llvm::CallInst:
Collaboration graph
[legend]

List of all members.

Public Types

enum  TailCallKind { TCK_None = 0, TCK_Tail = 1, TCK_MustTail = 2 }

Public Member Functions

 ~CallInst () override
FunctionTypegetFunctionType () const
void mutateFunctionType (FunctionType *FTy)
TailCallKind getTailCallKind () const
bool isTailCall () const
bool isMustTailCall () const
void setTailCall (bool isTC=true)
void setTailCallKind (TailCallKind TCK)
 DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Value)
 Provide fast operand accessors.
unsigned getNumArgOperands () const
 getNumArgOperands - Return the number of call arguments.
ValuegetArgOperand (unsigned i) const
 getArgOperand/setArgOperand - Return/set the i-th call argument.
void setArgOperand (unsigned i, Value *v)
iterator_range< op_iteratorarg_operands ()
 arg_operands - iteration adapter for range-for loops.
iterator_range< const_op_iteratorarg_operands () const
 arg_operands - iteration adapter for range-for loops.
const UsegetArgOperandUse (unsigned i) const
 Wrappers for getting the Use of a call argument.
UsegetArgOperandUse (unsigned i)
CallingConv::ID getCallingConv () const
 getCallingConv/setCallingConv - Get or set the calling convention of this function call.
void setCallingConv (CallingConv::ID CC)
const AttributeSetgetAttributes () const
 getAttributes - Return the parameter attributes for this call.
void setAttributes (const AttributeSet &Attrs)
 setAttributes - Set the parameter attributes for this call.
void addAttribute (unsigned i, Attribute::AttrKind attr)
 addAttribute - adds the attribute to the list of attributes.
void removeAttribute (unsigned i, Attribute attr)
 removeAttribute - removes the attribute from the list of attributes.
void addDereferenceableAttr (unsigned i, uint64_t Bytes)
 adds the dereferenceable attribute to the list of attributes.
void addDereferenceableOrNullAttr (unsigned i, uint64_t Bytes)
 adds the dereferenceable_or_null attribute to the list of attributes.
bool hasFnAttr (Attribute::AttrKind A) const
 Determine whether this call has the given attribute.
bool paramHasAttr (unsigned i, Attribute::AttrKind A) const
 Determine whether the call or the callee has the given attributes.
unsigned getParamAlignment (unsigned i) const
 Extract the alignment for a call or parameter (0=unknown).
uint64_t getDereferenceableBytes (unsigned i) const
 Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
uint64_t getDereferenceableOrNullBytes (unsigned i) const
 Extract the number of dereferenceable_or_null bytes for a call or parameter (0=unknown).
bool isNoBuiltin () const
 Return true if the call should not be treated as a call to a builtin.
bool isNoInline () const
 Return true if the call should not be inlined.
void setIsNoInline ()
bool canReturnTwice () const
 Return true if the call can return twice.
void setCanReturnTwice ()
bool doesNotAccessMemory () const
 Determine if the call does not access memory.
void setDoesNotAccessMemory ()
bool onlyReadsMemory () const
 Determine if the call does not access or only reads memory.
void setOnlyReadsMemory ()
bool doesNotReturn () const
 Determine if the call cannot return.
void setDoesNotReturn ()
bool doesNotThrow () const
 Determine if the call cannot unwind.
void setDoesNotThrow ()
bool cannotDuplicate () const
 Determine if the call cannot be duplicated.
void setCannotDuplicate ()
bool hasStructRetAttr () const
 Determine if the call returns a structure through first pointer argument.
bool hasByValArgument () const
 Determine if any call argument is an aggregate passed by value.
FunctiongetCalledFunction () const
 getCalledFunction - Return the function called, or null if this is an indirect function invocation.
const ValuegetCalledValue () const
 getCalledValue - Get a pointer to the function that is invoked by this instruction.
ValuegetCalledValue ()
void setCalledFunction (Value *Fn)
 setCalledFunction - Set the function called.
void setCalledFunction (FunctionType *FTy, Value *Fn)
bool isInlineAsm () const
 isInlineAsm - Check if this call is an inline asm statement.

Static Public Member Functions

static CallInstCreate (Value *Func, ArrayRef< Value * > Args, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static CallInstCreate (FunctionType *Ty, Value *Func, ArrayRef< Value * > Args, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static CallInstCreate (Value *Func, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock *InsertAtEnd)
static CallInstCreate (Value *F, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static CallInstCreate (Value *F, const Twine &NameStr, BasicBlock *InsertAtEnd)
static InstructionCreateMalloc (Instruction *InsertBefore, Type *IntPtrTy, Type *AllocTy, Value *AllocSize, Value *ArraySize=nullptr, Function *MallocF=nullptr, const Twine &Name="")
 CreateMalloc - Generate the IR for a call to malloc: 1.
static InstructionCreateMalloc (BasicBlock *InsertAtEnd, Type *IntPtrTy, Type *AllocTy, Value *AllocSize, Value *ArraySize=nullptr, Function *MallocF=nullptr, const Twine &Name="")
 CreateMalloc - Generate the IR for a call to malloc: 1.
static InstructionCreateFree (Value *Source, Instruction *InsertBefore)
 CreateFree - Generate the IR for a call to the builtin free function.
static InstructionCreateFree (Value *Source, BasicBlock *InsertAtEnd)
 CreateFree - Generate the IR for a call to the builtin free function.
static bool classof (const Instruction *I)
static bool classof (const Value *V)
 Methods for support type inquiry through isa, cast, and dyn_cast:

Protected Member Functions

CallInstclone_impl () const override

Detailed Description

CallInst - This class represents a function call, abstracting a target machine's calling convention.

This class uses low bit of the SubClassData field to indicate whether or not this is a tail call. The rest of the bits hold the calling convention of the call.

Definition at line 1311 of file Instructions.h.


Member Enumeration Documentation

Enumerator:
TCK_None 
TCK_Tail 
TCK_MustTail 

Definition at line 1403 of file Instructions.h.


Constructor & Destructor Documentation

CallInst::~CallInst ( ) [override]

Definition at line 263 of file Instructions.cpp.


Member Function Documentation

void CallInst::addDereferenceableAttr ( unsigned  i,
uint64_t  Bytes 
)

adds the dereferenceable attribute to the list of attributes.

Definition at line 345 of file Instructions.cpp.

References llvm::AttributeSet::addDereferenceableAttr(), getAttributes(), llvm::Value::getContext(), and setAttributes().

void CallInst::addDereferenceableOrNullAttr ( unsigned  i,
uint64_t  Bytes 
)

adds the dereferenceable_or_null attribute to the list of attributes.

Definition at line 351 of file Instructions.cpp.

References llvm::AttributeSet::addDereferenceableOrNullAttr(), getAttributes(), llvm::Value::getContext(), and setAttributes().

arg_operands - iteration adapter for range-for loops.

Definition at line 1435 of file Instructions.h.

References llvm::User::op_begin(), and llvm::User::op_end().

Referenced by getVectorCallCost(), and llvm::InstCombiner::visitCallInst().

arg_operands - iteration adapter for range-for loops.

Definition at line 1442 of file Instructions.h.

References llvm::User::op_begin(), and llvm::User::op_end().

Determine if the call cannot be duplicated.

Definition at line 1558 of file Instructions.h.

References hasFnAttr(), and llvm::Attribute::NoDuplicate.

Referenced by HasNoDuplicateCall().

Return true if the call can return twice.

Definition at line 1522 of file Instructions.h.

References hasFnAttr(), and llvm::Attribute::ReturnsTwice.

static bool llvm::CallInst::classof ( const Instruction I) [inline, static]

Definition at line 1606 of file Instructions.h.

References llvm::Call, and llvm::Instruction::getOpcode().

Referenced by classof().

static bool llvm::CallInst::classof ( const Value V) [inline, static]
CallInst * CallInst::clone_impl ( ) const [override, protected, virtual]

Implements llvm::Instruction.

Definition at line 3629 of file Instructions.cpp.

References llvm::User::getNumOperands().

static CallInst* llvm::CallInst::Create ( Value Func,
ArrayRef< Value * >  Args,
const Twine NameStr = "",
Instruction InsertBefore = nullptr 
) [inline, static]
static CallInst* llvm::CallInst::Create ( FunctionType Ty,
Value Func,
ArrayRef< Value * >  Args,
const Twine NameStr = "",
Instruction InsertBefore = nullptr 
) [inline, static]

Definition at line 1353 of file Instructions.h.

References llvm::ArrayRef< T >::size().

static CallInst* llvm::CallInst::Create ( Value Func,
ArrayRef< Value * >  Args,
const Twine NameStr,
BasicBlock InsertAtEnd 
) [inline, static]

Definition at line 1359 of file Instructions.h.

References llvm::ArrayRef< T >::size().

static CallInst* llvm::CallInst::Create ( Value F,
const Twine NameStr = "",
Instruction InsertBefore = nullptr 
) [inline, static]

Definition at line 1365 of file Instructions.h.

static CallInst* llvm::CallInst::Create ( Value F,
const Twine NameStr,
BasicBlock InsertAtEnd 
) [inline, static]

Definition at line 1369 of file Instructions.h.

Instruction * CallInst::CreateFree ( Value Source,
Instruction InsertBefore 
) [static]

CreateFree - Generate the IR for a call to the builtin free function.

Definition at line 523 of file Instructions.cpp.

References createFree().

Referenced by LLVMBuildFree(), and PerformHeapAllocSRoA().

Instruction * CallInst::CreateFree ( Value Source,
BasicBlock InsertAtEnd 
) [static]

CreateFree - Generate the IR for a call to the builtin free function.

Note: This function does not add the call to the basic block, that is the responsibility of the caller.

Definition at line 530 of file Instructions.cpp.

References createFree().

Instruction * CallInst::CreateMalloc ( Instruction InsertBefore,
Type IntPtrTy,
Type AllocTy,
Value AllocSize,
Value ArraySize = nullptr,
Function MallocF = nullptr,
const Twine Name = "" 
) [static]

CreateMalloc - Generate the IR for a call to malloc: 1.

Compute the malloc call's argument as the specified type's size, possibly multiplied by the array size if the array size is not constant 1. 2. Call malloc with that argument. 3. Bitcast the result of the malloc call to the specified type.

Definition at line 465 of file Instructions.cpp.

References createMalloc().

Referenced by LLVMBuildArrayMalloc(), LLVMBuildMalloc(), PerformHeapAllocSRoA(), and TryToOptimizeStoreOfMallocToGlobal().

Instruction * CallInst::CreateMalloc ( BasicBlock InsertAtEnd,
Type IntPtrTy,
Type AllocTy,
Value AllocSize,
Value ArraySize = nullptr,
Function MallocF = nullptr,
const Twine Name = "" 
) [static]

CreateMalloc - Generate the IR for a call to malloc: 1.

Compute the malloc call's argument as the specified type's size, possibly multiplied by the array size if the array size is not constant 1. 2. Call malloc with that argument. 3. Bitcast the result of the malloc call to the specified type. Note: This function does not add the bitcast to the basic block, that is the responsibility of the caller.

Definition at line 482 of file Instructions.cpp.

References createMalloc().

Provide fast operand accessors.

Determine if the call does not access memory.

Definition at line 1530 of file Instructions.h.

References hasFnAttr(), and llvm::Attribute::ReadNone.

Referenced by onlyReadsMemory().

bool llvm::CallInst::doesNotReturn ( ) const [inline]

Determine if the call cannot return.

Definition at line 1546 of file Instructions.h.

References hasFnAttr(), and llvm::Attribute::NoReturn.

bool llvm::CallInst::doesNotThrow ( ) const [inline]

Determine if the call cannot unwind.

Definition at line 1552 of file Instructions.h.

References hasFnAttr(), and llvm::Attribute::NoUnwind.

Referenced by HandleCallsInBlockInlinedThroughInvoke(), and llvm::InstCombiner::visitCallInst().

getArgOperand/setArgOperand - Return/set the i-th call argument.

Definition at line 1431 of file Instructions.h.

References llvm::User::getOperand().

Referenced by llvm::checkBinaryFloatSignature(), llvm::checkUnaryFloatSignature(), computeArraySize(), computeKnownBitsFromAssume(), llvm::ComputeUsesVAFloatArgument(), detectLog2OfHalf(), llvm::DbgDeclareInst::getAddress(), llvm::MemIntrinsic::getAlignmentCst(), llvm::MemIntrinsic::getAlignmentType(), llvm::VAStartInst::getArgList(), llvm::VAEndInst::getArgList(), llvm::VACopyInst::getDest(), llvm::InstrProfIncrementInst::getHash(), llvm::InstrProfIncrementInst::getIndex(), llvm::MemIntrinsic::getLength(), getLocForWrite(), llvm::InstrProfIncrementInst::getName(), llvm::InstrProfIncrementInst::getNumCounters(), llvm::DbgValueInst::getOffset(), llvm::AArch64TTIImpl::getOrCreateResultFromMemIntrinsic(), llvm::MemIntrinsic::getRawDest(), llvm::DbgDeclareInst::getRawExpression(), llvm::DbgValueInst::getRawExpression(), llvm::MemTransferInst::getRawSource(), llvm::DbgDeclareInst::getRawVariable(), llvm::DbgValueInst::getRawVariable(), llvm::VACopyInst::getSrc(), llvm::AArch64TTIImpl::getTgtMemIntrinsic(), llvm::AArch64TargetLowering::getTgtMemIntrinsic(), llvm::ARMTargetLowering::getTgtMemIntrinsic(), llvm::NVPTXTargetLowering::getTgtMemIntrinsic(), llvm::PPCTargetLowering::getTgtMemIntrinsic(), llvm::DbgValueInst::getValue(), llvm::MemSetInst::getValue(), getVectorIntrinsicCost(), llvm::MemIntrinsic::getVolatileCst(), handleBranchExpect(), handleSwitchExpect(), isDynamicConstant(), isReportingError(), lowerExpectIntrinsic(), llvm::IntrinsicLowering::LowerIntrinsicCall(), llvm::IntrinsicLowering::LowerToByteSwap(), llvm::parseEHActions(), PerformHeapAllocSRoA(), ReplaceFPIntrinsicWithCall(), ScalarizeMaskedLoad(), ScalarizeMaskedStore(), llvm::FastISel::selectIntrinsicCall(), llvm::FastISel::selectPatchpoint(), SimplifyX86insertps(), SimplifyX86vperm2(), tryToMoveFreeBeforeNullTest(), TryToOptimizeStoreOfMallocToGlobal(), llvm::UpgradeIntrinsicCall(), llvm::InstCombiner::visitCallInst(), llvm::InstCombiner::visitFCmpInst(), llvm::InstCombiner::visitFPTrunc(), llvm::InstCombiner::visitFree(), and WriteInstruction().

Definition at line 1448 of file Instructions.h.

References llvm::User::getOperandUse().

getAttributes - Return the parameter attributes for this call.

Definition at line 1462 of file Instructions.h.

Referenced by addAttribute(), addDereferenceableAttr(), addDereferenceableOrNullAttr(), HandleCallsInBlockInlinedThroughInvoke(), makeStatepointExplicitImpl(), removeAttribute(), and WriteInstruction().

Definition at line 1585 of file Instructions.h.

References llvm::User::Op().

uint64_t llvm::CallInst::getDereferenceableBytes ( unsigned  i) const [inline]

Extract the number of dereferenceable bytes for a call or parameter (0=unknown).

Definition at line 1498 of file Instructions.h.

References llvm::AttributeSet::getDereferenceableBytes().

Extract the number of dereferenceable_or_null bytes for a call or parameter (0=unknown).

Definition at line 1504 of file Instructions.h.

References llvm::AttributeSet::getDereferenceableOrNullBytes().

Definition at line 1395 of file Instructions.h.

Referenced by WriteInstruction().

Extract the alignment for a call or parameter (0=unknown).

Definition at line 1492 of file Instructions.h.

References llvm::AttributeSet::getParamAlignment().

Determine if any call argument is an aggregate passed by value.

Definition at line 1571 of file Instructions.h.

References llvm::Attribute::ByVal, and llvm::AttributeSet::hasAttrSomewhere().

Determine whether this call has the given attribute.

Definition at line 1482 of file Instructions.h.

References llvm::Attribute::NoBuiltin.

Referenced by cannotDuplicate(), canReturnTwice(), doesNotAccessMemory(), doesNotReturn(), doesNotThrow(), isNoInline(), isTrigLibCall(), and onlyReadsMemory().

Determine if the call returns a structure through first pointer argument.

Definition at line 1565 of file Instructions.h.

References paramHasAttr(), and llvm::Attribute::StructRet.

bool llvm::CallInst::isInlineAsm ( ) const [inline]

isInlineAsm - Check if this call is an inline asm statement.

Definition at line 1601 of file Instructions.h.

References llvm::User::Op().

Referenced by needsStatepoint().

bool llvm::CallInst::isNoBuiltin ( ) const [inline]

Return true if the call should not be treated as a call to a builtin.

Definition at line 1510 of file Instructions.h.

References llvm::Attribute::Builtin, and llvm::Attribute::NoBuiltin.

Referenced by getVectorCallCost(), and llvm::LibCallSimplifier::optimizeCall().

bool llvm::CallInst::isNoInline ( ) const [inline]

Return true if the call should not be inlined.

Definition at line 1516 of file Instructions.h.

References hasFnAttr(), and llvm::Attribute::NoInline.

bool llvm::CallInst::isTailCall ( ) const [inline]

Determine if the call does not access or only reads memory.

Definition at line 1538 of file Instructions.h.

References doesNotAccessMemory(), hasFnAttr(), and llvm::Attribute::ReadOnly.

Referenced by llvm::checkBinaryFloatSignature(), and llvm::checkUnaryFloatSignature().

Determine whether the call or the callee has the given attributes.

Definition at line 365 of file Instructions.cpp.

References F(), getCalledFunction(), and llvm::AttributeSet::hasAttribute().

Referenced by hasStructRetAttr().

removeAttribute - removes the attribute from the list of attributes.

Definition at line 336 of file Instructions.cpp.

References getAttributes(), llvm::Value::getContext(), llvm::AttributeSet::removeAttributes(), and setAttributes().

void llvm::CallInst::setArgOperand ( unsigned  i,
Value v 
) [inline]
void llvm::CallInst::setAttributes ( const AttributeSet Attrs) [inline]
void llvm::CallInst::setCalledFunction ( Value Fn) [inline]

setCalledFunction - Set the function called.

Definition at line 1588 of file Instructions.h.

References llvm::Value::getType().

Referenced by llvm::InstCombiner::visitCallInst().

void llvm::CallInst::setCalledFunction ( FunctionType FTy,
Value Fn 
) [inline]

Definition at line 1593 of file Instructions.h.

References llvm::Value::getType(), and llvm::User::Op().

void llvm::CallInst::setIsNoInline ( ) [inline]
void llvm::CallInst::setTailCall ( bool  isTC = true) [inline]

The documentation for this class was generated from the following files: