LLVM  8.0.1
Public Member Functions | Static Public Member Functions | Friends | List of all members
llvm::Argument Class Referencefinal

This class represents an incoming formal argument to a Function. More...

#include "llvm/IR/Argument.h"

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

Public Member Functions

 Argument (Type *Ty, const Twine &Name="", Function *F=nullptr, unsigned ArgNo=0)
 Argument constructor. More...
 
const FunctiongetParent () const
 
FunctiongetParent ()
 
unsigned getArgNo () const
 Return the index of this formal argument in its containing function. More...
 
bool hasNonNullAttr () const
 Return true if this argument has the nonnull attribute. More...
 
uint64_t getDereferenceableBytes () const
 If this argument has the dereferenceable attribute, return the number of bytes known to be dereferenceable. More...
 
uint64_t getDereferenceableOrNullBytes () const
 If this argument has the dereferenceable_or_null attribute, return the number of bytes known to be dereferenceable. More...
 
bool hasByValAttr () const
 Return true if this argument has the byval attribute. More...
 
bool hasSwiftSelfAttr () const
 Return true if this argument has the swiftself attribute. More...
 
bool hasSwiftErrorAttr () const
 Return true if this argument has the swifterror attribute. More...
 
bool hasByValOrInAllocaAttr () const
 Return true if this argument has the byval attribute or inalloca attribute. More...
 
unsigned getParamAlignment () const
 If this is a byval or inalloca argument, return its alignment. More...
 
bool hasNestAttr () const
 Return true if this argument has the nest attribute. More...
 
bool hasNoAliasAttr () const
 Return true if this argument has the noalias attribute. More...
 
bool hasNoCaptureAttr () const
 Return true if this argument has the nocapture attribute. More...
 
bool hasStructRetAttr () const
 Return true if this argument has the sret attribute. More...
 
bool hasReturnedAttr () const
 Return true if this argument has the returned attribute. More...
 
bool onlyReadsMemory () const
 Return true if this argument has the readonly or readnone attribute. More...
 
bool hasInAllocaAttr () const
 Return true if this argument has the inalloca attribute. More...
 
bool hasZExtAttr () const
 Return true if this argument has the zext attribute. More...
 
bool hasSExtAttr () const
 Return true if this argument has the sext attribute. More...
 
void addAttrs (AttrBuilder &B)
 Add attributes to an argument. More...
 
void addAttr (Attribute::AttrKind Kind)
 
void addAttr (Attribute Attr)
 
void removeAttr (Attribute::AttrKind Kind)
 Remove attributes from an argument. More...
 
bool hasAttribute (Attribute::AttrKind Kind) const
 Check if an argument has a given attribute. More...
 
- Public Member Functions inherited from llvm::Value
 Value (const Value &)=delete
 
Valueoperator= (const Value &)=delete
 
void deleteValue ()
 Delete a pointer to a generic Value. More...
 
void dump () const
 Support for debugging, callable in GDB: V->dump() More...
 
TypegetType () const
 All values are typed, get the type of this value. More...
 
LLVMContextgetContext () const
 All values hold a context through their type. More...
 
bool hasName () const
 
ValueNamegetValueName () const
 
void setValueName (ValueName *VN)
 
StringRef getName () const
 Return a constant reference to the value's name. More...
 
void setName (const Twine &Name)
 Change the name of the value. More...
 
void takeName (Value *V)
 Transfer the name from V to this value. More...
 
void replaceAllUsesWith (Value *V)
 Change all uses of this to point to a new Value. More...
 
void replaceNonMetadataUsesWith (Value *V)
 Change non-metadata uses of this to point to a new Value. More...
 
void replaceUsesOutsideBlock (Value *V, BasicBlock *BB)
 replaceUsesOutsideBlock - Go through the uses list for this definition and make each use point to "V" instead of "this" when the use is outside the block. More...
 
void assertModuleIsMaterializedImpl () const
 
void assertModuleIsMaterialized () const
 
bool use_empty () const
 
bool materialized_use_empty () const
 
use_iterator materialized_use_begin ()
 
const_use_iterator materialized_use_begin () const
 
use_iterator use_begin ()
 
const_use_iterator use_begin () const
 
use_iterator use_end ()
 
const_use_iterator use_end () const
 
iterator_range< use_iteratormaterialized_uses ()
 
iterator_range< const_use_iteratormaterialized_uses () const
 
iterator_range< use_iteratoruses ()
 
iterator_range< const_use_iteratoruses () const
 
bool user_empty () const
 
user_iterator materialized_user_begin ()
 
const_user_iterator materialized_user_begin () const
 
user_iterator user_begin ()
 
