LLVM  3.7.0
Public Member Functions | Static Public Member Functions | Friends | List of all members
llvm::Argument Class Reference

LLVM Argument representation. More...

#include <Argument.h>

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

Public Member Functions

 Argument (Type *Ty, const Twine &Name="", Function *F=nullptr)
 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 on it in its containing function. More...
 
uint64_t getDereferenceableBytes () const
 If this argument has the dereferenceable attribute on it in its containing function, return the number of bytes known to be dereferenceable. More...
 
uint64_t getDereferenceableOrNullBytes () const
 If this argument has the dereferenceable_or_null attribute on it in its containing function, return the number of bytes known to be dereferenceable. More...
 
bool hasByValAttr () const
 Return true if this argument has the byval attribute on it in its containing function. More...
 
bool hasByValOrInAllocaAttr () const
 Return true if this argument has the byval attribute or inalloca attribute on it in its containing function. 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 on it in its containing function. More...
 
bool hasNoAliasAttr () const
 Return true if this argument has the noalias attribute on it in its containing function. More...
 
bool hasNoCaptureAttr () const
 Return true if this argument has the nocapture attribute on it in its containing function. More...
 
bool hasStructRetAttr () const
 Return true if this argument has the sret attribute on it in its containing function. More...
 
bool hasReturnedAttr () const
 Return true if this argument has the returned attribute on it in its containing function. More...
 
bool onlyReadsMemory () const
 Return true if this argument has the readonly or readnone attribute on it in its containing function. More...
 
bool hasInAllocaAttr () const
 Return true if this argument has the inalloca attribute on it in its containing function. More...
 
bool hasZExtAttr () const
 Return true if this argument has the zext attribute on it in its containing function. More...
 
bool hasSExtAttr () const
 Return true if this argument has the sext attribute on it in its containing function. More...
 
void addAttr (AttributeSet AS)
 Add a Attribute to an argument. More...
 
void removeAttr (AttributeSet AS)
 Remove a Attribute from an argument. More...
 
- Public Member Functions inherited from llvm::Value
virtual ~Value ()
 
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 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...
 
bool use_empty () const
 
use_iterator use_begin ()
 
const_use_iterator use_begin () const
 
use_iterator use_end ()
 
const_use_iterator use_end () const
 
iterator_range< use_iteratoruses ()
 
iterator_range
< const_use_iterator
uses () const
 
bool user_empty () 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_iteratorusers ()
 
iterator_range
< const_user_iterator
users () 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...
 
void intersectOptionalDataWith (const Value *V)
 Clear any optional flags not set in the given Value. 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...
 
ValuestripPointerCasts ()
 Strip off pointer casts, all-zero GEPs, and aliases. More...
 
const ValuestripPointerCasts () const
 
ValuestripPointerCastsNoFollowAliases ()
 Strip off pointer casts and all-zero GEPs. More...
 
const ValuestripPointerCastsNoFollowAliases () const
 
ValuestripInBoundsConstantOffsets ()
 Strip off pointer casts and all-constant inbounds GEPs. More...
 
const ValuestripInBoundsConstantOffsets () const
 
ValuestripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset)
 Accumulate offsets from stripInBoundsConstantOffsets(). More...
 
const ValuestripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset) const
 
ValuestripInBoundsOffsets ()
 Strip off pointer casts and inbounds GEPs. More...
 
const ValuestripInBoundsOffsets () const
 
ValueDoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB)
 Translate PHI node to its predecessor from the given basic block. More...
 
const ValueDoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB) const
 
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) const
 Implement operator<< on Value. More...
 
void print (raw_ostream &O, ModuleSlotTracker &MST) 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
 
- Public Member Functions inherited from llvm::ilist_node< Argument >
ArgumentgetPrevNode ()
 Get the previous node, or 0 for the list head. More...
 
const ArgumentgetPrevNode () const
 Get the previous node, or 0 for the list head. More...
 
ArgumentgetNextNode ()
 Get the next node, or 0 for the list tail. More...
 
const ArgumentgetNextNode () const
 Get the next node, or 0 for the list tail. More...
 

Static Public Member Functions

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

Friends

class SymbolTableListTraits< Argument, Function >
 

Additional Inherited Members

- Public Types inherited from llvm::Value
enum  ValueTy
 Concrete subclass of this. More...
 
