18 #ifndef LLVM_IR_FUNCTION_H
19 #define LLVM_IR_FUNCTION_H
47 class AssemblyAnnotationWriter;
52 template <
typename T>
class Optional;
71 mutable Argument *Arguments =
nullptr;
73 std::unique_ptr<ValueSymbolTable>
92 IsMaterializableBit = 0,
107 void CheckLazyArguments()
const {
109 BuildLazyArguments();
112 void BuildLazyArguments()
const;
114 void clearArguments();
121 const Twine &
N =
"", Module *M =
nullptr);
124 Function(
const Function&) =
delete;
125 void operator=(
const Function&) =
delete;
156 unsigned Mask = 1 << IsMaterializableBit;
191 auto ID =
static_cast<unsigned>(CC);
281 const std::string &
getGC()
const;
282 void setGC(std::string Str);
423 addFnAttr(Attribute::InaccessibleMemOnly);
432 addFnAttr(Attribute::InaccessibleMemOrArgMemOnly);
561 return &Function::BasicBlocks;
585 size_t size()
const {
return BasicBlocks.size(); }
586 bool empty()
const {
return BasicBlocks.empty(); }
596 CheckLazyArguments();
600 CheckLazyArguments();
605 CheckLazyArguments();
606 return Arguments + NumArgs;
609 CheckLazyArguments();
610 return Arguments + NumArgs;
655 bool ShouldPreserveUseListOrder =
false,
656 bool IsForDebug =
false)
const;
723 void allocHungoffUselist();
724 template<
int Idx>
void setHungoffOperand(
Constant *
C);
728 void setValueSubclassData(
unsigned short D) {
731 void setValueSubclassDataBit(
unsigned Bit,
bool On);
741 #endif // LLVM_IR_FUNCTION_H
bool isDefTriviallyDead() const
isDefTriviallyDead - Return true if it is trivially safe to remove this function definition from the ...
bool hasAttribute(unsigned i, Attribute::AttrKind Kind) const
check if an attributes is in the list of attributes.
bool hasLazyArguments() const
hasLazyArguments/CheckLazyArguments - The argument list of a function is built on demand...
bool isDebugInfoForProfiling() const
Returns true if we should emit debug info for profiling.
uint64_t getParamDereferenceableBytes(unsigned ArgNo) const
Extract the number of dereferenceable bytes for a parameter.
This class provides a symbol table of name/value pairs.
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
base_list_type::const_iterator const_iterator
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
This class represents an incoming formal argument to a Function.
bool isConvergent() const
Determine if the call is convergent.
Constant * getPrologueData() const
Get the prologue data associated with this function.
void operator=(const Function &)=delete
uint64_t getDereferenceableOrNullBytes(unsigned Index) const
Get the number of dereferenceable_or_null bytes (or zero if unknown).
bool onlyReadsMemory() const
Determine if the function does not access or only reads memory.
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
adds the attribute to the list of attributes for the given arg.
A Module instance is used to store all the information related to an LLVM module. ...
iterator_range< const_arg_iterator > args() const
void addDereferenceableAttr(unsigned i, uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes.
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
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...
Type * getValueType() const
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
void setGC(std::string Str)
void viewCFGOnly() const
viewCFGOnly - This function is meant for use from the debugger.
Externally visible function.
void setSectionPrefix(StringRef Prefix)
Set the section prefix for this function.
bool onlyAccessesInaccessibleMemory() const
Determine if the function may only access memory that is inaccessible from the IR.
bool hasPrologueData() const
Check whether this function has prologue data.
The two locations do not alias at all.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
const_arg_iterator arg_end() const
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of an arg.
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it...
bool optForSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
void setDoesNotReadMemory()
bool optForMinSize() const
Optimize this function for minimum size (-Oz).
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
uint64_t getDereferenceableBytes(unsigned i) const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
AttributeList getAttributes() const
Return the attribute list for this Function.
bool doesNotThrow() const
Determine if the function cannot unwind.
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
Optional< StringRef > getSectionPrefix() const
Get the section prefix for this function.
bool doesNotReadMemory() const
Determine if the function does not access or only writes memory.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
This file contains the simple types necessary to represent the attributes associated with functions a...
const ValueSymbolTable * getValueSymbolTable() const
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Extract the number of dereferenceable_or_null bytes for a parameter.
const_iterator end() const
#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 *)
const BasicBlock & back() const
bool hasStructRetAttr() const
Determine if the function returns a structure through first or second pointer argument.
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
Equivalent to hasAttribute(ArgNo + FirstArgIndex, Kind).
DenseSet< GlobalValue::GUID > getImportGUIDs() const
Returns the set of GUIDs that needs to be imported to the function for sample PGO, to enable the same inlines as the profiled optimized binary.
void addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes)
adds the dereferenceable_or_null attribute to the list of attributes.
const_iterator begin() const
Optional< uint64_t > getEntryCount() const
Get the entry count for this function.
uint64_t getParamDereferenceableBytes(unsigned ArgNo) const
Get the number of dereferenceable bytes (or zero if unknown) of an arg.
bool doesNotAccessMemory() const
Determine if the function does not access memory.
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
check if an attributes is in the list of attributes.
void setIsMaterializable(bool V)
void setOnlyAccessesArgMemory()
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
void setCallingConv(CallingConv::ID CC)
void addParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs)
adds the attributes to the list of attributes for the given arg.
Type * getReturnType() const
Returns the type of the ret val.
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
void setSubprogram(DISubprogram *SP)
Set the attached subprogram.
void setOnlyReadsMemory()
void stealArgumentListFrom(Function &Src)
Steal arguments from another function.
static Intrinsic::ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
const_arg_iterator arg_begin() const
This is an important class for using LLVM in a threaded context.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
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.
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
BasicBlock & getEntryBlock()
Attribute getAttribute(unsigned i, StringRef Kind) const
void removeAttribute(unsigned i, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
unsigned getParamAlignment(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
void addFnAttr(StringRef Kind, StringRef Val=StringRef())
Add function attributes to this function.
bool onlyAccessesInaccessibleMemOrArgMem() const
Determine if the function may only access memory that is either inaccessible from the IR or pointed t...
bool hasPersonalityFn() const
Check whether this function has a personality function.
bool doesNotReturn() const
Determine if the function cannot return.
void addAttribute(unsigned i, Attribute::AttrKind Kind)
adds the attribute to the list of attributes.
unsigned getValueID() const
Return an ID for the concrete type of this object.
bool doesNotRecurse() const
Determine if the function is known not to recurse, directly or indirectly.
void recalculateIntrinsicID()
Recalculate the ID for this function if it is an Intrinsic defined in llvm/Intrinsics.h.
Intrinsic::ID IntID
The intrinsic ID for this subclass (which must be a Function).
void removeParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs)
removes the attribute from the list of attributes.
uint64_t getDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown).
unsigned getStackAlignment(unsigned Index) const
Get the stack alignment.
bool returnDoesNotAlias() const
Determine if the parameter or return value is marked with NoAlias attribute.
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
void setCannotDuplicate()
bool hasFnAttribute(Attribute::AttrKind Kind) const
Equivalent to hasAttribute(AttributeList::FunctionIndex, Kind) but may be faster. ...
void addFnAttr(Attribute Attr)
BasicBlockListType & getBasicBlockList()
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
void setEntryCount(uint64_t Count, const DenseSet< GlobalValue::GUID > *Imports=nullptr)
Set the entry count for this function.
uint64_t getDereferenceableOrNullBytes(unsigned i) const
Extract the number of dereferenceable_or_null bytes for a call or parameter (0=unknown).
Iterator for intrusive lists based on ilist_node.
base_list_type::iterator iterator
const BasicBlockListType & getBasicBlockList() const
Get the underlying elements of the Function...
bool isMaterializable() const
void setOnlyAccessesInaccessibleMemOrArgMem()
void setGlobalObjectSubClassData(unsigned Val)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
bool needsUnwindTableEntry() const
True if this function needs an unwind table.
void dropAllReferences()
dropAllReferences() - This method causes all the subinstructions to "let go" of all references that t...
const BasicBlock & getEntryBlock() const
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...
void setLinkage(LinkageTypes LT)
unsigned getGlobalObjectSubClassData() const
ValueSymbolTable * getValueSymbolTable()
getSymbolTable() - Return the symbol table if any, otherwise nullptr.
A range adaptor for a pair of iterators.
LinkageTypes
An enumeration for the kinds of linkage for global values.
DISubprogram * getSubprogram() const
Get the attached subprogram.
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
unsigned HasLLVMReservedName
True if the function's name starts with "llvm.".
void removeAttributes(unsigned i, const AttrBuilder &Attrs)
removes the attributes from the list of attributes.
bool hasAddressTaken(const User **=nullptr) const
hasAddressTaken - returns true if there are any uses of this function other than direct calls or invo...
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
unsigned short getSubclassDataFromValue() const
void setDoesNotAccessMemory()
Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const
const std::string & getGC() const
bool callsFunctionThatReturnsTwice() const
callsFunctionThatReturnsTwice - Return true if the function has a call to setjmp or other function th...
void setPrologueData(Constant *PrologueData)
Compile-time customization of User operands.
bool hasPrefixData() const
Check whether this function has prefix data.
bool hasUWTable() const
True if the ABI mandates (or the user requested) that this function be in a unwind table...
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
Constant * getPrefixData() const
Get the prefix data associated with this function.
void removeFnAttr(Attribute::AttrKind Kind)
Remove function attributes from this function.
bool cannotDuplicate() const
Determine if the call cannot be duplicated.
bool hasFnAttribute(StringRef Kind) const
bool isSpeculatable() const
Determine if the call has sideeffects.
void addAttributes(unsigned i, const AttrBuilder &Attrs)
adds the attributes to the list of attributes.
void addDereferenceableOrNullParamAttr(unsigned ArgNo, uint64_t Bytes)
adds the dereferenceable_or_null attribute to the list of attributes for the given arg...
Type * getReturnType() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const BasicBlock & front() const
unsigned getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
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.
The highest possible calling convention ID. Must be some 2^k - 1.
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.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
void setPersonalityFn(Constant *Fn)
void addDereferenceableParamAttr(unsigned ArgNo, uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes for the given arg.
unsigned getFnStackAlignment() const
Return the stack alignment for the function.
void removeFnAttr(StringRef Kind)
Remove function attribute from this function.
void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW=nullptr, bool ShouldPreserveUseListOrder=false, bool IsForDebug=false) const
Print the function to an output stream with an optional AssemblyAnnotationWriter. ...
iterator_range< arg_iterator > args()
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...
void setPrefixData(Constant *PrefixData)
void setReturnDoesNotAlias()
Attribute getFnAttribute(StringRef Kind) const
void viewCFG() const
viewCFG - This function is meant for use from the debugger.