18 #ifndef LLVM_IR_FUNCTION_H
19 #define LLVM_IR_FUNCTION_H
42 template <
typename T>
class Optional;
43 class AssemblyAnnotationWriter;
64 std::unique_ptr<ValueSymbolTable>
83 IsMaterializableBit = 0,
98 void CheckLazyArguments()
const {
100 BuildLazyArguments();
103 void BuildLazyArguments()
const;
110 const Twine &
N =
"", Module *M =
nullptr);
113 Function(
const Function&) =
delete;
114 void operator=(
const Function&) =
delete;
170 auto ID =
static_cast<unsigned>(CC);
253 const std::string &
getGC()
const;
254 void setGC(std::string Str);
349 addFnAttr(Attribute::InaccessibleMemOnly);
358 addFnAttr(Attribute::InaccessibleMemOrArgMemOnly);
422 return AttributeSets.
hasAttribute(1, Attribute::StructRet) ||
439 return AttributeSets.
hasAttribute(n, Attribute::NoCapture);
446 return AttributeSets.
hasAttribute(n, Attribute::ReadNone);
500 CheckLazyArguments();
504 CheckLazyArguments();
509 return &Function::ArgumentList;
516 return &Function::BasicBlocks;
540 size_t size()
const {
return BasicBlocks.size(); }
541 bool empty()
const {
return BasicBlocks.empty(); }
551 CheckLazyArguments();
552 return ArgumentList.begin();
555 CheckLazyArguments();
556 return ArgumentList.begin();
560 CheckLazyArguments();
561 return ArgumentList.end();
564 CheckLazyArguments();
565 return ArgumentList.end();
610 bool ShouldPreserveUseListOrder =
false,
611 bool IsForDebug =
false)
const;
675 void allocHungoffUselist();
676 template<
int Idx>
void setHungoffOperand(
Constant *
C);
680 void setValueSubclassData(
unsigned short D) {
683 void setValueSubclassDataBit(
unsigned Bit,
bool On);
693 #endif // LLVM_IR_FUNCTION_H
bool isDefTriviallyDead() const
isDefTriviallyDead - Return true if it is trivially safe to remove this function definition from the ...
The highest possible calling convention ID. Must be some 2^k - 1.
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...
BasicBlockListType::const_iterator const_iterator
This class provides a symbol table of name/value pairs.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
LLVM Argument representation.
bool isConvergent() const
Determine if the call is convergent.
Constant * getPrologueData() const
Get the prologue data associated with this function.
ArgumentListType::iterator arg_iterator
void operator=(const Function &)=delete
unsigned getStackAlignment(unsigned Index) const
Get the stack alignment.
bool onlyReadsMemory() const
Determine if the function does not access or only reads memory.
A Module instance is used to store all the information related to an LLVM module. ...
bool doesNotAccessMemory(unsigned n) const
iterator_range< const_arg_iterator > args() const
void addDereferenceableAttr(unsigned i, uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes.
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
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.
Type * getReturnType() const
Returns the type of the ret val.
bool onlyAccessesInaccessibleMemory() const
Determine if the function may only access memory that is inaccessible from the IR.
unsigned getParamAlignment(unsigned Index) const
Return the alignment for the specified function parameter.
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
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
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...
bool doesNotAlias(unsigned n) const
Determine if the parameter or return value is marked with NoAlias attribute.
bool isMaterializable() const
uint64_t getDereferenceableBytes(unsigned i) const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
void removeAttributes(unsigned i, AttributeSet Attrs)
removes the attributes from the list of attributes.
uint64_t getDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown).
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...
static GCRegistry::Add< StatepointGC > D("statepoint-example","an example strategy for statepoint")
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
void addAttributes(unsigned i, AttributeSet Attrs)
adds the attributes to the list of attributes.
bool onlyReadsMemory(unsigned n) const
const_iterator end() const
SymbolTableList< Argument > ArgumentListType
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
Class to represent function types.
SymbolTableList< BasicBlock > BasicBlockListType
static BasicBlockListType Function::* getSublistAccess(BasicBlock *)
const BasicBlock & back() const
bool hasStructRetAttr() const
Determine if the function returns a structure through first pointer argument.
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.
bool doesNotAccessMemory() const
Determine if the function does not access memory.
void setOnlyAccessesArgMemory()
void setDoesNotCapture(unsigned n)
void setCallingConv(CallingConv::ID CC)
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.
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.
BasicBlock & getEntryBlock()
Attribute getAttribute(unsigned i, StringRef Kind) const
void removeAttribute(unsigned i, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
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...
void setDoesNotAlias(unsigned n)
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.
uint64_t getDereferenceableOrNullBytes(unsigned Index) const
Get the number of dereferenceable_or_null bytes (or zero if unknown).
unsigned getValueID() const
Return an ID for the concrete type of this object.
void copyAttributesFrom(const GlobalValue *Src) override
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
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).
BasicBlockListType::iterator iterator
void setDoesNotAccessMemory(unsigned n)
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
void setCannotDuplicate()
void addFnAttr(Attribute Attr)
BasicBlockListType & getBasicBlockList()
void setEntryCount(uint64_t Count)
Set the entry count for this function.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Equivalent to hasAttribute(AttributeSet::FunctionIndex, Kind) but may be faster.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
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.
const BasicBlockListType & getBasicBlockList() const
void setOnlyAccessesInaccessibleMemOrArgMem()
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)
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)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
ValueSymbolTable * getValueSymbolTable()
getSymbolTable() - Return the symbol table if any, otherwise nullptr.
AttributeSet getAttributes() const
Return the attribute list for this Function.
ArgumentListType & getArgumentList()
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 setIsMaterializable(bool V)
void eraseFromParent() override
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
AttributeSet removeAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified index from this attribute list.
void setAttributes(AttributeSet Attrs)
Set the attribute list for this Function.
bool hasAddressTaken(const User **=nullptr) const
hasAddressTaken - returns true if there are any uses of this function other than direct calls or invo...
void removeFromParent() override
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it...
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
FunctionType * getFunctionType() const
Returns the FunctionType for me.
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...
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.
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
bool cannotDuplicate() const
Determine if the call cannot be duplicated.
bool hasFnAttribute(StringRef Kind) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const BasicBlock & front() const
unsigned getParamAlignment(unsigned i) const
Extract the alignment for a call or parameter (0=unknown).
LLVM Value Representation.
void setOnlyReadsMemory(unsigned n)
bool doesNotCapture(unsigned n) const
Determine if the parameter can be captured.
const ArgumentListType & getArgumentList() const
Get the underlying elements of the Function...
HungoffOperandTraits - determine the allocation regime of the Use array when it is not a prefix to th...
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)
ArgumentListType::const_iterator const_arg_iterator
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
unsigned getFnStackAlignment() const
Return the stack alignment for the function.
void removeFnAttr(StringRef Kind)
Remove function attribute from this function.
static ArgumentListType Function::* getSublistAccess(Argument *)
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)
Attribute getFnAttribute(StringRef Kind) const
void viewCFG() const
viewCFG - This function is meant for use from the debugger.