typedef use_iterator_impl< Useuse_iterator
 
typedef use_iterator_impl
< const Use
const_use_iterator
 
typedef user_iterator_impl< Useruser_iterator
 
typedef user_iterator_impl
< const User
const_user_iterator
 
- 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 = 29 }
 The number of operands in the subclass. More...
 
- Protected Member Functions inherited from llvm::Value
 Value (Type *Ty, unsigned scid)
 
unsigned short getSubclassDataFromValue () const
 
void setValueSubclassData (unsigned short D)
 
- Protected Member Functions inherited from llvm::ilist_node< Argument >
 ilist_node ()
 
- Protected Attributes inherited from llvm::Value
unsigned char SubclassOptionalData: 7
 Hold subclass data that can be dropped. More...
 
unsigned NumUserOperands: NumUserOperandsBits
 
bool IsUsedByMD: 1
 
bool HasName: 1
 
bool HasHungOffUses: 1
 

Detailed Description

LLVM Argument representation.

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 35 of file Argument.h.

Constructor & Destructor Documentation

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

Constructor.

If F is specified, the argument is inserted at the end of the argument list for F.

Definition at line 47 of file Function.cpp.

References llvm::Function::getArgumentList(), llvm::iplist< NodeTy, Traits >::push_back(), and llvm::Value::setName().

Member Function Documentation

void Argument::addAttr ( AttributeSet  AS)

Add a Attribute to an argument.

addAttr - Add attributes to an argument.

Definition at line 192 of file Function.cpp.

References llvm::Function::addAttributes(), getArgNo(), llvm::Function::getContext(), llvm::AttributeSet::getNumSlots(), getParent(), and llvm::AttributeSet::getSlotIndex().

Referenced by LLVMAddAttribute(), and LLVMSetParamAlignment().

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

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

Definition at line 129 of file Argument.h.

References llvm::Value::getValueID().

unsigned Argument::getArgNo ( ) const

Return the index of this formal argument in its containing function.

getArgNo - Return the index of this formal argument in its containing function.

For example in "void foo(int a, float b)" a is 0 and b is 1.

Definition at line 62 of file Function.cpp.

References llvm::Function::arg_begin(), F(), and getParent().

Referenced by addAttr(), AllCallersPassInValidPointerForArgument(), getDereferenceableBytes(), getDereferenceableOrNullBytes(), getParamAlignment(), hasByValAttr(), hasByValOrInAllocaAttr(), hasInAllocaAttr(), hasNestAttr(), hasNoAliasAttr(), hasNoCaptureAttr(), hasNonNullAttr(), hasReturnedAttr(), hasSExtAttr(), hasStructRetAttr(), hasZExtAttr(), LLVMAddAttribute(), LLVMGetAttribute(), LLVMRemoveAttribute(), LLVMSetParamAlignment(), onlyReadsMemory(), and removeAttr().

uint64_t Argument::getDereferenceableBytes ( ) const

If this argument has the dereferenceable attribute on it in its containing function, return the number of bytes known to be dereferenceable.

Otherwise, zero is returned.

Definition at line 117 of file Function.cpp.

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

Referenced by hasNonNullAttr().

uint64_t Argument::getDereferenceableOrNullBytes ( ) const

If this argument has the dereferenceable_or_null attribute on it in its containing function, return the number of bytes known to be dereferenceable.

Otherwise, zero is returned.

Definition at line 123 of file Function.cpp.

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

unsigned Argument::getParamAlignment ( ) const

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

Definition at line 111 of file Function.cpp.

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

Referenced by llvm::ObjectSizeOffsetVisitor::visitArgument().

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

Definition at line 50 of file Argument.h.

bool Argument::hasByValAttr ( ) const

Return true if this argument has the byval attribute on it in its containing function.

hasByValAttr - Return true if this argument has the byval attribute on it in its containing function.

Definition at line 90 of file Function.cpp.

References llvm::Attribute::ByVal, getArgNo(), llvm::Function::getAttributes(), getParent(), and llvm::Value::getType().

bool Argument::hasByValOrInAllocaAttr ( ) const

Return true if this argument has the byval attribute or inalloca attribute on it in its containing function.

These attributes both represent arguments being passed by value.

Definition at line 104 of file Function.cpp.

