18 #ifndef LLVM_IR_FUNCTION_H
19 #define LLVM_IR_FUNCTION_H
40 return static_cast<Argument*
>(&Sentinel);
85 IsMaterializableBit = 1 << 0,
86 HasMetadataHashEntryBit = 1 << 1
88 void setGlobalObjectBit(
unsigned Mask,
bool Value) {
95 void setParent(
Module *parent);
101 bool hasLazyArguments()
const {
104 void CheckLazyArguments()
const {
105 if (hasLazyArguments())
106 BuildLazyArguments();
108 void BuildLazyArguments()
const;
110 Function(
const Function&) =
delete;
111 void operator=(
const Function&) =
delete;
118 const Twine &
N =
"", Module *M =
nullptr);
123 return new(1)
Function(Ty, Linkage,
N, M);
135 return cast<Constant>(Op<0>());
177 (static_cast<unsigned>(CC) << 3));
240 const char *
getGC()
const;
241 void setGC(
const char *Str);
425 CheckLazyArguments();
429 CheckLazyArguments();
433 return &Function::ArgumentList;
439 return &Function::BasicBlocks;
473 CheckLazyArguments();
474 return ArgumentList.
begin();
477 CheckLazyArguments();
478 return ArgumentList.
begin();
481 CheckLazyArguments();
482 return ArgumentList.
end();
485 CheckLazyArguments();
486 return ArgumentList.
end();
602 void setValueSubclassData(
unsigned short D) {
606 bool hasMetadataHashEntry()
const {
609 void setHasMetadataHashEntry(
bool HasEntry) {
610 setGlobalObjectBit(HasMetadataHashEntryBit, HasEntry);
613 void clearMetadata();
616 inline ValueSymbolTable *
bool isDefTriviallyDead() const
isDefTriviallyDead - Return true if it is trivially safe to remove this function definition from the ...
void setPersonalityFn(Constant *C)
BasicBlockListType::const_iterator const_iterator
void viewCFGOnly() const
viewCFGOnly - This function is meant for use from the debugger.
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
ArgumentListType::iterator arg_iterator
unsigned getStackAlignment(unsigned Index) const
Get the stack alignment.
static void destroySentinel(Argument *)
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.
unsigned getNumOperands() const
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
const char * getGC() const
Externally visible function.
Type * getReturnType() const
unsigned getParamAlignment(unsigned Index) const
Return the alignment for the specified function parameter.
bool hasPrologueData() const
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
Argument * provideInitialHead() const
const_arg_iterator arg_end() const
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
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 does not alias other parameters.
bool isMaterializable() const
uint64_t getDereferenceableBytes(unsigned i) const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
StringRef getName() const
Return a constant reference to the value's name.
unsigned getGlobalObjectSubClassData() const
AttributeSet removeAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Attr) const
Remove the specified attribute at the specified index from this attribute list.
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.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This file contains the simple types necessary to represent the attributes associated with functions a...
void setMetadata(unsigned KindID, MDNode *MD)
Set a particular kind of metadata attachment.
Function must be in a unwind table.
bool onlyReadsMemory(unsigned n) const
void viewCFG() const
viewCFG - This function is meant for use from the debugger.
const_iterator end() const
Function does not access memory.
Hidden pointer to structure to return.
Function creates no aliases of pointer.
void addFnAttr(Attribute::AttrKind N)
Add function attributes to this function.
void addFnAttr(StringRef Kind, StringRef Value)
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
FunctionType - Class to represent function types.
static void noteHead(Argument *, Argument *)
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.
void removeAttributes(unsigned i, AttributeSet attr)
removes the attributes from the list of attributes.
ValueSymbolTable & getValueSymbolTable()
getSymbolTable() - Return the symbol table...
bool doesNotAccessMemory() const
Determine if the function does not access memory.
Considered to not alias after call.
void setOnlyAccessesArgMemory()
void setDoesNotCapture(unsigned n)
void setCallingConv(CallingConv::ID CC)
void setOnlyReadsMemory()
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachment, if any.
const ValueSymbolTable & getValueSymbolTable() const
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
iplist< BasicBlock > BasicBlockListType
const_arg_iterator arg_begin() const
This is an important class for using LLVM in a threaded context.
size_type LLVM_ATTRIBUTE_UNUSED_RESULT size() const
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 dropUnknownMetadata(ArrayRef< unsigned > KnownIDs)
Drop metadata not in the given list.
BasicBlock & getEntryBlock()
void setDoesNotAlias(unsigned n)
bool hasPersonalityFn() const
Get the personality function associated with this function.
bool hasMetadata() const
Check if this has any metadata.
bool doesNotReturn() const
Determine if the function cannot return.
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 ...
OptionalOperandTraits - when the number of operands may change at runtime.
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).
Function doesn't unwind stack.
BasicBlockListType::iterator iterator
Mark the function as not returning.
void setDoesNotAccessMemory(unsigned n)
static iplist< BasicBlock > Function::* getSublistAccess(BasicBlock *)
static iplist< Argument > Function::* getSublistAccess(Argument *)
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
Call cannot be duplicated.
void setCannotDuplicate()
BasicBlockListType & getBasicBlockList()
void setEntryCount(uint64_t Count)
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).
const BasicBlockListType & getBasicBlockList() const
bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
Get all current metadata attachments.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
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 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)
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.
void addAttribute(unsigned i, Attribute::AttrKind attr)
adds the attribute to the list of attributes.
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
Function only reads from memory.
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
void setGC(const char *Str)
void setIsMaterializable(bool V)
void eraseFromParent() override
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW=nullptr) const
Print the function to an output stream with an optional AssemblyAnnotationWriter. ...
AttributeSet addAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Attr) const
Add an attribute to the attribute set at the given index.
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
ilist_node - Base class that provides next/prev services for nodes that use ilist_nextprev_traits or ...
Constant * getPersonalityFn() const
void setDoesNotAccessMemory()
void removeFnAttr(Attribute::AttrKind N)
Remove function attributes from this function.
FunctionType * getFunctionType() const
bool callsFunctionThatReturnsTwice() const
callsFunctionThatReturnsTwice - Return true if the function has a call to setjmp or other function th...
void addFnAttr(StringRef Kind)
Add function attributes to this function.
void setPrologueData(Constant *PrologueData)
static bool getSymTab(Value *V, ValueSymbolTable *&ST)
Compile-time customization of User operands.
bool hasPrefixData() const
bool hasUWTable() const
True if the ABI mandates (or the user requested) that this function be in a unwind table...
Constant * getPrefixData() const
void setAttributes(AttributeSet attrs)
Set the attribute list for this Function.
Funciton can access memory only using pointers based on its arguments.
Argument * createSentinel() const
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.
static NodeTy * createSentinel()
createSentinel - create the dynamic sentinel
bool hasFnAttribute(StringRef Kind) const
const ARM::ArchExtKind Kind
const BasicBlock & front() const
unsigned getParamAlignment(unsigned i) const
Extract the alignment for a call or parameter (0=unknown).
iplist< Argument > ArgumentListType
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...
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
ArgumentListType::const_iterator const_arg_iterator
void addAttributes(unsigned i, AttributeSet attrs)
adds the attributes to the list of attributes.
Argument * ensureHead(Argument *) const
Can only be moved to control-equivalent blocks.
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
void setGlobalObjectSubClassData(unsigned Val)
unsigned getFnStackAlignment() const
Return the stack alignment for the function.
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