18 #ifndef LLVM_IR_FUNCTION_H 19 #define LLVM_IR_FUNCTION_H 50 class AssemblyAnnotationWriter;
55 template <
typename T>
class Optional;
76 std::unique_ptr<ValueSymbolTable>
95 IsMaterializableBit = 0,
106 return getSubclassDataFromValue() & (1<<0);
110 void CheckLazyArguments()
const {
111 if (hasLazyArguments())
112 BuildLazyArguments();
115 void BuildLazyArguments()
const;
117 void clearArguments();
128 void operator=(
const Function&) =
delete;
137 unsigned AddrSpace,
const Twine &
N =
"",
139 return new Function(Ty, Linkage, AddrSpace,
N, M);
145 return new Function(Ty, Linkage, static_cast<unsigned>(-1),
N, M);
161 unsigned getInstructionCount()
const;
165 return cast<FunctionType>(getValueType());
177 bool isVarArg()
const {
return getFunctionType()->isVarArg(); }
180 return getGlobalObjectSubClassData() & (1 << IsMaterializableBit);
183 unsigned Mask = 1 << IsMaterializableBit;
184 setGlobalObjectSubClassData((~Mask & getGlobalObjectSubClassData()) |
208 void recalculateIntrinsicID();
214 return static_cast<CallingConv::ID>((getSubclassDataFromValue() >> 4) &
218 auto ID =
static_cast<unsigned>(CC);
220 setValueSubclassData((getSubclassDataFromValue() & 0xc00f) | (
ID << 4));
270 : Count(Count), PCT(PCT) {}
271 bool hasValue()
const {
return PCT != PCT_Invalid; }
275 explicit operator bool() {
return hasValue(); }
350 return getSubclassDataFromValue() & (1<<14);
352 const std::string &getGC()
const;
353 void setGC(std::string Str);
360 void addAttribute(
unsigned i,
Attribute Attr);
369 void addParamAttr(
unsigned ArgNo,
Attribute Attr);
372 void addParamAttrs(
unsigned ArgNo,
const AttrBuilder &Attrs);
378 void removeAttribute(
unsigned i,
StringRef Kind);
381 void removeAttributes(
unsigned i,
const AttrBuilder &Attrs);
387 void removeParamAttr(
unsigned ArgNo,
StringRef Kind);
390 void removeParamAttrs(
unsigned ArgNo,
const AttrBuilder &Attrs);
413 void addDereferenceableAttr(
unsigned i, uint64_t Bytes);
417 void addDereferenceableParamAttr(
unsigned ArgNo, uint64_t Bytes);
421 void addDereferenceableOrNullAttr(
unsigned i, uint64_t Bytes);
425 void addDereferenceableOrNullParamAttr(
unsigned ArgNo, uint64_t Bytes);
574 return hasUWTable() || !doesNotThrow() || hasPersonalityFn();
604 void copyAttributesFrom(
const Function *Src);
611 setLinkage(ExternalLinkage);
617 void removeFromParent();
622 void eraseFromParent();
628 void stealArgumentListFrom(
Function &Src);
637 return &Function::BasicBlocks;
661 size_t size()
const {
return BasicBlocks.size(); }
662 bool empty()
const {
return BasicBlocks.empty(); }
672 CheckLazyArguments();
676 CheckLazyArguments();
681 CheckLazyArguments();
682 return Arguments + NumArgs;
685 CheckLazyArguments();
686 return Arguments + NumArgs;
703 return getSubclassDataFromValue() & (1<<3);
708 void setPersonalityFn(
Constant *Fn);
712 return getSubclassDataFromValue() & (1<<1);
717 void setPrefixData(
Constant *PrefixData);
721 return getSubclassDataFromValue() & (1<<2);
726 void setPrologueData(
Constant *PrologueData);
731 bool ShouldPreserveUseListOrder =
false,
732 bool IsForDebug =
false)
const;
740 void viewCFG()
const;
747 void viewCFGOnly()
const;
766 void dropAllReferences();
772 bool hasAddressTaken(
const User** =
nullptr)
const;
778 bool isDefTriviallyDead()
const;
782 bool callsFunctionThatReturnsTwice()
const;
796 bool isDebugInfoForProfiling()
const;
802 bool nullPointerIsDefined()
const;
805 void allocHungoffUselist();
806 template<
int Idx>
void setHungoffOperand(
Constant *
C);
810 void setValueSubclassData(
unsigned short D) {
813 void setValueSubclassDataBit(
unsigned Bit,
bool On);
830 #endif // LLVM_IR_FUNCTION_H
const Function & getFunction() const
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
bool onlyReadsMemory() const
Determine if the function does not access or only reads memory.
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
This class provides a symbol table of name/value pairs.
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
unsigned getFnStackAlignment() const
Return the stack alignment for the function.
const_iterator begin() const
This class represents an incoming formal argument to a Function.
unsigned getValueID() const
Return an ID for the concrete type of this object.
bool isSpeculatable() const
Determine if the call has sideeffects.
uint64_t getParamDereferenceableBytes(unsigned ArgNo) const
Extract the number of dereferenceable bytes for a parameter.
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
Implements a dense probed hash-table based set.
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
unsigned getParamAlignment(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
bool hasFnAttribute(StringRef Kind) const
Return true if the function has the attribute.
const BasicBlock & back() const
bool hasPrologueData() const
Check whether this function has prologue data.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
void setDoesNotReadMemory()
bool hasStructRetAttr() const
Determine if the function returns a structure through first or second pointer argument.
bool hasPrefixData() const
Check whether this function has prefix data.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
uint64_t getDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown).
uint64_t getDereferenceableBytes(unsigned i) const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
bool hasUWTable() const
True if the ABI mandates (or the user requested) that this function be in a unwind table...
This file contains the simple types necessary to represent the attributes associated with functions a...
Attribute getAttribute(unsigned i, StringRef Kind) const
gets the attribute from the list of attributes.
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
check if an attributes is in the list of attributes.
The highest possible calling convention ID. Must be some 2^k - 1.
bool onlyAccessesInaccessibleMemory() const
Determine if the function may only access memory that is inaccessible from the IR.
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
Class to represent function types.
static BasicBlockListType Function::* getSublistAccess(BasicBlock *)
bool hasAttribute(unsigned i, Attribute::AttrKind Kind) const
check if an attributes is in the list of attributes.
uint64_t getDereferenceableOrNullBytes(unsigned Index) const
Get the number of dereferenceable_or_null bytes (or zero if unknown).
AttributeList getAttributes() const
Return the attribute list for this Function.
bool hasPersonalityFn() const
Check whether this function has a personality function.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Extract the number of dereferenceable_or_null bytes for a parameter.
void setIsMaterializable(bool V)
void setOnlyAccessesArgMemory()
bool doesNotAccessMemory() const
Determine if the function does not access memory.
uint64_t getDereferenceableOrNullBytes(unsigned i) const
Extract the number of dereferenceable_or_null bytes for a call or parameter (0=unknown).
const BasicBlock & getEntryBlock() const
bool cannotDuplicate() const
Determine if the call cannot be duplicated.
unsigned getStackAlignment(unsigned Index) const
Get the stack alignment.
void setCallingConv(CallingConv::ID CC)
Type * getReturnType() const
Returns the type of the ret val.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
void setOnlyReadsMemory()
uint64_t getCount() const
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
void deleteBody()
deleteBody - This method deletes the body of the function, and converts the linkage to external...
This is an important base class in LLVM.
bool returnDoesNotAlias() const
Determine if the parameter or return value is marked with NoAlias attribute.
BasicBlock & getEntryBlock()
void addFnAttr(StringRef Kind, StringRef Val=StringRef())
Add function attributes to this function.
AMDGPU Lower Kernel Arguments
bool doesNotReturn() const
Determine if the function cannot return.
iterator_range< const_arg_iterator > args() const
bool optForSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
bool isMaterializable() const
#define DECLARE_TRANSPARENT_OPERAND_ACCESSORS(VALUECLASS)
Macro for generating in-class operand accessor declarations.
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
static DISubprogram * getSubprogram(bool IsDistinct, Ts &&... Args)
Class to represent profile counts.
void setCannotDuplicate()
void addFnAttr(Attribute Attr)
Add function attributes to this function.
BasicBlockListType & getBasicBlockList()
bool doesNotRecurse() const
Determine if the function is known not to recurse, directly or indirectly.
bool doesNotThrow() const
Determine if the function cannot unwind.
ProfileCount & setCount(uint64_t C)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Iterator for intrusive lists based on ilist_node.
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
Equivalent to hasAttribute(ArgNo + FirstArgIndex, Kind).
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
void setOnlyAccessesInaccessibleMemOrArgMem()
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static ProfileCount getInvalid()
ProfileCount(uint64_t Count, ProfileCountType PCT)
bool NullPointerIsDefined(const Function *F, unsigned AS=0)
Check whether null pointer dereferencing is considered undefined behavior for a given function or an ...
void setOnlyAccessesInaccessibleMemory()
void setValueSubclassData(unsigned short D)
void setAttributes(AttributeList Attrs)
Set the attribute list for this Function.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
ValueSymbolTable * getValueSymbolTable()
getSymbolTable() - Return the symbol table if any, otherwise nullptr.
bool needsUnwindTableEntry() const
True if this function needs an unwind table.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
A range adaptor for a pair of iterators.
LinkageTypes
An enumeration for the kinds of linkage for global values.
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
uint64_t getParamDereferenceableBytes(unsigned ArgNo) const
Get the number of dereferenceable bytes (or zero if unknown) of an arg.
const_arg_iterator arg_end() const
Function::ProfileCount ProfileCount
unsigned getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of an arg.
void setDoesNotAccessMemory()
bool optForMinSize() const
Optimize this function for minimum size (-Oz).
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
bool doesNotReadMemory() const
Determine if the function does not access or only writes memory.
Compile-time customization of User operands.
bool onlyAccessesInaccessibleMemOrArgMem() const
Determine if the function may only access memory that is either inaccessible from the IR or pointed t...
const_arg_iterator arg_begin() const
const BasicBlockListType & getBasicBlockList() const
Get the underlying elements of the Function...
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
const ValueSymbolTable * getValueSymbolTable() const
void removeFnAttr(Attribute::AttrKind Kind)
Remove function attributes from this function.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Equivalent to hasAttribute(AttributeList::FunctionIndex, Kind) but may be faster. ...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const BasicBlock & front() const
LLVM Value Representation.
HungoffOperandTraits - determine the allocation regime of the Use array when it is not a prefix to th...
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
ProfileCountType getType() const
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
This class implements an extremely fast bulk output stream that can only output to a stream...
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
StringRef - Represent a constant reference to a string, i.e.
Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const
gets the attribute from the list of attributes.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
Attribute getFnAttribute(StringRef Kind) const
Return the attribute for the given attribute kind.
bool doesNoCfCheck() const
Determine if the function should not perform indirect branch tracking.
const_iterator end() const
bool isConvergent() const
Determine if the call is convergent.
bool hasProfileData() const
Return true if the function is annotated with profile data.
void removeFnAttr(StringRef Kind)
Remove function attribute from this function.
bool hasLazyArguments() const
hasLazyArguments/CheckLazyArguments - The argument list of a function is built on demand...
iterator_range< arg_iterator > args()
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...
void setReturnDoesNotAlias()