Go to the documentation of this file.
25 #include "llvm/Config/llvm-config.h"
58 const std::optional<unsigned> &NumElemsArg) {
60 "Attempting to pack a reserved value");
66 static std::pair<unsigned, std::optional<unsigned>>
69 unsigned ElemSizeArg = Num >> 32;
71 std::optional<unsigned> NumElemsArg;
73 NumElemsArg = NumElems;
74 return std::make_pair(ElemSizeArg, NumElemsArg);
78 std::optional<unsigned> MaxValue) {
79 return uint64_t(MinValue) << 32 | MaxValue.value_or(0);
82 static std::pair<unsigned, std::optional<unsigned>>
85 unsigned MinValue =
Value >> 32;
87 return std::make_pair(MinValue,
88 MaxValue > 0 ? MaxValue : std::optional<unsigned>());
95 "Not an enum or int attribute");
103 assert(Val == 0 &&
"Value must be zero for enum attributes");
115 pImpl->
AttrsSet.InsertNode(PA, InsertPoint);
126 if (!Val.
empty())
ID.AddString(Val);
138 pImpl->
AttrsSet.InsertNode(PA, InsertPoint);
160 pImpl->
AttrsSet.InsertNode(PA, InsertPoint);
173 assert(
A <= 0x100 &&
"Alignment too large.");
179 assert(Bytes &&
"Bytes must be non-zero.");
185 assert(Bytes &&
"Bytes must be non-zero.");
186 return get(
Context, DereferenceableOrNull, Bytes);
221 const std::optional<unsigned> &NumElemsArg) {
222 assert(!(ElemSizeArg == 0 && NumElemsArg && *NumElemsArg == 0) &&
223 "Invalid allocsize arguments -- given allocsize(0, 0)");
235 #define GET_ATTR_NAMES
236 #define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME) \
237 .Case(#DISPLAY_NAME, Attribute::ENUM_NAME)
238 #include "llvm/IR/Attributes.inc"
244 #define GET_ATTR_NAMES
245 #define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME) \
246 case Attribute::ENUM_NAME: \
247 return #DISPLAY_NAME;
248 #include "llvm/IR/Attributes.inc"
258 #define GET_ATTR_NAMES
259 #define ATTRIBUTE_ALL(ENUM_NAME, DISPLAY_NAME) .Case(#DISPLAY_NAME, true)
260 #include "llvm/IR/Attributes.inc"
285 if (!pImpl)
return None;
287 "Invalid attribute type to get the kind as an enum!");
292 if (!pImpl)
return 0;
294 "Expected the attribute to be an integer attribute!");
299 if (!pImpl)
return false;
301 "Expected the attribute to be a string attribute!");
306 if (!pImpl)
return {};
308 "Invalid attribute type to get the kind as a string!");
313 if (!pImpl)
return {};
315 "Invalid attribute type to get the value as a string!");
320 if (!pImpl)
return {};
322 "Invalid attribute type to get the value as a type!");
338 "Trying to get alignment from non-alignment attribute!");
344 "Trying to get alignment from non-alignment attribute!");
350 "Trying to get dereferenceable bytes from "
351 "non-dereferenceable attribute!");
357 "Trying to get dereferenceable bytes from "
358 "non-dereferenceable attribute!");
362 std::pair<unsigned, std::optional<unsigned>>
365 "Trying to get allocsize args from non-allocsize attribute");
371 "Trying to get vscale args from non-vscale attribute");
377 "Trying to get vscale args from non-vscale attribute");
383 "Trying to get unwind table kind from non-uwtable attribute");
389 "Trying to get allockind value from non-allockind attribute");
395 "Can only call getMemoryEffects() on memory attribute");
414 if (!pImpl)
return {};
439 auto AttrWithBytesToString = [&](
const char *
Name) {
446 return AttrWithBytesToString(
"alignstack");
449 return AttrWithBytesToString(
"dereferenceable");
452 return AttrWithBytesToString(
"dereferenceable_or_null");
456 std::optional<unsigned> NumElems;
460 ?
"allocsize(" +
Twine(ElemSize) +
"," +
Twine(*NumElems) +
")"
461 :
"allocsize(" +
Twine(ElemSize) +
")")
468 return (
"vscale_range(" +
Twine(MinValue) +
"," +
469 Twine(MaxValue.value_or(0)) +
")")
488 parts.push_back(
"alloc");
490 parts.push_back(
"realloc");
492 parts.push_back(
"free");
494 parts.push_back(
"uninitialized");
496 parts.push_back(
"zeroed");
498 parts.push_back(
"aligned");
499 return (
"allockind(\"" +
500 Twine(llvm::join(parts.begin(), parts.end(),
",")) +
"\")")
534 OS <<
"inaccessiblemem: ";
561 if (!AttrVal.empty()) {
563 printEscapedString(AttrVal, OS);
574 assert(
isValid() &&
"invalid Attribute doesn't refer to any context");
578 return C.pImpl->AttrsSet.FindNodeOrInsertPos(
ID, Unused) == pImpl;
582 if (!pImpl && !
A.pImpl)
return false;
583 if (!pImpl)
return true;
584 if (!
A.pImpl)
return false;
585 return *pImpl < *
A.pImpl;
589 ID.AddPointer(pImpl);
598 #define GET_ATTR_PROP_TABLE
599 #include "llvm/IR/Attributes.inc"
605 return AttrPropTable[
Index] & Prop;
705 B.addAttribute(
Kind);
733 B.removeAttribute(
Kind);
741 B.removeAttribute(
Kind);
777 return SetNode ? SetNode->
getAlignment() : std::nullopt;
805 return SetNode ? SetNode->
getAttributeType(Attribute::Preallocated) :
nullptr;
813 return SetNode ? SetNode->
getAttributeType(Attribute::ElementType) :
nullptr;
816 std::optional<std::pair<unsigned, std::optional<unsigned>>>
844 return SetNode ? SetNode->
getAsString(InAttrGrp) :
"";
852 return C.pImpl->AttrsSetNodes.FindNodeOrInsertPos(
ID, Unused) == SetNode;
856 return SetNode ? SetNode->
begin() :
nullptr;
860 return SetNode ? SetNode->
end() :
nullptr;
863 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
880 for (
const auto &
I : *
this) {
881 if (
I.isStringAttribute())
882 StringAttrs.insert({
I.getKindAsString(),
I });
884 AvailableAttrs.addAttribute(
I.getKindAsEnum());
892 return getSorted(
C, SortedAttrs);
897 if (SortedAttrs.
empty())
905 for (
const auto &Attr : SortedAttrs)
916 void *Mem = ::operator
new(totalSizeToAlloc<Attribute>(SortedAttrs.size()));
926 return getSorted(
C,
B.attrs());
930 return StringAttrs.count(
Kind);
933 std::optional<Attribute>
944 return A.getKindAsEnum() < Kind;
946 assert(
I !=
end() &&
I->hasAttribute(
Kind) &&
"Presence check failed?");
951 if (
auto A = findEnumAttribute(
Kind))
957 return StringAttrs.lookup(
Kind);
961 if (
auto A = findEnumAttribute(Attribute::Alignment))
962 return A->getAlignment();
967 if (
auto A = findEnumAttribute(Attribute::StackAlignment))
968 return A->getStackAlignment();
973 if (
auto A = findEnumAttribute(
Kind))
974 return A->getValueAsType();
979 if (
auto A = findEnumAttribute(Attribute::Dereferenceable))
980 return A->getDereferenceableBytes();
985 if (
auto A = findEnumAttribute(Attribute::DereferenceableOrNull))
986 return A->getDereferenceableOrNullBytes();
990 std::optional<std::pair<unsigned, std::optional<unsigned>>>
992 if (
auto A = findEnumAttribute(Attribute::AllocSize))
993 return A->getAllocSizeArgs();
998 if (
auto A = findEnumAttribute(Attribute::VScaleRange))
999 return A->getVScaleRangeMin();
1004 if (
auto A = findEnumAttribute(Attribute::VScaleRange))
1005 return A->getVScaleRangeMax();
1006 return std::nullopt;
1010 if (
auto A = findEnumAttribute(Attribute::UWTable))
1011 return A->getUWTableKind();
1016 if (
auto A = findEnumAttribute(Attribute::AllocKind))
1017 return A->getAllocKind();
1022 if (
auto A = findEnumAttribute(Attribute::Memory))
1023 return A->getMemoryEffects();
1032 Str +=
I->getAsString(InAttrGrp);
1048 : NumAttrSets(Sets.
size()) {
1049 assert(!Sets.
empty() &&
"pointless AttributeListImpl");
1052 llvm::copy(Sets, getTrailingObjects<AttributeSet>());
1057 if (!
I.isStringAttribute())
1060 for (
const auto &Set : Sets)
1061 for (
const auto &
I : Set)
1062 if (!
I.isStringAttribute())
1072 for (
const auto &Set : Sets)
1073 ID.AddPointer(Set.SetNode);
1077 unsigned *
Index)
const {
1082 for (
unsigned I = 0,
E = NumAttrSets;
I !=
E; ++
I) {
1094 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1106 assert(!AttrSets.
empty() &&
"pointless AttributeListImpl");
1114 pImpl->
AttrsLists.FindNodeOrInsertPos(
ID, InsertPoint);
1121 AttributeListImpl::totalSizeToAlloc<AttributeSet>(AttrSets.
size()),
1124 pImpl->
AttrsLists.InsertNode(PA, InsertPoint);
1139 "Misordered Attributes list!");
1141 [](
const std::pair<unsigned, Attribute> &Pair) {
1142 return Pair.second.isValid();
1144 "Pointless attribute!");
1151 unsigned Index =
I->first;
1153 while (
I !=
E &&
I->first ==
Index) {
1154 AttrVec.push_back(
I->second);
1161 return get(
C, AttrPairVec);
1172 "Misordered Attributes list!");
1174 [](
const std::pair<unsigned, AttributeSet> &Pair) {
1175 return !Pair.second.hasAttributes();
1177 "Pointless attribute!");
1186 for (
const auto &Pair :
Attrs)
1198 unsigned NumSets = 0;
1199 for (
size_t I = ArgAttrs.
size();
I != 0; --
I) {
1200 if (ArgAttrs[
I - 1].hasAttributes()) {
1221 AttrSets.push_back(FnAttrs);
1223 AttrSets.push_back(RetAttrs);
1235 if (!
Attrs.hasAttributes())
1251 for (
const auto K : Kinds)
1259 assert(Kinds.
size() == Values.
size() &&
"Mismatched attribute values.");
1262 for (
const auto K : Kinds)
1270 for (
const auto &K : Kinds)
1282 unsigned MaxSize = 0;
1291 for (
unsigned I = 0;
I < MaxSize; ++
I) {
1333 if (Index >= AttrSets.
size())
1334 AttrSets.resize(
Index + 1);
1339 AttrSets.pop_back();
1340 if (AttrSets.
empty())
1348 if (!
B.hasAttributes())
1366 if (MaxIndex >= AttrSets.size())
1367 AttrSets.
resize(MaxIndex + 1);
1369 for (
unsigned ArgNo : ArgNos) {
1384 if (
Attrs == NewAttrs)
1386 return setAttributesAtIndex(
C,
Index, NewAttrs);
1394 if (
Attrs == NewAttrs)
1396 return setAttributesAtIndex(
C,
Index, NewAttrs);
1404 if (
Attrs == NewAttrs)
1406 return setAttributesAtIndex(
C,
Index, NewAttrs);
1411 unsigned WithoutIndex)
const {
1416 return setAttributesAtIndex(
C, WithoutIndex,
AttributeSet());
1422 B.addDereferenceableAttr(Bytes);
1430 B.addDereferenceableAttr(Bytes);
1438 B.addDereferenceableOrNullAttr(Bytes);
1444 const std::optional<unsigned> &NumElemsArg) {
1446 B.addAllocSizeAttr(ElemSizeArg, NumElemsArg);
1480 return pImpl && pImpl->hasFnAttribute(
Kind);
1488 unsigned *
Index)
const {
1489 return pImpl && pImpl->hasAttrSomewhere(Attr,
Index);
1583 return pImpl->begin()[
Index];
1587 assert(!
isEmpty() &&
"an empty attribute list has no parent context");
1591 return C.pImpl->AttrsLists.FindNodeOrInsertPos(
ID, Unused) == pImpl;
1595 return pImpl ? pImpl->begin() :
nullptr;
1599 return pImpl ? pImpl->end() :
nullptr;
1607 return pImpl ? pImpl->NumAttrSets : 0;
1611 O <<
"AttributeList[\n";
1618 case AttrIndex::ReturnIndex:
1621 case AttrIndex::FunctionIndex:
1625 O <<
"arg(" <<
i - AttrIndex::FirstArgIndex <<
")";
1633 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1676 template <
typename K>
1680 if (It !=
Attrs.
end() && It->hasAttribute(Kind))
1707 if (It != Attrs.end() && It->hasAttribute(Val))
1714 if (It != Attrs.end() && It->hasAttribute(A))
1719 std::optional<uint64_t>
1724 return A.getValueAsInt();
1725 return std::nullopt;
1733 std::optional<std::pair<unsigned, std::optional<unsigned>>>
1737 return A.getAllocSizeArgs();
1738 return std::nullopt;
1754 assert(*
Align <= 0x100 &&
"Alignment too large.");
1759 if (Bytes == 0)
return *
this;
1768 return addRawIntAttr(Attribute::DereferenceableOrNull, Bytes);
1773 const std::optional<unsigned> &NumElems) {
1779 assert(RawArgs &&
"Invalid allocsize arguments -- given allocsize(0, 0)");
1784 std::optional<unsigned> MaxValue) {
1813 return A.isValid() ? A.getValueAsType() :
nullptr;
1842 for (
const auto &
I :
B.attrs())
1860 if (It != Attrs.end() && It->hasAttribute(A))
1867 if (It != Attrs.end() && It->hasAttribute(A))
1881 return Attrs ==
B.Attrs;
1935 return Incompatible;
1946 template<
typename AttrClass>
1948 return Caller.getFnAttribute(AttrClass::getKind()) ==
1949 Callee.getFnAttribute(AttrClass::getKind());
1957 template<
typename AttrClass>
1959 if (AttrClass::isSet(Caller, AttrClass::getKind()) &&
1960 !AttrClass::isSet(
Callee, AttrClass::getKind()))
1969 template<
typename AttrClass>
1971 if (!AttrClass::isSet(Caller, AttrClass::getKind()) &&
1972 AttrClass::isSet(
Callee, AttrClass::getKind()))
1982 if (!Caller.hasStackProtectorFnAttr())
1993 if (
Callee.hasFnAttribute(Attribute::StackProtectReq)) {
1994 Caller.removeFnAttrs(OldSSPAttr);
1995 Caller.addFnAttr(Attribute::StackProtectReq);
1996 }
else if (
Callee.hasFnAttribute(Attribute::StackProtectStrong) &&
1997 !Caller.hasFnAttribute(Attribute::StackProtectReq)) {
1998 Caller.removeFnAttrs(OldSSPAttr);
1999 Caller.addFnAttr(Attribute::StackProtectStrong);
2000 }
else if (
Callee.hasFnAttribute(Attribute::StackProtect) &&
2001 !Caller.hasFnAttribute(Attribute::StackProtectReq) &&
2002 !Caller.hasFnAttribute(Attribute::StackProtectStrong))
2003 Caller.addFnAttr(Attribute::StackProtect);
2009 if (!Caller.hasFnAttribute(
"probe-stack") &&
2010 Callee.hasFnAttribute(
"probe-stack")) {
2011 Caller.addFnAttr(
Callee.getFnAttribute(
"probe-stack"));
2022 Attribute CallerAttr = Caller.getFnAttribute(
"stack-probe-size");
2024 uint64_t CallerStackProbeSize, CalleeStackProbeSize;
2028 if (CallerStackProbeSize > CalleeStackProbeSize) {
2029 Caller.addFnAttr(CalleeAttr);
2032 Caller.addFnAttr(CalleeAttr);
2048 Attribute CallerAttr = Caller.getFnAttribute(
"min-legal-vector-width");
2050 Attribute CalleeAttr =
Callee.getFnAttribute(
"min-legal-vector-width");
2052 uint64_t CallerVectorWidth, CalleeVectorWidth;
2055 if (CallerVectorWidth < CalleeVectorWidth)
2056 Caller.addFnAttr(CalleeAttr);
2060 Caller.removeFnAttr(
"min-legal-vector-width");
2069 if (
Callee.nullPointerIsDefined() && !Caller.nullPointerIsDefined()) {
2070 Caller.addFnAttr(Attribute::NullPointerIsValid);
2093 return A.getValueAsString().equals(
"true");
2098 Fn.
addFnAttr(Kind, Val ?
"true" :
"false");
2102 #define GET_ATTR_NAMES
2103 #define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME) \
2104 struct ENUM_NAME##Attr : EnumAttr { \
2105 static enum Attribute::AttrKind getKind() { \
2106 return llvm::Attribute::ENUM_NAME; \
2109 #define ATTRIBUTE_STRBOOL(ENUM_NAME, DISPLAY_NAME) \
2110 struct ENUM_NAME##Attr : StrBoolAttr { \
2111 static StringRef getKind() { return #DISPLAY_NAME; } \
2113 #include "llvm/IR/Attributes.inc"
2115 #define GET_ATTR_COMPAT_FUNC
2116 #include "llvm/IR/Attributes.inc"
2120 return hasCompatibleFnAttrs(Caller,
Callee);
2125 return hasCompatibleFnAttrs(A,
B);
2130 mergeFnAttrs(Caller,
Callee);
2143 mergeFnAttrs(
Base, ToMerge);
2152 if (
Width > OldWidth)
AttributeList removeAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified index from this attribute list.
std::pair< unsigned, std::optional< unsigned > > getAllocSizeArgs() const
Returns the argument numbers for the allocsize attribute.
AttrBuilder & addDereferenceableOrNullAttr(uint64_t Bytes)
This turns the number of dereferenceable_or_null bytes into the form used internally in Attribute.
uint64_t getRetDereferenceableOrNullBytes() const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of the return value.
Type * getParamInAllocaType(unsigned ArgNo) const
Return the inalloca type for the specified function parameter.
void print(raw_ostream &O) const
static Attribute getWithPreallocatedType(LLVMContext &Context, Type *Ty)
AttributeList removeAttributesAtIndex(LLVMContext &C, unsigned Index, const AttributeMask &AttrsToRemove) const
Remove the specified attributes at the specified index from this attribute list.
@ EndAttrKinds
Sentinal value useful for loops.
We currently generate a but we really shouldn eax ecx xorl edx divl ecx eax divl ecx movl eax ret A similar code sequence works for division We currently compile i32 v2 eax eax jo LBB1_2 atomic and others It is also currently not done for read modify write instructions It is also current not done if the OF or CF flags are needed The shift operators have the complication that when the shift count is EFLAGS is not set
@ NoModRef
The access neither references nor modifies the value stored in memory.
LLVMContextImpl *const pImpl
AttributeSet()=default
AttributeSet is a trivially copyable value type.
Attribute getAttribute(Attribute::AttrKind Kind) const
Return Attribute with the given Kind.
void mergeAttributesForOutlining(Function &Base, const Function &ToMerge)
Merges the functions attributes from ToMerge into function Base.
static Attribute getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg)
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This is an optimization pass for GlobalISel generic memory operations.
bool isEnumAttribute() const
Return true if the attribute is an Attribute::AttrKind type.
bool isValid() const
Return true if the attribute is any kind of attribute.
AttributeList addDereferenceableParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given arg index.
AttrBuilder(LLVMContext &Ctx)
bool hasAttributes() const
Return true if attributes exists in this set.
AttrBuilder & addUWTableAttr(UWTableKind Kind)
This turns the unwind table kind into the form used internally in Attribute.
static StringRef getStringValue(IO &IO, const char *Key)
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
bool hasAttributesAtIndex(unsigned Index) const
Return true if attribute exists at the given index.
AllocFnKind getAllocKind() const
static unsigned attrIdxToArrayIdx(unsigned Index)
Map from AttributeList index to the internal array index.
MaybeAlign getStackAlignment() const
Returns the stack alignment field of an attribute as a byte alignment value.
bool hasAttrSomewhere(Attribute::AttrKind Kind, unsigned *Index=nullptr) const
Return true if the specified attribute is set for at least one parameter or for the return value.
static constexpr uint64_t MaximumAlignment
AttrBuilder & addTypeAttr(Attribute::AttrKind Kind, Type *Ty)
Add a type attribute with the given type.
bool isPointerTy() const
True if this is an instance of PointerType.
uint64_t getDereferenceableOrNullBytes() const
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
unsigned getNumAttributes() const
Return the number of attributes this AttributeList contains.
static void set(Function &Fn, Attribute::AttrKind Kind, bool Val)
A raw_ostream that writes to an std::string.
Type * getParamPreallocatedType(unsigned ArgNo) const
Return the preallocated type for the specified function parameter.
bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
static Attribute::AttrKind getAttrKindFromName(StringRef AttrName)
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
bool isTypeAttribute() const
Return true if the attribute is a type attribute.
static bool isIntAttrKind(AttrKind Kind)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
@ None
No unwind table requested.
static uint64_t packAllocSizeArgs(unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg)
static LazyValueInfoImpl & getImpl(void *&PImpl, AssumptionCache *AC, const Module *M)
This lazily constructs the LazyValueInfoImpl.
UWTableKind getUWTableKind() const
Get the unwind table kind requested for the function.
static const char * getModRefStr(ModRefInfo MR)
static void adjustCallerStackProbes(Function &Caller, const Function &Callee)
If the inlined function required stack probes, then ensure that the calling function has those too.
AttributeSet addAttributes(LLVMContext &C, AttributeSet AS) const
Add attributes to the attribute set.
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
AttributeMask getUBImplyingAttributes()
Get param/return attributes which imply immediate undefined behavior if an invalid value is passed.
static AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute >> Attrs)
Create an AttributeList with the specified parameters in it.
static const unsigned AllocSizeNumElemsNotPresent
static Attribute getWithStackAlignment(LLVMContext &Context, Align Alignment)
static void setOR(Function &Caller, const Function &Callee)
Compute the logical OR of the attributes of the caller and the callee.
Type * getParamByValType(unsigned ArgNo) const
Return the byval type for the specified function parameter.
std::optional< uint64_t > getRawIntAttr(Attribute::AttrKind Kind) const
Return raw (possibly packed/encoded) value of integer attribute or std::nullopt if not set.
The instances of the Type class are immutable: once they are created, they are never changed.
static Attribute getWithVScaleRangeArgs(LLVMContext &Context, unsigned MinValue, unsigned MaxValue)
AttributeList addDereferenceableRetAttr(LLVMContext &C, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
static bool isTypeAttrKind(AttrKind Kind)
AttrBuilder & addAllocKindAttr(AllocFnKind Kind)
OutputIt copy(R &&Range, OutputIt Out)
@ ArgMem
Access to memory via argument pointers.
AttributeSet getFnAttrs() const
The function attributes are returned.
Function::iterator insert(Function::iterator Position, BasicBlock *BB)
Insert BB in the basic block list at Position.
bool hasAttribute(Attribute::AttrKind Kind) const
@ InaccessibleMem
Memory that is inaccessible via LLVM IR.
unsigned getVScaleRangeMin() const
AttrBuilder & addPreallocatedAttr(Type *Ty)
This turns a preallocated type into the form used internally in Attribute.
static void setAND(Function &Caller, const Function &Callee)
Compute the logical AND of the attributes of the caller and the callee.
MaybeAlign getAlignment() const
Returns the alignment field of an attribute as a byte alignment value.
static void adjustMinLegalVectorWidth(Function &Caller, const Function &Callee)
If the inlined function defines a min legal vector width, then ensure the calling function has the sa...
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
AttrBuilder & addRawIntAttr(Attribute::AttrKind Kind, uint64_t Value)
Add integer attribute with raw value (packed/encoded if necessary).
uint64_t getDereferenceableBytes() const
static uint64_t packVScaleRangeArgs(unsigned MinValue, std::optional< unsigned > MaxValue)
static MemoryEffects createFromIntValue(uint32_t Data)
Create MemoryEffects from an encoded integer value (used by memory attribute).
AttrBuilder & merge(const AttrBuilder &B)
Add the attributes from the builder.
bool getValueAsBool() const
Return the attribute's value as a boolean.
static void adjustNullPointerValidAttr(Function &Caller, const Function &Callee)
If the inlined function has null_pointer_is_valid attribute, set this attribute in the caller post in...
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
FoldingSet< AttributeImpl > AttrsSet
bool empty() const
empty - Check if the array is empty.
static void adjustCallerSSPLevel(Function &Caller, const Function &Callee)
If the inlined function had a higher stack protection level than the calling function,...
AttrBuilder & removeAttribute(Attribute::AttrKind Val)
Remove an attribute from the builder.
MaybeAlign getAlignment() const
uint64_t getParamDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown) of an arg.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Summary of how a function affects memory in the program.
AttrBuilder & remove(const AttributeMask &AM)
Remove the attributes from the builder.
AllocFnKind getAllocKind() const
MaybeAlign getParamStackAlignment(unsigned ArgNo) const
Return the stack alignment for the specified function parameter.
uint64_t getValueAsInt() const
Return the attribute's value as an integer.
AttributeSet addAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add an argument attribute.
bool hasAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
const T & back() const
back - Get the last element.
static Attribute getWithInAllocaType(LLVMContext &Context, Type *Ty)
Type * getTypeAttr(Attribute::AttrKind Kind) const
Retrieve type for the given type attribute.
AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo, const AttrBuilder &B) const
Add an argument attribute to the list.
bool hasParentContext(LLVMContext &C) const
Return true if this attribute list belongs to the LLVMContext.
@ Ref
The access may reference the value stored in memory.
static void addAttributeImpl(SmallVectorImpl< Attribute > &Attrs, K Kind, Attribute Attr)
AttrBuilder & addByValAttr(Type *Ty)
This turns a byval type into the form used internally in Attribute.
std::string getAsString(bool InAttrGrp=false) const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Function object to check whether the first component of a std::pair compares less than the first comp...
(vector float) vec_cmpeq(*A, *B) C
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of an arg.
bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
bool isEnumAttribute() const
bool operator==(const AttrBuilder &B) const
StringRef getKindAsString() const
AttributeList addAllocSizeParamAttr(LLVMContext &C, unsigned ArgNo, unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg)
Add the allocsize attribute to the attribute set at the given arg index.
void print(raw_ostream &O, bool IsForDebug=false, bool NoDetails=false) const
Print the current type.
static void set(Function &Fn, StringRef Kind, bool Val)
static Attribute getWithMemoryEffects(LLVMContext &Context, MemoryEffects ME)
AttrBuilder & addVScaleRangeAttr(unsigned MinValue, std::optional< unsigned > MaxValue)
This turns two ints into the form used internally in Attribute.
bool hasAttribute(Attribute::AttrKind A) const
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
Attribute::AttrKind getKindAsEnum() const
bool isIntAttribute() const
uint64_t getDereferenceableBytes() const
bool areOutlineCompatible(const Function &A, const Function &B)
Checks if there are any incompatible function attributes between A and B.
std::optional< unsigned > getVScaleRangeMax() const
Returns the maximum value for the vscale_range attribute or std::nullopt when unknown.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
into llvm powi allowing the code generator to produce balanced multiplication trees First
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
unsigned getVScaleRangeMin() const
Returns the minimum value for the vscale_range attribute.
MemoryEffects getMemoryEffects() const
Returns memory effects of the function.
bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the function.
bool hasAttribute(Attribute::AttrKind Kind) const
static bool isSet(const Function &Fn, StringRef Kind)
AttributeSet getAttributes(unsigned Index) const
The attributes for the specified index are returned.
MaybeAlign getRetAlignment() const
Return the alignment of the return value.
This class implements an extremely fast bulk output stream that can only output to a stream.
Type * getInAllocaType() const
StringRef getKindAsString() const
Return the attribute's kind as a string.
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
Type * getParamElementType(unsigned ArgNo) const
Return the elementtype type for the specified function parameter.
AttributeList addDereferenceableOrNullParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable_or_null attribute to the attribute set at the given arg index.
This struct is a compact representation of a valid (non-zero power of two) alignment.
static Attribute getWithStructRetType(LLVMContext &Context, Type *Ty)
std::optional< std::pair< unsigned, std::optional< unsigned > > > getAllocSizeArgs() const
Retrieve the allocsize args, or std::nullopt if the attribute does not exist.
static bool isEnumAttrKind(AttrKind Kind)
static bool hasAttributeProperty(Attribute::AttrKind Kind, AttributeProperty Prop)
StringRef getValueAsString() const
Return the attribute's value as a string.
std::optional< unsigned > getVScaleRangeMax() const
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
AttrBuilder & addAlignmentAttr(MaybeAlign Align)
This turns an alignment into the form used internally in Attribute.
bool isIntegerTy() const
True if this is an instance of IntegerType.
void sort(IteratorTy Start, IteratorTy End)
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
constexpr bool empty() const
empty - Check if the string is empty.
UWTableKind getUWTableKind() const
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
AttrBuilder & addAllocSizeAttr(unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg)
This turns one (or two) ints into the form used internally in Attribute.
static MemoryEffects unknown()
Create MemoryEffects that can read and write any memory.
AttributeSet getRetAttrs() const
The attributes for the ret value are returned.
AttrBuilder & addStackAlignmentAttr(MaybeAlign Align)
This turns a stack alignment into the form used internally in Attribute.
static bool canUseAsFnAttr(AttrKind Kind)
std::optional< std::pair< unsigned, std::optional< unsigned > > > getAllocSizeArgs() const
uint32_t toIntValue() const
Convert MemoryEffects into an encoded integer value (used by memory attribute).
static auto locations()
Returns iterator over all supported location kinds.
std::optional< unsigned > getVScaleRangeMax() const
@ None
No attributes have been set.
uint64_t getRetDereferenceableBytes() const
Get the number of dereferenceable bytes (or zero if unknown) of the return value.
friend class AttributeList
AttrBuilder & addVScaleRangeAttrFromRawRepr(uint64_t RawVScaleRangeRepr)
Add a vscale_range attribute, using the representation returned by Attribute.getIntValue().
static AttributeSet get(LLVMContext &C, const AttrBuilder &B)
AttrBuilder & addInAllocaAttr(Type *Ty)
This turns an inalloca type into the form used internally in Attribute.
static Attribute getWithUWTableKind(LLVMContext &Context, UWTableKind Kind)
This is an important class for using LLVM in a threaded context.
std::string getAsString(unsigned Index, bool InAttrGrp=false) const
Return the attributes at the index as a string.
ModRefInfo getModRef(Location Loc) const
Get ModRefInfo for the given Location.
Type * getAttributeType(Attribute::AttrKind Kind) const
Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind).
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
static Attribute getWithDereferenceableBytes(LLVMContext &Context, uint64_t Bytes)
void Profile(FoldingSetNodeID &ID) const
MaybeAlign getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
static bool canUseAsParamAttr(AttrKind Kind)
StringRef getValueAsString() const
AttributeSet removeAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attributes from this set.
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
bool hasParentContext(LLVMContext &C) const
Return true if this attribute set belongs to the LLVMContext.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
AttrBuilder & addByRefAttr(Type *Ty)
This turns a byref type into the form used internally in Attribute.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
std::string getAsString(bool InAttrGrp=false) const
The Attribute is converted to a string of equivalent mnemonic.
uint64_t getDereferenceableOrNullBytes() const
FoldingSet< AttributeListImpl > AttrsLists
Attribute comparator that only compares attribute keys.
bool isVoidTy() const
Return true if this is 'void'.
AttributeSet removeAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute from this set.
bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
bool isTypeAttribute() const
unsigned getNumAttributes() const
Return the number of attributes in this set.
MaybeAlign getStackAlignment() const
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
static std::pair< unsigned, std::optional< unsigned > > unpackVScaleRangeArgs(uint64_t Value)
bool operator<(const AttributeImpl &AI) const
Used when sorting the attributes.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
friend class AttributeListImpl
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
This class provides various memory handling functions that manipulate MemoryBlock instances.
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Attribute getAttribute(Attribute::AttrKind Kind) const
@ Sync
"Synchronous" unwind tables
uint64_t getDereferenceableOrNullBytes() const
Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute.
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
Type * getParamByRefType(unsigned ArgNo) const
Return the byref type for the specified function parameter.
@ Mod
The access may modify the value stored in memory.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
void updateMinLegalVectorWidthAttr(Function &Fn, uint64_t Width)
Update min-legal-vector-width if it is in Attribute and less than Width.
UWTableKind getUWTableKind() const
static void adjustCallerStackProbeSize(Function &Caller, const Function &Callee)
If the inlined function defines the size of guard region on the stack, then ensure that the calling f...
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
AttrBuilder & addAllocSizeAttrFromRawRepr(uint64_t RawAllocSizeRepr)
Add an allocsize attribute, using the representation returned by Attribute.getIntValue().
UWTableKind getUWTableKind() const
static Attribute getWithDereferenceableOrNullBytes(LLVMContext &Context, uint64_t Bytes)
MaybeAlign getRetStackAlignment() const
Get the stack alignment of the return value.
bool operator()(Attribute A0, StringRef Kind) const
void Profile(FoldingSetNodeID &ID) const
static size_t totalSizeToAlloc(StringRef Kind, StringRef Val)
AttrBuilder & addStructRetAttr(Type *Ty)
This turns a sret type into the form used internally in Attribute.
AttributeList addAttributesAtIndex(LLVMContext &C, unsigned Index, const AttrBuilder &B) const
Add attributes to the attribute set at the given index.
amdgpu Simplify well known AMD library false FunctionCallee Callee
static Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
bool getValueAsBool() const
uint64_t getDereferenceableBytes() const
Returns the number of dereferenceable bytes from the dereferenceable attribute.
bool hasParentContext(LLVMContext &C) const
Return true if this attribute belongs to the LLVMContext.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
AttributeListImpl(ArrayRef< AttributeSet > Sets)
Type * getPreallocatedType() const
Type * getByRefType() const
static bool isExistingAttribute(StringRef Name)
Return true if the provided string matches the IR name of an attribute.
Type * getByValType() const
AllocFnKind getAllocKind() const
ArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
uint64_t value() const
This is a hole in the type system and should not be abused.
MemoryEffects getMemoryEffects() const
const BasicBlock & back() const
LLVM_ATTRIBUTE_RETURNS_NONNULL void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
Type * getParamStructRetType(unsigned ArgNo) const
Return the sret type for the specified function parameter.
Type * getValueAsType() const
Return the attribute's value as a Type.
MemoryEffects getMemoryEffects() const
AttrBuilder & addMemoryAttr(MemoryEffects ME)
Add memory effect attribute.
bool operator()(Attribute A0, Attribute::AttrKind Kind) const
bool is_sorted(R &&Range, Compare C)
Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...
unsigned getNumAttrSets() const
AttributeMask typeIncompatible(Type *Ty, AttributeSafetyKind ASK=ASK_ALL)
Which attributes cannot be applied to a type.
static std::pair< unsigned, std::optional< unsigned > > unpackAllocSizeArgs(uint64_t Num)
FoldingSet< AttributeSetNode > AttrsSetNodes
Attribute getAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
Type * getElementType() const
bool operator()(Attribute A0, Attribute A1) const
AttrBuilder & addDereferenceableAttr(uint64_t Bytes)
This turns the number of dereferenceable bytes into the form used internally in Attribute.
std::optional< std::pair< unsigned, std::optional< unsigned > > > getAllocSizeArgs() const
static Attribute getWithByRefType(LLVMContext &Context, Type *Ty)
static StringRef getNameFromAttrKind(Attribute::AttrKind AttrKind)
bool areInlineCompatible(const Function &Caller, const Function &Callee)
Attribute getAttribute(Attribute::AttrKind Kind) const
Return the attribute object.
std::string getAsString(bool InAttrGrp) const
void removeFnAttr(Attribute::AttrKind Kind)
Remove function attributes from this function.
void addAttribute(Attribute::AttrKind Kind)
AttributeList addRetAttributes(LLVMContext &C, const AttrBuilder &B) const
Add a return value attribute to the list.
size_t size() const
size - Get the array size.
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
index_iterator indexes() const
Use this to iterate over the valid attribute indexes.
friend class AttributeSet
AttributeList addAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Type * getValueAsType() const
void Profile(FoldingSetNodeID &ID) const
MaybeAlign getStackAlignment() const
bool isIntAttribute() const
Return true if the attribute is an integer attribute.
Type * getStructRetType() const
ArrayRef(const T &OneElt) -> ArrayRef< T >
A switch()-like statement whose cases are string literals.
std::string str() const
str - Get the contents as an std::string.
void mergeAttributesForInlining(Function &Caller, const Function &Callee)
Merge caller's and callee's attributes.
AttributeMask & addAttribute(Attribute::AttrKind Val)
Add an attribute to the mask.
void Profile(FoldingSetNodeID &ID) const
MaybeAlign getAlignment() const
AllocFnKind getAllocKind() const
static Attribute getWithByValType(LLVMContext &Context, Type *Ty)
AttributeSet getParamAttrs(unsigned ArgNo) const
The attributes for the argument or parameter at the given index are returned.
void reserve(size_type N)
bool overlaps(const AttributeMask &AM) const
Return true if the builder has any attribute that's in the specified builder.
bool hasAttrSomewhere(Attribute::AttrKind Kind, unsigned *Index=nullptr) const
Return true if the specified attribute is set for at least one parameter or for the return value.
LLVM Value Representation.
bool isStringAttribute() const
static bool isSet(const Function &Fn, Attribute::AttrKind Kind)
bool operator<(Attribute A) const
Less-than operator. Useful for sorting the attributes list.
bool isEmpty() const
Return true if there are no attributes.
uint64_t getValueAsInt() const
static AttributeSetNode * get(LLVMContext &C, const AttrBuilder &B)
@ ModRef
The access may reference and may modify the value stored in memory.
unsigned getVScaleRangeMin() const
static bool canUseAsRetAttr(AttrKind Kind)
MemoryEffects getMemoryEffects() const
Returns memory effects.
reference emplace_back(ArgTypes &&... Args)
MaybeAlign getFnStackAlignment() const
Get the stack alignment of the function.