References llvm::Attribute::ByVal, getArgNo(), llvm::Function::getAttributes(), getParent(), llvm::Value::getType(), llvm::AttributeSet::hasAttribute(), and llvm::Attribute::InAlloca.

Referenced by llvm::ObjectSizeOffsetVisitor::visitArgument().

bool Argument::hasInAllocaAttr ( ) const

Return true if this argument has the inalloca attribute on it in its containing function.

Definition at line 98 of file Function.cpp.

References getArgNo(), llvm::Function::getAttributes(), getParent(), llvm::Value::getType(), and llvm::Attribute::InAlloca.

Referenced by determinePointerReadAttrs().

bool Argument::hasNestAttr ( ) const

Return true if this argument has the nest attribute on it in its containing function.

hasNestAttr - Return true if this argument has the nest attribute on it in its containing function.

Definition at line 131 of file Function.cpp.

References getArgNo(), llvm::Function::getAttributes(), getParent(), llvm::Value::getType(), and llvm::Attribute::Nest.

bool Argument::hasNoAliasAttr ( ) const

Return true if this argument has the noalias attribute on it in its containing function.

hasNoAliasAttr - Return true if this argument has the noalias attribute on it in its containing function.

Definition at line 139 of file Function.cpp.

References getArgNo(), llvm::Function::getAttributes(), getParent(), llvm::Value::getType(), and llvm::Attribute::NoAlias.

bool Argument::hasNoCaptureAttr ( ) const

Return true if this argument has the nocapture attribute on it in its containing function.

hasNoCaptureAttr - Return true if this argument has the nocapture attribute on it in its containing function.

Definition at line 147 of file Function.cpp.

References getArgNo(), llvm::Function::getAttributes(), getParent(), llvm::Value::getType(), and llvm::Attribute::NoCapture.

bool Argument::hasNonNullAttr ( ) const

Return true if this argument has the nonnull attribute on it in its containing function.

hasNonNullAttr - Return true if this argument has the nonnull attribute on it in its containing function.

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

Definition at line 77 of file Function.cpp.

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

bool Argument::hasReturnedAttr ( ) const

Return true if this argument has the returned attribute on it in its containing function.

hasReturnedAttr - Return true if this argument has the returned attribute on it in its containing function.

Definition at line 163 of file Function.cpp.

References getArgNo(), llvm::Function::getAttributes(), getParent(), and llvm::Attribute::Returned.

bool Argument::hasSExtAttr ( ) const

Return true if this argument has the sext attribute on it in its containing function.

hasSExtAttr Return true if this argument has the sext attribute on it in its containing function.

Definition at line 177 of file Function.cpp.

References getArgNo(), llvm::Function::getAttributes(), getParent(), and llvm::Attribute::SExt.

bool Argument::hasStructRetAttr ( ) const

Return true if this argument has the sret attribute on it in its containing function.

hasSRetAttr - Return true if this argument has the sret attribute on it in its containing function.

Definition at line 155 of file Function.cpp.

References getArgNo(), llvm::Function::getAttributes(), getParent(), llvm::Value::getType(), and llvm::Attribute::StructRet.

bool Argument::hasZExtAttr ( ) const

Return true if this argument has the zext attribute on it in its containing function.

hasZExtAttr - Return true if this argument has the zext attribute on it in its containing function.

Definition at line 170 of file Function.cpp.

References getArgNo(), llvm::Function::getAttributes(), getParent(), and llvm::Attribute::ZExt.

bool Argument::onlyReadsMemory ( ) const

Return true if this argument has the readonly or readnone attribute on it in its containing function.

Definition at line 184 of file Function.cpp.

References getArgNo(), llvm::Function::getAttributes(), getParent(), llvm::Attribute::ReadNone, and llvm::Attribute::ReadOnly.

void Argument::removeAttr ( AttributeSet  AS)

Remove a Attribute from an argument.

removeAttr - Remove attributes from an argument.

Definition at line 202 of file Function.cpp.

References getArgNo(), llvm::Function::getContext(), llvm::AttributeSet::getNumSlots(), getParent(), llvm::AttributeSet::getSlotIndex(), and llvm::Function::removeAttributes().

Referenced by LLVMRemoveAttribute().

Friends And Related Function Documentation

friend class SymbolTableListTraits< Argument, Function >
friend

Definition at line 39 of file Argument.h.


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