const_user_iterator user_begin () const
 
user_iterator user_end ()
 
const_user_iterator user_end () const
 
Useruser_back ()
 
const Useruser_back () const
 
iterator_range< user_iteratormaterialized_users ()
 
iterator_range< const_user_iteratormaterialized_users () const
 
iterator_range< user_iteratorusers ()
 
iterator_range< const_user_iteratorusers () const
 
bool hasOneUse () const
 Return true if there is exactly one user of this value. More...
 
bool hasNUses (unsigned N) const
 Return true if this Value has exactly N users. More...
 
bool hasNUsesOrMore (unsigned N) const
 Return true if this value has N users or more. More...
 
bool isUsedInBasicBlock (const BasicBlock *BB) const
 Check if this value is used in the specified basic block. More...
 
unsigned getNumUses () const
 This method computes the number of uses of this Value. More...
 
void addUse (Use &U)
 This method should only be used by the Use class. More...
 
unsigned getValueID () const
 Return an ID for the concrete type of this object. More...
 
unsigned getRawSubclassOptionalData () const
 Return the raw optional flags value contained in this value. More...
 
void clearSubclassOptionalData ()
 Clear the optional flags contained in this value. More...
 
bool hasSameSubclassOptionalData (const Value *V) const
 Check the optional flags for equality. More...
 
bool hasValueHandle () const
 Return true if there is a value handle associated with this value. More...
 
bool isUsedByMetadata () const
 Return true if there is metadata referencing this value. More...
 
bool isSwiftError () const
 Return true if this value is a swifterror value. More...
 
const ValuestripPointerCasts () const
 Strip off pointer casts, all-zero GEPs, and aliases. More...
 
ValuestripPointerCasts ()
 
const ValuestripPointerCastsAndInvariantGroups () const
 Strip off pointer casts, all-zero GEPs, aliases and invariant group info. More...
 
ValuestripPointerCastsAndInvariantGroups ()
 
const ValuestripPointerCastsNoFollowAliases () const
 Strip off pointer casts and all-zero GEPs. More...
 
ValuestripPointerCastsNoFollowAliases ()
 
const ValuestripInBoundsConstantOffsets () const
 Strip off pointer casts and all-constant inbounds GEPs. More...
 
ValuestripInBoundsConstantOffsets ()
 
const ValuestripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset) const
 Accumulate offsets from stripInBoundsConstantOffsets(). More...
 
ValuestripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset)
 
const ValuestripInBoundsOffsets () const
 Strip off pointer casts and inbounds GEPs. More...
 
ValuestripInBoundsOffsets ()
 
uint64_t getPointerDereferenceableBytes (const DataLayout &DL, bool &CanBeNull) const
 Returns the number of bytes known to be dereferenceable for the pointer value. More...
 
unsigned getPointerAlignment (const DataLayout &DL) const
 Returns an alignment of the pointer value. More...
 
const ValueDoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB) const
 Translate PHI node to its predecessor from the given basic block. More...
 
ValueDoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB)
 
void mutateType (Type *Ty)
 Mutate the type of this Value to be of the specified type. More...
 
template<class Compare >
void sortUseList (Compare Cmp)
 Sort the use-list. More...
 
void reverseUseList ()
 Reverse the use-list. More...
 
void print (raw_ostream &O, bool IsForDebug=false) const
 Implement operator<< on Value. More...
 
void print (raw_ostream &O, ModuleSlotTracker &MST, bool IsForDebug=false) const
 
