45 void Argument::anchor() { }
56 void Argument::setParent(
Function *parent) {
64 assert(F &&
"Argument is not in a function");
68 for (; &*AI !=
this; ++AI)
78 if (!
getType()->isPointerTy())
return false;
83 getType()->getPointerAddressSpace() == 0)
91 if (!
getType()->isPointerTy())
return false;
99 if (!
getType()->isPointerTy())
return false;
105 if (!
getType()->isPointerTy())
return false;
112 assert(
getType()->isPointerTy() &&
"Only pointers have alignments");
118 assert(
getType()->isPointerTy() &&
119 "Only pointers have dereferenceable bytes");
124 assert(
getType()->isPointerTy() &&
125 "Only pointers have dereferenceable bytes");
132 if (!
getType()->isPointerTy())
return false;
140 if (!
getType()->isPointerTy())
return false;
148 if (!
getType()->isPointerTy())
return false;
156 if (!
getType()->isPointerTy())
return false;
194 "Trying to add more than one attribute set to an argument!");
204 "Trying to remove more than one attribute set from an argument!");
220 setGlobalObjectBit(IsMaterializableBit, V);
255 "invalid return type");
261 setValueSubclassData(1);
277 ArgumentList.
clear();
287 void Function::BuildLazyArguments()
const {
290 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
292 "Cannot have void typed arguments!");
298 const_cast<Function*
>(
this)->setValueSubclassData(SDC &= ~(1<<0));
308 void Function::setParent(
Module *parent) {
324 I->dropAllReferences();
328 while (!BasicBlocks.
empty())
329 BasicBlocks.
begin()->eraseFromParent();
385 assert(
hasGC() &&
"Function has no collector");
387 return *(*GCNames)[
this];
417 assert(isa<Function>(Src) &&
"Expected a Function!");
419 const Function *SrcF = cast<Function>(Src);
446 #define GET_FUNCTION_RECOGNIZER
447 #include "llvm/IR/Intrinsics.gen"
448 #undef GET_FUNCTION_RECOGNIZER
478 if (
PointerType* PTyp = dyn_cast<PointerType>(Ty)) {
481 }
else if (
ArrayType* ATyp = dyn_cast<ArrayType>(Ty)) {
484 }
else if (
StructType* STyp = dyn_cast<StructType>(Ty)) {
485 assert(!STyp->isLiteral() &&
"TODO: implement literal types");
486 Result += STyp->getName();
487 }
else if (
FunctionType* FT = dyn_cast<FunctionType>(Ty)) {
502 static const char *
const Table[] = {
504 #define GET_INTRINSIC_NAME_TABLE
505 #include "llvm/IR/Intrinsics.gen"
506 #undef GET_INTRINSIC_NAME_TABLE
510 std::string Result(Table[
id]);
511 for (
unsigned i = 0; i < Tys.
size(); ++i) {
566 unsigned StructElts = 2;
567 using namespace Intrinsic;
648 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
653 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
659 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
665 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
671 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
677 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
683 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
697 for (
unsigned i = 0; i != StructElts; ++i)
706 #define GET_INTRINSIC_GENERATOR_GLOBAL
707 #include "llvm/IR/Intrinsics.gen"
708 #undef GET_INTRINSIC_GENERATOR_GLOBAL
713 unsigned TableVal = IIT_Table[
id-1];
718 unsigned NextElt = 0;
719 if ((TableVal >> 31) != 0) {
721 IITEntries = IIT_LongEncodingTable;
724 NextElt = (TableVal << 1) >> 1;
733 IITEntries = IITValues;
739 while (NextElt != IITEntries.
size() && IITEntries[NextElt] != 0)
746 using namespace Intrinsic;
747 IITDescriptor D = Infos.
front();
748 Infos = Infos.
slice(1);
765 D.Pointer_AddressSpace);
768 assert(D.Struct_NumElements <= 5 &&
"Can't handle this yet");
769 for (
unsigned i = 0, e = D.Struct_NumElements; i != e; ++i)
775 return Tys[D.getArgumentNumber()];
777 Type *Ty = Tys[D.getArgumentNumber()];
778 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
784 Type *Ty = Tys[D.getArgumentNumber()];
785 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
794 Tys[D.getArgumentNumber()]));
797 Type *Ty = Tys[D.getArgumentNumber()];
798 if (
VectorType *VTy = dyn_cast<VectorType>(Ty)) {
804 Type *Ty = Tys[D.getArgumentNumber()];
808 Type *Ty = Tys[D.getArgumentNumber()];
831 while (!TableRef.
empty())
844 #define GET_INTRINSIC_OVERLOAD_TABLE
845 #include "llvm/IR/Intrinsics.gen"
846 #undef GET_INTRINSIC_OVERLOAD_TABLE
854 case Intrinsic::experimental_gc_statepoint:
855 case Intrinsic::experimental_patchpoint_void:
856 case Intrinsic::experimental_patchpoint_i64:
862 #define GET_INTRINSIC_ATTRIBUTES
863 #include "llvm/IR/Intrinsics.gen"
864 #undef GET_INTRINSIC_ATTRIBUTES
875 #define GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
876 #include "llvm/IR/Intrinsics.gen"
877 #undef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
880 #define GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
881 #include "llvm/IR/Intrinsics.gen"
882 #undef GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
888 const User *FU = U.getUser();
889 if (isa<BlockAddress>(FU))
891 if (!isa<CallInst>(FU) && !isa<InvokeInst>(FU))
892 return PutOffender ? (*PutOffender = FU,
true) :
true;
894 if (!CS.isCallee(&U))
895 return PutOffender ? (*PutOffender = FU,
true) :
true;
908 if (!isa<BlockAddress>(U))
931 assert(PDMap.
find(
this) != PDMap.
end());
932 return cast<Constant>(PDMap.
find(
this)->second->getReturnValue());
953 setValueSubclassData(SCData);
960 assert(SOMap.
find(
this) != SOMap.
end());
961 return cast<Constant>(SOMap.
find(
this)->second->getReturnValue());
982 setValueSubclassData(PDData);
994 if (MDS->getString().equals(
"function_entry_count")) {
1007 Op<0>().set(
nullptr);
bool hasNoCaptureAttr() const
Return true if this argument has the nocapture attribute on it in its containing function.
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type (if unknown returns 0).
bool hasNoAliasAttr() const
Return true if this argument has the noalias attribute on it in its containing function.
bool isDefTriviallyDead() const
isDefTriviallyDead - Return true if it is trivially safe to remove this function definition from the ...
void setPersonalityFn(Constant *C)
ReturnInst - Return a value (possibly void), from a function.
void push_back(const T &Elt)
This class provides a symbol table of name/value pairs.
iterator_range< use_iterator > uses()
void setFunctionNumOperands(unsigned NumOps)
Set the number of operands on a Function.
static Type * getDoubleTy(LLVMContext &C)
PooledStringPtr intern(StringRef Str)
intern - Adds a string to the pool and returns a reference-counted pointer to it. ...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
LLVM Argument representation.
Constant * getPrologueData() const
bool onlyReadsMemory() const
Return true if this argument has the readonly or readnone attribute on it in its containing function...
uint64_t getZExtValue() const
Get zero extended value.
Sign extended before/after call.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
A Module instance is used to store all the information related to an LLVM module. ...
unsigned getNumParams() const
getNumParams - Return the number of fixed parameters this function type requires. ...
PrefixDataMapTy PrefixDataMap
const T & front() const
front - Get the first element.
void addDereferenceableAttr(unsigned i, uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes.
bool hasByValOrInAllocaAttr() const
Return true if this argument has the byval attribute or inalloca attribute on it in its containing fu...
Nested function static chain.
const char * getGC() const
static PointerType * get(Type *ElementType, unsigned AddressSpace)
PointerType::get - This constructs a pointer to an object of the specified type in a numbered address...
bool isOverloaded(ID id)
Returns true if the intrinsic can be overloaded.
bool hasAvailableExternallyLinkage() const
Type * getReturnType() const
bool hasPrologueData() const
static bool isValidReturnType(Type *RetTy)
isValidReturnType - Return true if the specified type is valid as a return type.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Return the function type for an intrinsic.
static Type * getMetadataTy(LLVMContext &C)
static VectorType * getTruncatedElementVectorType(VectorType *VTy)
VectorType::getTruncatedElementVectorType - This static method is like getInteger except that the ele...
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
static Type * getX86_MMXTy(LLVMContext &C)
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
bool isMaterializable() const
uint64_t getDereferenceableBytes(unsigned i) const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
unsigned getGlobalObjectSubClassData() const
void addAttr(AttributeSet AS)
Add a Attribute to an argument.
bool empty() const
empty - Checks whether the pool is empty.
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, Instruction *InsertBefore=nullptr)
StringPool - An interned string pool.
void push_back(NodeTy *val)
std::string getEVTString() const
getEVTString - This function returns value type as a string, e.g.
inst_iterator inst_begin(Function *F)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static Type * getFloatTy(LLVMContext &C)
static DenseMap< const Function *, PooledStringPtr > * GCNames
const APInt & getValue() const
Return the constant as an APInt value reference.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
StructType - Class to represent struct types.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
A Use represents the edge between a Value definition and its users.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
static StringRef getName(Value *V)
void setMetadata(unsigned KindID, MDNode *MD)
Set a particular kind of metadata attachment.
AttributeSet addDereferenceableAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
bool hasFnAttr(Attribute::AttrKind A) const
Return true if this function has the given attribute.
void setName(const Twine &Name)
Change the name of the value.
uint64_t getDereferenceableOrNullBytes() const
If this argument has the dereferenceable_or_null attribute on it in its containing function...
Type * getVectorElementType() const
ScopedReader - RAII acquisition of a reader lock.
Function does not access memory.
Hidden pointer to structure to return.
Function creates no aliases of pointer.
uint64_t getDereferenceableBytes() const
If this argument has the dereferenceable attribute on it in its containing function, return the number of bytes known to be dereferenceable.
void removeAttr(AttributeSet AS)
Remove a Attribute from an argument.
ScopedWriter - RAII acquisition of a writer lock.
PrologueDataMapTy PrologueDataMap
FunctionType - Class to represent function types.
IIT_Info
IIT_Info - These are enumerators that describe the entries returned by the getIntrinsicInfoTableEntri...
LLVMContext & getContext() const
getContext - Return the LLVMContext in which this type was uniqued.
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
bool hasStructRetAttr() const
Return true if this argument has the sret attribute on it in its containing function.
ArrayRef< T > slice(unsigned N) const
slice(n) - Chop off the first N elements of the array.
ArrayType - Class to represent array types.
static StringPool * GCNamePool
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
FunctionType::get - This static method is the primary way of constructing a FunctionType.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
static std::string utostr(uint64_t X, bool isNeg=false)
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
void addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes)
adds the dereferenceable_or_null attribute to the list of attributes.
bool hasNestAttr() const
Return true if this argument has the nest attribute on it in its containing function.
Optional< uint64_t > getEntryCount() const
Get the entry count for this function.
unsigned getNumElements() const
Return the number of elements in the Vector type.
void removeAttributes(unsigned i, AttributeSet attr)
removes the attributes from the list of attributes.
size_t size() const
size - Get the array size.
Considered to not alias after call.
ValueName * getValueName() const
PointerType - Class to represent pointers.
static std::string getMangledTypeStr(Type *Ty)
Returns a stable mangling for the type specified for use in the name mangling scheme used by 'any' ty...
void setCallingConv(CallingConv::ID CC)
unsigned getNumSlots() const
Return the number of slots used in this attribute list.
Type * getParamType(unsigned i) const
Parameter type accessors.
bool erase(const KeyT &Val)
static VectorType * getHalfElementsVectorType(VectorType *VTy)
VectorType::getHalfElementsVectorType - This static method returns a VectorType with half as many ele...
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachment, if any.
bool isLeaf(ID id)
Returns true if the intrinsic is a leaf, i.e.
Constant * getOrInsertFunction(StringRef Name, FunctionType *T, AttributeSet AttributeList)
Look up the specified function in the module symbol table.
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.
const Function * getParent() const
This is an important base class in LLVM.
bool hasInAllocaAttr() const
Return true if this argument has the inalloca attribute on it in its containing function.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
unsigned getParamAlignment() const
If this is a byval or inalloca argument, return its alignment.
bool hasPersonalityFn() const
Get the personality function associated with this function.
Return value is always equal to this argument.
Pass structure in an alloca.
static Type * getVoidTy(LLVMContext &C)
bool hasSExtAttr() const
Return true if this argument has the sext attribute on it in its containing function.
void copyAttributesFrom(const GlobalValue *Src) override
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
Zero extended before/after call.
static IITDescriptor get(IITDescriptorKind K, unsigned Field)
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).
Class to represent integer types.
bool empty() const
empty - Check if the array is empty.
MDNode * createFunctionEntryCount(uint64_t Count)
Return metadata containing the entry count for a function.
iterator erase(iterator where)
LLVMContextImpl *const pImpl
Pointer is known to be not null.
static Intrinsic::ID lookupIntrinsicID(const ValueName *ValName)
This does the actual lookup of an intrinsic ID which matches the given function name.
void setEntryCount(uint64_t Count)
Set the entry count for this function.
bool hasByValAttr() const
Return true if this argument has the byval attribute on it in its containing function.
const FunctionListType & getFunctionList() const
Get the Module's list of functions (constant).
static Type * getHalfTy(LLVMContext &C)
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
const MDOperand & getOperand(unsigned I) const
uint64_t getDereferenceableOrNullBytes(unsigned i) const
Extract the number of dereferenceable_or_null bytes for a call or parameter (0=unknown).
static PointerType * getUnqual(Type *ElementType)
PointerType::getUnqual - This constructs a pointer to an object of the specified type in the generic ...
This is the shared class of boolean and integer constants.
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
StructType::get - This static method is the primary way to create a literal StructType.
void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl< IITDescriptor > &T)
Return the IIT table descriptor for the specified intrinsic into an array of IITDescriptors.
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
void dropAllReferences()
dropAllReferences() - This method causes all the subinstructions to "let go" of all references that t...
const char * getKeyData() const
getKeyData - Return the start of the string data that is the key for this value.
void copyAttributesFrom(const GlobalValue *Src) override
Copy all additional attributes (those not needed to create a GlobalValue) from the GlobalValue Src to...
bool hasZExtAttr() const
Return true if this argument has the zext attribute on it in its containing function.
static VectorType * getExtendedElementVectorType(VectorType *VTy)
VectorType::getExtendedElementVectorType - This static method is like getInteger except that the elem...
void setOperand(unsigned i, Value *Val)
AttributeSet getAttributes() const
Return the attribute list for this Function.
AttributeSet removeAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Remove the specified attributes at the specified index from this attribute list.
VectorType - Class to represent vector types.
Argument(Type *Ty, const Twine &Name="", Function *F=nullptr)
Constructor.
void addAttribute(unsigned i, Attribute::AttrKind attr)
adds the attribute to the list of attributes.
iterator_range< user_iterator > users()
Function only reads from memory.
bool hasNonNullAttr() const
Return true if this argument has the nonnull attribute on it in its containing function.
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
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)
static void DecodeIITType(unsigned &NextElt, ArrayRef< unsigned char > Infos, SmallVectorImpl< Intrinsic::IITDescriptor > &OutputTable)
void eraseFromParent() override
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
bool hasLinkOnceLinkage() const
PointerType * getType() const
Global values are always pointers.
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...
unsigned short getSubclassDataFromValue() const
std::string getName(ID id, ArrayRef< Type * > Tys=None)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
Constant * getPersonalityFn() const
unsigned getSlotIndex(unsigned Slot) const
Return the index for the given slot.
AttributeSet addDereferenceableOrNullAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable_or_null attribute to the attribute set at the given index.
ImmutableCallSite - establish a view to a call site for examination.
FunctionType * getFunctionType() const
bool callsFunctionThatReturnsTwice() const
callsFunctionThatReturnsTwice - Return true if the function has a call to setjmp or other function th...
void setPrologueData(Constant *PrologueData)
unsigned getKeyLength() const
iterator find(const KeyT &Val)
Compile-time customization of User operands.
bool hasPrefixData() const
Constant * getPrefixData() const
static EVT getEVT(Type *Ty, bool HandleUnknown=false)
getEVT - Return the value type corresponding to the specified type.
AttributeSet getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
static ManagedStatic< sys::SmartRWMutex< true > > GCLock
void setAttributes(AttributeSet attrs)
Set the attribute list for this Function.
bool hasLocalLinkage() const
Type * getReturnType() const
Function can return twice.
unsigned getParamAlignment(unsigned i) const
Extract the alignment for a call or parameter (0=unknown).
static Type * DecodeFixedType(ArrayRef< Intrinsic::IITDescriptor > &Infos, ArrayRef< Type * > Tys, LLVMContext &Context)
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
const ArgumentListType & getArgumentList() const
Get the underlying elements of the Function...
unsigned getArgNo() const
Return the index of this formal argument in its containing function.
static VectorType * get(Type *ElementType, unsigned NumElements)
VectorType::get - This static method is the primary way to construct an VectorType.
inst_iterator inst_end(Function *F)
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
void addAttributes(unsigned i, AttributeSet attrs)
adds the attributes to the list of attributes.
AttributeSet addAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Add attributes to the attribute set at the given index.
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
NodeTy * remove(iterator &IT)
void setGlobalObjectSubClassData(unsigned Val)
bool hasReturnedAttr() const
Return true if this argument has the returned attribute on it in its containing function.
LLVMContext & getContext() const
Get the global data context.
bool isVoidTy() const
isVoidTy - Return true if this is 'void'.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...
void setPrefixData(Constant *PrefixData)