LLVM
8.0.1
|
This class represents an incoming formal argument to a Function. More...
#include "llvm/IR/Argument.h"
Public Member Functions | |
Argument (Type *Ty, const Twine &Name="", Function *F=nullptr, unsigned ArgNo=0) | |
Argument constructor. More... | |
const Function * | getParent () const |
Function * | getParent () |
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 | |
Value & | operator= (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... | |
Type * | getType () const |
All values are typed, get the type of this value. More... | |
LLVMContext & | getContext () const |
All values hold a context through their type. More... | |
bool | hasName () const |
ValueName * | getValueName () 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_iterator > | materialized_uses () |
iterator_range< const_use_iterator > | materialized_uses () const |
iterator_range< use_iterator > | uses () |
iterator_range< const_use_iterator > | uses () 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 |
User * | user_back () |
const User * | user_back () const |
iterator_range< user_iterator > | materialized_users () |
iterator_range< const_user_iterator > | materialized_users () const |
iterator_range< user_iterator > | users () |
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... | |
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 Value * | stripPointerCasts () const |
Strip off pointer casts, all-zero GEPs, and aliases. More... | |
Value * | stripPointerCasts () |
const Value * | stripPointerCastsAndInvariantGroups () const |
Strip off pointer casts, all-zero GEPs, aliases and invariant group info. More... | |
Value * | stripPointerCastsAndInvariantGroups () |
const Value * | stripPointerCastsNoFollowAliases () const |
Strip off pointer casts and all-zero GEPs. More... | |
Value * | stripPointerCastsNoFollowAliases () |
const Value * | stripInBoundsConstantOffsets () const |
Strip off pointer casts and all-constant inbounds GEPs. More... | |
Value * | stripInBoundsConstantOffsets () |
const Value * | stripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset) const |
Accumulate offsets from stripInBoundsConstantOffsets(). More... | |
Value * | stripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset) |
const Value * | stripInBoundsOffsets () const |
Strip off pointer casts and inbounds GEPs. More... | |
Value * | stripInBoundsOffsets () |
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 Value * | DoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB) const |
Translate PHI node to its predecessor from the given basic block. More... | |
Value * | DoPHITranslation (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 |
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.
|
explicit |
Argument constructor.
Definition at line 67 of file Function.cpp.
References llvm::Value::setName().
Referenced by llvm::Function::~Function().
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().
void Argument::addAttr | ( | Attribute | Attr | ) |
Definition at line 177 of file Function.cpp.
References llvm::Function::addParamAttr(), getArgNo(), and getParent().
void Argument::addAttrs | ( | AttrBuilder & | B | ) |
Add attributes to an argument.
Definition at line 167 of file Function.cpp.
References llvm::AttributeList::addParamAttributes(), llvm::AArch64CC::AL, B, getArgNo(), llvm::Function::getAttributes(), llvm::Function::getContext(), getParent(), and llvm::Function::setAttributes().
Referenced by getArgNo().
Method for support type inquiry through isa, cast, and dyn_cast.
Definition at line 123 of file Argument.h.
References llvm::Value::getValueID().
|
inline |
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 48 of file Argument.h.
References addAttr(), addAttrs(), assert(), B, getDereferenceableBytes(), getDereferenceableOrNullBytes(), getParamAlignment(), hasAttribute(), hasByValAttr(), hasByValOrInAllocaAttr(), hasInAllocaAttr(), hasNestAttr(), hasNoAliasAttr(), hasNoCaptureAttr(), hasNonNullAttr(), hasReturnedAttr(), hasSExtAttr(), hasStructRetAttr(), hasSwiftErrorAttr(), hasSwiftSelfAttr(), hasZExtAttr(), Kind, onlyReadsMemory(), and removeAttr().
Referenced by addAttr(), addAttrs(), allCallersPassInValidPointerForArgument(), llvm::AMDGPU::HSAMD::MetadataStreamerV2::emitKernel(), getDereferenceableBytes(), getDereferenceableOrNullBytes(), getParamAlignment(), hasAttribute(), hasByValOrInAllocaAttr(), hasNonNullAttr(), hasSwiftErrorAttr(), hasSwiftSelfAttr(), isArgPassedInSGPR(), llvm::AMDGPU::isArgPassedInSGPR(), LLVMGetNextParam(), LLVMGetPreviousParam(), onlyReadsMemory(), PushArgMD(), and removeAttr().
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().
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().
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().
Definition at line 42 of file Argument.h.
Referenced by addAttr(), addAttrs(), allCallersPassInValidPointerForArgument(), llvm::AMDGPU::HSAMD::MetadataStreamerV2::emitKernel(), llvm::Function::eraseFromParent(), getDereferenceableBytes(), getDereferenceableOrNullBytes(), getOpenCLAlignment(), getParamAlignment(), hasAttribute(), hasByValOrInAllocaAttr(), hasNonNullAttr(), hasSwiftErrorAttr(), hasSwiftSelfAttr(), isArgPassedInSGPR(), llvm::AMDGPU::isArgPassedInSGPR(), isOnlyUsedInEntryBlock(), isSafeToPromoteArgument(), LLVMGetNextParam(), LLVMGetPreviousParam(), onlyReadsMemory(), removeAttr(), and llvm::Function::removeFromParent().
|
inline |
Definition at line 43 of file Argument.h.
bool Argument::hasAttribute | ( | Attribute::AttrKind | Kind | ) | const |
Check if an argument has a given attribute.
Definition at line 185 of file Function.cpp.
References getArgNo(), getParent(), and llvm::Function::hasParamAttribute().
Referenced by getArgNo(), hasByValAttr(), hasInAllocaAttr(), hasNestAttr(), hasNoAliasAttr(), hasNoCaptureAttr(), hasReturnedAttr(), hasSExtAttr(), hasStructRetAttr(), and hasZExtAttr().
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().
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().
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().
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().
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().
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().
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().
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().
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().
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().
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().
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().
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().
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().
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().
|
friend |
Definition at line 34 of file Argument.h.