void printAsOperand (raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
 Print the name of this Value out to the specified raw_ostream. More...
 
void printAsOperand (raw_ostream &O, bool PrintType, ModuleSlotTracker &MST) const
 

Static Public Member Functions

static bool classof (const Value *V)
 Method for support type inquiry through isa, cast, and dyn_cast. More...
 

Friends

class Function
 

Additional Inherited Members

- Public Types inherited from llvm::Value
enum  ValueTy
 Concrete subclass of this. More...
 
using use_iterator = use_iterator_impl< Use >
 
using const_use_iterator = use_iterator_impl< const Use >
 
using user_iterator = user_iterator_impl< User >
 
using const_user_iterator = user_iterator_impl< const User >
 
- Static Public Attributes inherited from llvm::Value
static const unsigned MaxAlignmentExponent = 29
 The maximum alignment for instructions. More...
 
static const unsigned MaximumAlignment = 1u << MaxAlignmentExponent
 
- Protected Types inherited from llvm::Value
enum  : unsigned { NumUserOperandsBits = 28 }
 The number of operands in the subclass. More...
 
- Protected Member Functions inherited from llvm::Value
 Value (Type *Ty, unsigned scid)
 
 ~Value ()
 Value's destructor should be virtual by design, but that would require that Value and all of its subclasses have a vtable that effectively duplicates the information in the value ID. More...
 
unsigned short getSubclassDataFromValue () const
 
void setValueSubclassData (unsigned short D)
 
- Protected Attributes inherited from llvm::Value
unsigned char SubclassOptionalData: 7
 Hold subclass data that can be dropped. More...
 
unsigned NumUserOperands: NumUserOperandsBits
 
unsigned IsUsedByMD: 1
 
unsigned HasName: 1
 
unsigned HasHungOffUses: 1
 
unsigned HasDescriptor: 1
 

Detailed Description

This class represents an incoming formal argument to a Function.

A formal argument, since it is ``formal'', does not contain an actual value but instead represents the type, argument number, and attributes of an argument for a specific function. When used in the body of said function, the argument of course represents the value of the actual argument that the function was called with.

Definition at line 30 of file Argument.h.

Constructor & Destructor Documentation

◆ Argument()

Argument::Argument ( Type Ty,
const Twine Name = "",
Function F = nullptr,
unsigned  ArgNo = 0 
)
explicit

Argument constructor.

Definition at line 67 of file Function.cpp.

References llvm::Value::setName().

Referenced by llvm::Function::~Function().

Member Function Documentation

◆ addAttr() [1/2]

void Argument::addAttr ( Attribute::AttrKind  Kind)

Definition at line 173 of file Function.cpp.

References llvm::Function::addParamAttr(), getArgNo(), and getParent().

Referenced by getArgNo(), and LLVMSetParamAlignment().

◆ addAttr() [2/2]

void Argument::addAttr ( Attribute  Attr)

Definition at line 177 of file Function.cpp.

References llvm::Function::addParamAttr(), getArgNo(), and getParent().

◆ addAttrs()

void Argument::addAttrs ( AttrBuilder B)

◆ classof()

static bool llvm::Argument::classof ( const Value V)
inlinestatic

Method for support type inquiry through isa, cast, and dyn_cast.

Definition at line 123 of file Argument.h.

References llvm::Value::getValueID().

◆ getArgNo()

unsigned llvm::Argument::getArgNo ( ) const
inline

◆ getDereferenceableBytes()

uint64_t Argument::getDereferenceableBytes ( ) const

If this argument has the dereferenceable attribute, return the number of bytes known to be dereferenceable.

Otherwise, zero is returned.

Definition at line 117 of file Function.cpp.

References assert(), getArgNo(), llvm::Function::getParamDereferenceableBytes(), getParent(), and llvm::Value::getType().

Referenced by getArgNo(), and hasNonNullAttr().

◆ getDereferenceableOrNullBytes()

uint64_t Argument::getDereferenceableOrNullBytes ( ) const

If this argument has the dereferenceable_or_null attribute, return the number of bytes known to be dereferenceable.

Otherwise, zero is returned.

Definition at line 123 of file Function.cpp.

References assert(), getArgNo(), llvm::Function::getParamDereferenceableOrNullBytes(), getParent(), and llvm::Value::getType().

Referenced by getArgNo().

◆ getParamAlignment()

unsigned Argument::getParamAlignment ( ) const

If this is a byval or inalloca argument, return its alignment.

Definition at line 112 of file Function.cpp.

References assert(), getArgNo(), llvm::Function::getParamAlignment(), getParent(), and llvm::Value::getType().

Referenced by getArgNo(), and llvm::ObjectSizeOffsetVisitor::visitArgument().

◆ getParent() [1/2]

const Function* llvm::Argument::getParent ( ) const
inline

◆ getParent() [2/2]

Function* llvm::Argument::getParent ( )
inline

Definition at line 43 of file Argument.h.

◆ hasAttribute()

bool Argument::hasAttribute ( Attribute::AttrKind  Kind) const

◆ hasByValAttr()

bool Argument::hasByValAttr ( ) const

Return true if this argument has the byval attribute.

Definition at line 87 of file Function.cpp.

References llvm::Attribute::ByVal, llvm::Value::getType(), and hasAttribute().

Referenced by canPaddingBeAccessed(), getArgNo(), and PropagateConstantsIntoArguments().

◆ hasByValOrInAllocaAttr()

bool Argument::hasByValOrInAllocaAttr ( ) const

Return true if this argument has the byval attribute or inalloca attribute.

These attributes represent arguments being passed by value.

Definition at line 105 of file Function.cpp.

References llvm::AMDGPU::HSAMD::Kernel::Key::Attrs, llvm::Attribute::ByVal, getArgNo(), llvm::Function::getAttributes(), getParent(), llvm::Value::getType(), llvm::AttributeList::hasParamAttribute(), and llvm::Attribute::InAlloca.

Referenced by getArgNo(), and llvm::ObjectSizeOffsetVisitor::visitArgument().

◆ hasInAllocaAttr()

bool Argument::hasInAllocaAttr ( ) const

Return true if this argument has the inalloca attribute.

Definition at line 100 of file Function.cpp.

References llvm::Value::getType(), hasAttribute(), and llvm::Attribute::InAlloca.

Referenced by determinePointerReadAttrs(), getArgNo(), and PropagateConstantsIntoArguments().

◆ hasNestAttr()

bool Argument::hasNestAttr ( ) const

Return true if this argument has the nest attribute.

Definition at line 129 of file Function.cpp.

References llvm::Value::getType(), hasAttribute(), and llvm::Attribute::Nest.

Referenced by getArgNo().

◆ hasNoAliasAttr()

bool Argument::hasNoAliasAttr ( ) const

Return true if this argument has the noalias attribute.

Definition at line 134 of file Function.cpp.

References llvm::Value::getType(), hasAttribute(), and llvm::Attribute::NoAlias.

Referenced by getArgNo().

◆ hasNoCaptureAttr()

bool Argument::hasNoCaptureAttr ( ) const

Return true if this argument has the nocapture attribute.

Definition at line 139 of file Function.cpp.

References llvm::Value::getType(), hasAttribute(), and llvm::Attribute::NoCapture.

Referenced by getArgNo().

◆ hasNonNullAttr()

bool Argument::hasNonNullAttr ( ) const

Return true if this argument has the nonnull attribute.

Also returns true if at least one byte is known to be dereferenceable and the pointer is in addrspace(0).

Definition at line 76 of file Function.cpp.

References getArgNo(), getDereferenceableBytes(), getParent(), llvm::Value::getType(), llvm::Attribute::NonNull, and llvm::NullPointerIsDefined().

Referenced by getArgNo().

◆ hasReturnedAttr()

bool Argument::hasReturnedAttr ( ) const

Return true if this argument has the returned attribute.

Definition at line 149 of file Function.cpp.

References hasAttribute(), and llvm::Attribute::Returned.

Referenced by getArgNo().

◆ hasSExtAttr()

bool Argument::hasSExtAttr ( ) const

Return true if this argument has the sext attribute.

Definition at line 157 of file Function.cpp.

References hasAttribute(), and llvm::Attribute::SExt.

Referenced by getArgNo().

◆ hasStructRetAttr()

bool Argument::hasStructRetAttr ( ) const

Return true if this argument has the sret attribute.

Definition at line 144 of file Function.cpp.

References llvm::Value::getType(), hasAttribute(), and llvm::Attribute::StructRet.

Referenced by getArgNo().

◆ hasSwiftErrorAttr()

bool Argument::hasSwiftErrorAttr ( ) const

Return true if this argument has the swifterror attribute.

Definition at line 96 of file Function.cpp.

References getArgNo(), getParent(), llvm::Function::hasParamAttribute(), and llvm::Attribute::SwiftError.

Referenced by getArgNo().

◆ hasSwiftSelfAttr()

bool Argument::hasSwiftSelfAttr ( ) const

Return true if this argument has the swiftself attribute.

Definition at line 92 of file Function.cpp.

References getArgNo(), getParent(), llvm::Function::hasParamAttribute(), and llvm::Attribute::SwiftSelf.

Referenced by getArgNo().

◆ hasZExtAttr()

bool Argument::hasZExtAttr ( ) const

Return true if this argument has the zext attribute.

Definition at line 153 of file Function.cpp.

References hasAttribute(), and llvm::Attribute::ZExt.

Referenced by getArgNo().

◆ onlyReadsMemory()

bool Argument::onlyReadsMemory ( ) const

Return true if this argument has the readonly or readnone attribute.

Definition at line 161 of file Function.cpp.

References llvm::AMDGPU::HSAMD::Kernel::Key::Attrs, getArgNo(), llvm::Function::getAttributes(), getParent(), llvm::AttributeList::hasParamAttribute(), llvm::Attribute::ReadNone, and llvm::Attribute::ReadOnly.

Referenced by getArgNo().

◆ removeAttr()

void Argument::removeAttr ( Attribute::AttrKind  Kind)

Remove attributes from an argument.

Definition at line 181 of file Function.cpp.

References getArgNo(), getParent(), and llvm::Function::removeParamAttr().

Referenced by getArgNo().

Friends And Related Function Documentation

◆ Function

friend class Function
friend

Definition at line 34 of file Argument.h.


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