26 #include "llvm/Config/llvm-config.h" 63 "Attempting to pack a reserved value");
65 return uint64_t(ElemSizeArg) << 32 |
66 NumElemsArg.
getValueOr(AllocSizeNumElemsNotPresent);
69 static std::pair<unsigned, Optional<unsigned>>
72 unsigned ElemSizeArg = Num >> 32;
75 if (NumElems != AllocSizeNumElemsNotPresent)
76 NumElemsArg = NumElems;
77 return std::make_pair(ElemSizeArg, NumElemsArg);
97 pImpl->
AttrsSet.InsertNode(PA, InsertPoint);
117 pImpl->
AttrsSet.InsertNode(PA, InsertPoint);
138 pImpl->
AttrsSet.InsertNode(PA, InsertPoint);
146 assert(A <= 0x40000000 &&
"Alignment too large.");
151 assert(A <= 0x100 &&
"Alignment too large.");
157 assert(Bytes &&
"Bytes must be non-zero.");
158 return get(
Context, Dereferenceable, Bytes);
163 assert(Bytes &&
"Bytes must be non-zero.");
164 return get(
Context, DereferenceableOrNull, Bytes);
168 return get(
Context, ByVal, Ty);
174 assert(!(ElemSizeArg == 0 && NumElemsArg && *NumElemsArg == 0) &&
175 "Invalid allocsize arguments -- given allocsize(0, 0)");
200 if (!pImpl)
return None;
202 "Invalid attribute type to get the kind as an enum!");
207 if (!pImpl)
return 0;
209 "Expected the attribute to be an integer attribute!");
214 if (!pImpl)
return {};
216 "Invalid attribute type to get the kind as a string!");
221 if (!pImpl)
return {};
223 "Invalid attribute type to get the value as a string!");
228 if (!pImpl)
return {};
230 "Invalid attribute type to get the value as a type!");
246 "Trying to get alignment from non-alignment attribute!");
252 "Trying to get alignment from non-alignment attribute!");
258 "Trying to get dereferenceable bytes from " 259 "non-dereferenceable attribute!");
265 "Trying to get dereferenceable bytes from " 266 "non-dereferenceable attribute!");
272 "Trying to get allocsize args from non-allocsize attribute");
277 if (!pImpl)
return {};
280 return "sanitize_address";
282 return "sanitize_hwaddress";
284 return "sanitize_memtag";
286 return "alwaysinline";
298 return "inaccessiblememonly";
299 if (
hasAttribute(Attribute::InaccessibleMemOrArgMemOnly))
300 return "inaccessiblemem_or_argmemonly";
322 return "noduplicate";
326 return "noimplicitfloat";
330 return "nonlazybind";
348 return "optforfuzzing";
362 return "returns_twice";
366 return "speculative_load_hardening";
368 return "speculatable";
378 return "shadowcallstack";
384 return "sanitize_thread";
386 return "sanitize_memory";
402 Ty->print(OS,
false,
true);
417 Result += (InAttrGrp) ?
"=" :
" ";
422 auto AttrWithBytesToString = [&](
const char *
Name) {
437 return AttrWithBytesToString(
"alignstack");
440 return AttrWithBytesToString(
"dereferenceable");
443 return AttrWithBytesToString(
"dereferenceable_or_null");
450 std::string Result =
"allocsize(";
451 Result +=
utostr(ElemSize);
454 Result +=
utostr(*NumElems);
470 if (AttrVal.empty())
return Result;
488 if (!pImpl && !A.pImpl)
return false;
489 if (!pImpl)
return true;
490 if (!A.pImpl)
return false;
491 return *pImpl < *A.pImpl;
501 void EnumAttributeImpl::anchor() {}
503 void IntAttributeImpl::anchor() {}
505 void StringAttributeImpl::anchor() {}
507 void TypeAttributeImpl::anchor() {}
558 "Comparison of types would be unstable");
614 if (!hasAttributes())
621 for (
const auto I : *
this)
651 return SetNode ? SetNode->getNumAttributes() : 0;
655 return SetNode ? SetNode->hasAttribute(Kind) :
false;
659 return SetNode ? SetNode->hasAttribute(Kind) :
false;
663 return SetNode ? SetNode->getAttribute(Kind) :
Attribute();
667 return SetNode ? SetNode->getAttribute(Kind) :
Attribute();
671 return SetNode ? SetNode->getAlignment() :
None;
675 return SetNode ? SetNode->getStackAlignment() :
None;
679 return SetNode ? SetNode->getDereferenceableBytes() : 0;
683 return SetNode ? SetNode->getDereferenceableOrNullBytes() : 0;
687 return SetNode ? SetNode->getByValType() :
nullptr;
691 return SetNode ? SetNode->getAllocSizeArgs()
692 : std::pair<unsigned, Optional<unsigned>>(0, 0);
696 return SetNode ? SetNode->getAsString(InAttrGrp) :
"";
700 return SetNode ? SetNode->begin() :
nullptr;
704 return SetNode ? SetNode->end() :
nullptr;
707 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 720 : NumAttrs(Attrs.
size()) {
722 llvm::copy(Attrs, getTrailingObjects<Attribute>());
725 sizeof(AvailableAttrs) * CHAR_BIT,
726 "Too many attributes");
728 for (
const auto I : *
this) {
729 if (!
I.isStringAttribute()) {
731 AvailableAttrs[Kind / 8] |= 1ULL << (Kind % 8);
748 for (
const auto Attr : SortedAttrs)
759 void *Mem = ::operator
new(totalSizeToAlloc<Attribute>(SortedAttrs.size()));
778 case Attribute::ByVal:
781 case Attribute::Alignment:
785 case Attribute::StackAlignment:
789 case Attribute::Dereferenceable:
793 case Attribute::DereferenceableOrNull:
797 case Attribute::AllocSize: {
809 for (
const auto &TDA : B.
td_attrs())
816 for (
const auto I : *
this)
817 if (
I.hasAttribute(Kind))
824 for (
const auto I : *
this)
825 if (
I.hasAttribute(Kind))
832 for (
const auto I : *
this)
833 if (
I.hasAttribute(Kind))
839 for (
const auto I : *
this)
840 if (
I.hasAttribute(Attribute::Alignment))
841 return I.getAlignment();
846 for (
const auto I : *
this)
847 if (
I.hasAttribute(Attribute::StackAlignment))
848 return I.getStackAlignment();
853 for (
const auto I : *
this)
854 if (
I.hasAttribute(Attribute::ByVal))
855 return I.getValueAsType();
860 for (
const auto I : *
this)
861 if (
I.hasAttribute(Attribute::Dereferenceable))
862 return I.getDereferenceableBytes();
867 for (
const auto I : *
this)
868 if (
I.hasAttribute(Attribute::DereferenceableOrNull))
869 return I.getDereferenceableOrNullBytes();
873 std::pair<unsigned, Optional<unsigned>>
875 for (
const auto I : *
this)
876 if (
I.hasAttribute(Attribute::AllocSize))
877 return I.getAllocSizeArgs();
878 return std::make_pair(0, 0);
886 Str +=
I->getAsString(InAttrGrp);
906 assert(!Sets.
empty() &&
"pointless AttributeListImpl");
909 llvm::copy(Sets, getTrailingObjects<AttributeSet>());
913 sizeof(AvailableFunctionAttrs) * CHAR_BIT,
914 "Too many attributes");
916 "function should be stored in slot 0");
917 for (
const auto I : Sets[0]) {
918 if (!
I.isStringAttribute()) {
920 AvailableFunctionAttrs[Kind / 8] |= 1ULL << (Kind % 8);
931 for (
const auto &Set : Sets)
935 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 947 assert(!AttrSets.
empty() &&
"pointless AttributeListImpl");
955 pImpl->AttrsLists.FindNodeOrInsertPos(ID, InsertPoint);
961 void *Mem = ::operator
new(
962 AttributeListImpl::totalSizeToAlloc<AttributeSet>(AttrSets.
size()));
964 pImpl->AttrsLists.InsertNode(PA, InsertPoint);
973 ArrayRef<std::pair<unsigned, Attribute>> Attrs) {
979 [](
const std::pair<unsigned, Attribute> &LHS,
980 const std::pair<unsigned, Attribute> &RHS) {
981 return LHS.first < RHS.first;
982 }) &&
"Misordered Attributes list!");
984 [](
const std::pair<unsigned, Attribute> &Pair) {
987 "Pointless attribute!");
993 E = Attrs.
end();
I !=
E; ) {
994 unsigned Index =
I->first;
996 while (
I !=
E &&
I->first == Index) {
1004 return get(
C, AttrPairVec);
1009 ArrayRef<std::pair<unsigned, AttributeSet>> Attrs) {
1015 [](
const std::pair<unsigned, AttributeSet> &LHS,
1016 const std::pair<unsigned, AttributeSet> &RHS) {
1017 return LHS.first < RHS.first;
1019 "Misordered Attributes list!");
1021 [](
const std::pair<unsigned, AttributeSet> &Pair) {
1022 return !Pair.second.hasAttributes();
1024 "Pointless attribute!");
1026 unsigned MaxIndex = Attrs.
back().first;
1029 if (MaxIndex == FunctionIndex && Attrs.
size() > 1)
1030 MaxIndex = Attrs[Attrs.
size() - 2].first;
1033 for (
const auto Pair : Attrs)
1045 unsigned NumSets = 0;
1046 for (
size_t I = ArgAttrs.
size();
I != 0; --
I) {
1047 if (ArgAttrs[
I - 1].hasAttributes()) {
1093 for (
const auto K : Kinds)
1101 for (
const auto K : Kinds)
1110 if (Attrs.
size() == 1)
1113 unsigned MaxSize = 0;
1114 for (
const auto List : Attrs)
1122 for (
unsigned I = 0;
I < MaxSize; ++
I) {
1124 for (
const auto List : Attrs)
1129 return getImpl(C, NewAttrSets);
1134 if (hasAttribute(Index, Kind))
return *
this;
1137 return addAttributes(C, Index, B);
1145 return addAttributes(C, Index, B);
1152 return addAttributes(C, Index, B);
1168 assert((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
1169 "Attempt to change alignment!");
1174 if (Index >= AttrSets.
size())
1175 AttrSets.
resize(Index + 1);
1191 if (MaxIndex >= AttrSets.
size())
1192 AttrSets.
resize(MaxIndex + 1);
1194 for (
unsigned ArgNo : ArgNos) {
1206 if (!hasAttribute(Index, Kind))
return *
this;
1212 AttrSets[
Index] = AttrSets[
Index].removeAttribute(C, Kind);
1219 if (!hasAttribute(Index, Kind))
return *
this;
1225 AttrSets[
Index] = AttrSets[
Index].removeAttribute(C, Kind);
1238 if (Index >= AttrSets.
size())
1239 AttrSets.
resize(Index + 1);
1241 AttrSets[
Index] = AttrSets[
Index].removeAttributes(C, AttrsToRemove);
1247 unsigned WithoutIndex)
const {
1251 if (WithoutIndex >= getNumAttrSets())
1260 uint64_t Bytes)
const {
1263 return addAttributes(C, Index, B);
1268 uint64_t Bytes)
const {
1271 return addAttributes(C, Index, B);
1276 unsigned ElemSizeArg,
1280 return addAttributes(C, Index, B);
1315 return pImpl && pImpl->hasFnAttribute(Kind);
1324 return hasAttribute(ArgNo + FirstArgIndex, Kind);
1328 unsigned *
Index)
const {
1329 if (!pImpl)
return false;
1331 for (
unsigned I = index_begin(),
E = index_end();
I !=
E; ++
I) {
1332 if (hasAttribute(
I, Attr)) {
1375 std::pair<unsigned, Optional<unsigned>>
1386 if (!pImpl || Index >= getNumAttrSets())
1388 return pImpl->begin()[
Index];
1392 return pImpl ? pImpl->
begin() :
nullptr;
1396 return pImpl ? pImpl->
end() :
nullptr;
1404 return pImpl ? pImpl->NumAttrSets : 0;
1407 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 1411 for (
unsigned i = index_begin(),
e = index_end(); i !=
e; ++i) {
1413 dbgs() <<
" { " << i <<
" => " << getAsString(i) <<
" }\n";
1427 for (
const auto &
A : AS)
1432 for (
const auto &
A : AS)
1438 TargetDepAttrs.clear();
1440 StackAlignment.reset();
1441 DerefBytes = DerefOrNullBytes = 0;
1443 ByValType =
nullptr;
1448 assert(Val != Attribute::Alignment && Val != Attribute::StackAlignment &&
1449 Val != Attribute::Dereferenceable && Val != Attribute::AllocSize &&
1450 "Adding integer attribute without adding a value!");
1464 if (Kind == Attribute::Alignment)
1466 else if (Kind == Attribute::StackAlignment)
1468 else if (Kind == Attribute::ByVal)
1470 else if (Kind == Attribute::Dereferenceable)
1472 else if (Kind == Attribute::DereferenceableOrNull)
1474 else if (Kind == Attribute::AllocSize)
1480 TargetDepAttrs[
A] = V;
1488 if (Val == Attribute::Alignment)
1490 else if (Val == Attribute::StackAlignment)
1491 StackAlignment.reset();
1492 else if (Val == Attribute::ByVal)
1493 ByValType =
nullptr;
1494 else if (Val == Attribute::Dereferenceable)
1496 else if (Val == Attribute::DereferenceableOrNull)
1497 DerefOrNullBytes = 0;
1498 else if (Val == Attribute::AllocSize)
1510 auto I = TargetDepAttrs.find(A);
1511 if (
I != TargetDepAttrs.end())
1512 TargetDepAttrs.erase(
I);
1524 assert(*Align <= 0x40000000 &&
"Alignment too large.");
1526 Attrs[Attribute::Alignment] =
true;
1536 assert(*Align <= 0x100 &&
"Alignment too large.");
1538 Attrs[Attribute::StackAlignment] =
true;
1539 StackAlignment =
Align;
1544 if (Bytes == 0)
return *
this;
1546 Attrs[Attribute::Dereferenceable] =
true;
1555 Attrs[Attribute::DereferenceableOrNull] =
true;
1556 DerefOrNullBytes = Bytes;
1567 assert(RawArgs &&
"Invalid allocsize arguments -- given allocsize(0, 0)");
1569 Attrs[Attribute::AllocSize] =
true;
1572 AllocSizeArgs = RawArgs;
1577 Attrs[Attribute::ByVal] =
true;
1585 Alignment = B.Alignment;
1587 if (!StackAlignment)
1588 StackAlignment = B.StackAlignment;
1591 DerefBytes = B.DerefBytes;
1593 if (!DerefOrNullBytes)
1594 DerefOrNullBytes = B.DerefOrNullBytes;
1597 AllocSizeArgs = B.AllocSizeArgs;
1600 ByValType = B.ByValType;
1605 TargetDepAttrs[
I.first] =
I.second;
1615 if (B.StackAlignment)
1616 StackAlignment.reset();
1621 if (B.DerefOrNullBytes)
1622 DerefOrNullBytes = 0;
1624 if (B.AllocSizeArgs)
1628 ByValType =
nullptr;
1633 TargetDepAttrs.erase(
I.first);
1640 if ((Attrs & B.Attrs).any())
1644 for (
const auto &
I : td_attrs())
1652 return TargetDepAttrs.find(A) != TargetDepAttrs.end();
1656 return !Attrs.none() || !TargetDepAttrs.
empty();
1662 for (
const auto Attr : AS) {
1663 if (Attr.isEnumAttribute() || Attr.isIntAttribute()) {
1664 if (
contains(Attr.getKindAsEnum()))
1667 assert(Attr.isStringAttribute() &&
"Invalid attribute kind!");
1668 return contains(Attr.getKindAsString());
1676 return Alignment != 0;
1680 if (Attrs != B.Attrs)
1684 E = TargetDepAttrs.end();
I !=
E; ++
I)
1685 if (B.TargetDepAttrs.find(
I->first) == B.TargetDepAttrs.end())
1688 return Alignment == B.Alignment && StackAlignment == B.StackAlignment &&
1689 DerefBytes == B.DerefBytes && ByValType == B.ByValType;
1719 return Incompatible;
1722 template<
typename AttrClass>
1733 template<
typename AttrClass>
1735 if (AttrClass::isSet(Caller, AttrClass::getKind()) &&
1736 !AttrClass::isSet(Callee, AttrClass::getKind()))
1737 AttrClass::set(Caller, AttrClass::getKind(),
false);
1745 template<
typename AttrClass>
1747 if (!AttrClass::isSet(Caller, AttrClass::getKind()) &&
1748 AttrClass::isSet(Callee, AttrClass::getKind()))
1749 AttrClass::set(Caller, AttrClass::getKind(),
true);
1765 Caller.
addFnAttr(Attribute::StackProtectReq);
1766 }
else if (Callee.
hasFnAttribute(Attribute::StackProtectStrong) &&
1769 Caller.
addFnAttr(Attribute::StackProtectStrong);
1773 Caller.
addFnAttr(Attribute::StackProtect);
1791 uint64_t CalleeStackProbeSize;
1796 uint64_t CallerStackProbeSize;
1800 if (CallerStackProbeSize > CalleeStackProbeSize) {
1822 uint64_t CallerVectorWidth;
1826 uint64_t CalleeVectorWidth;
1830 if (CallerVectorWidth < CalleeVectorWidth)
1849 #define GET_ATTR_COMPAT_FUNC 1850 #include "AttributesCompatFunc.inc" 1854 return hasCompatibleFnAttrs(Caller, Callee);
1859 mergeFnAttrs(Caller, Callee);
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs() const
Retrieve the allocsize args, if the allocsize attribute exists.
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
const_iterator end(StringRef path)
Get end iterator over path.
MaybeAlign getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
reference emplace_back(ArgTypes &&... Args)
MaybeAlign getStackAlignment(unsigned Index) const
Get the stack alignment.
static constexpr unsigned attrIdxToArrayIdx(unsigned Index)
Map from AttributeList index to the internal array index.
StringRef getKindAsString() const
Return the attribute's kind as a string.
bool hasAttribute(Attribute::AttrKind A) const
MaybeAlign getAlignment() const
Retrieve the alignment attribute, if it exists.
ArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs() const
const T & back() const
back - Get the last element.
FoldingSet< AttributeImpl > AttrsSet
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
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...
static std::pair< unsigned, Optional< unsigned > > unpackAllocSizeArgs(uint64_t Num)
This class represents lattice values for constants.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
uint64_t getDereferenceableOrNullBytes() const
Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute...
static Attribute getWithDereferenceableBytes(LLVMContext &Context, uint64_t Bytes)
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
MaybeAlign getAlignment() const
void push_back(const T &Elt)
constexpr T getValueOr(U &&value) const LLVM_LVALUE_FUNCTION
The two locations do not alias at all.
void printEscapedString(StringRef Name, raw_ostream &Out)
Print each character of the specified string, escaping it if it is not printable or if it is an escap...
Attribute getAttribute(Attribute::AttrKind Kind) const
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
AttrBuilder & addDereferenceableAttr(uint64_t Bytes)
This turns the number of dereferenceable bytes into the form used internally in Attribute.
static AttributeSetNode * get(LLVMContext &C, const AttrBuilder &B)
AttributeListImpl(LLVMContext &C, ArrayRef< AttributeSet > Sets)
Type * getByValType() const
Retrieve the byval type.
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
std::string getAsString(bool InAttrGrp) const
void reserve(size_type N)
MaybeAlign getAlignment() const
Returns the alignment field of an attribute as a byte alignment value.
uint64_t getDereferenceableBytes() const
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
return AArch64::GPR64RegClass contains(Reg)
void Profile(FoldingSetNodeID &ID) const
bool areInlineCompatible(const Function &Caller, const Function &Callee)
bool operator<(Attribute A) const
Less-than operator. Useful for sorting the attributes list.
uint64_t getDereferenceableOrNullBytes() const
Retrieve the number of dereferenceable_or_null bytes, if the dereferenceable_or_null attribute exists...
Type * getValueAsType() const
uint64_t getDereferenceableOrNullBytes() const
bool hasAttributes() const
Return true if the builder has IR-level attributes.
bool hasAlignmentAttr() const
Return true if the builder has an alignment attribute.
uint64_t getValueAsInt() const
Return the attribute's value as an integer.
AttrBuilder & addDereferenceableOrNullAttr(uint64_t Bytes)
This turns the number of dereferenceable_or_null bytes into the form used internally in Attribute...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
uint64_t getDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown).
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
static Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
bool isIntegerTy() const
True if this is an instance of IntegerType.
static Attribute getWithDereferenceableOrNullBytes(LLVMContext &Context, uint64_t Bytes)
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 isIntAttribute() const
AttrBuilder & addAllocSizeAttr(unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
This turns one (or two) ints into the form used internally in Attribute.
This file contains the simple types necessary to represent the attributes associated with functions a...
No attributes have been set.
AttributeSet getRetAttributes() const
The attributes for the ret value are returned.
void AddInteger(signed I)
AttrBuilder & addByValAttr(Type *Ty)
This turns a byval type into the form used internally in Attribute.
bool hasAttributes(unsigned Index) const
Return true if attribute exists at the given index.
static Attribute getWithStackAlignment(LLVMContext &Context, Align Alignment)
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
LLVMContext & getContext() const
Retrieve the LLVM context.
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
Type * getByValType() const
LLVM_NODISCARD AttributeList removeAttributes(LLVMContext &C, unsigned Index, const AttrBuilder &AttrsToRemove) const
Remove the specified attributes at the specified index from this attribute list.
AttributeSet getParamAttributes(unsigned ArgNo) const
The attributes for the argument or parameter at the given index are returned.
Type * getValueAsType() const
Return the attribute's value as a Type.
uint64_t getDereferenceableOrNullBytes(unsigned Index) const
Get the number of dereferenceable_or_null bytes (or zero if unknown).
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs() const
MaybeAlign getStackAlignment() const
Retrieve the stack alignment attribute, if it exists.
AttrBuilder & remove(const AttrBuilder &B)
Remove the attributes from the builder.
LLVM_NODISCARD AttributeSet addAttributes(LLVMContext &C, AttributeSet AS) const
Add attributes to the attribute set.
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs() const
Returns the argument numbers for the allocsize attribute (or pair(0, 0) if not known).
uint64_t value() const
This is a hole in the type system and should not be abused.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
AttrBuilder & addAllocSizeAttrFromRawRepr(uint64_t RawAllocSizeRepr)
Add an allocsize attribute, using the representation returned by Attribute.getIntValue().
uint64_t getDereferenceableBytes() const
Returns the number of dereferenceable bytes from the dereferenceable attribute.
bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
AttributeSet getAttributes(unsigned Index) const
The attributes for the specified index are returned.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
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...
bool operator==(const AttrBuilder &B)
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
MaybeAlign getStackAlignment() const
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
LLVM_NODISCARD AttributeList addDereferenceableOrNullAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable_or_null attribute to the attribute set at the given index.
static AttributeSet get(LLVMContext &C, const AttrBuilder &B)
std::map< std::string, std::string >::const_iterator td_const_iterator
bool isTypeAttribute() const
LLVM_NODISCARD AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
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.
static void adjustCallerStackProbes(Function &Caller, const Function &Callee)
If the inlined function required stack probes, then ensure that the calling function has those too...
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
bool isStringAttribute() const
bool isPointerTy() const
True if this is an instance of PointerType.
LLVM_NODISCARD AttributeSet removeAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute from this set.
LLVM_NODISCARD AttributeList addAllocSizeAttr(LLVMContext &C, unsigned Index, unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
Add the allocsize attribute to the attribute set at the given index.
static const unsigned AllocSizeNumElemsNotPresent
unsigned getNumAttributes() const
Return the number of attributes in this set.
AttrBuilder & addAlignmentAttr(MaybeAlign Align)
This turns an alignment into the form used internally in Attribute.
This file defines various helper methods and classes used by LLVMContextImpl for creating and managin...
Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind).
bool isEnumAttribute() const
Return true if the attribute is an Attribute::AttrKind type.
MaybeAlign getAlignment() const
static Attribute getWithByValType(LLVMContext &Context, Type *Ty)
Attribute::AttrKind getKindAsEnum() const
Attribute getAttribute(Attribute::AttrKind Kind) const
Return the attribute object.
std::string getAsString(unsigned Index, bool InAttrGrp=false) const
Return the attributes at the index as a string.
Sentinal value useful for loops.
static void setAND(Function &Caller, const Function &Callee)
Compute the logical AND of the attributes of the caller and the callee.
bool operator<(const AttributeImpl &AI) const
Used when sorting the attributes.
uint64_t getDereferenceableBytes() const
Retrieve the number of dereferenceable bytes, if the dereferenceable attribute exists (zero is return...
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
uint64_t getDereferenceableBytes() const
StringRef getKindAsString() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This struct is a compact representation of a valid (non-zero power of two) alignment.
LLVMContextImpl *const pImpl
LLVM_NODISCARD AttributeSet addAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add an argument attribute.
void sort(IteratorTy Start, IteratorTy End)
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
static void adjustCallerSSPLevel(Function &Caller, const Function &Callee)
If the inlined function had a higher stack protection level than the calling function, then bump up the caller's stack protection level.
std::string getAsString(bool InAttrGrp=false) const
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
Equivalent to hasAttribute(ArgNo + FirstArgIndex, Kind).
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
Align max(MaybeAlign Lhs, Align Rhs)
bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
AttrBuilder & removeAttribute(Attribute::AttrKind Val)
Remove an attribute from the builder.
AttrBuilder & removeAttributes(AttributeList A, uint64_t WithoutIndex)
Remove the attributes from the builder.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs(unsigned Index) const
Get the allocsize argument numbers (or pair(0, 0) if unknown).
MaybeAlign getRetAlignment() const
Return the alignment of the return value.
bool overlaps(const AttrBuilder &B) const
Return true if the builder has any attribute that's in the specified builder.
MaybeAlign getStackAlignment() const
Returns the stack alignment field of an attribute as a byte alignment value.
bool isTypeAttribute() const
Return true if the attribute is a type attribute.
AttrBuilder & addStackAlignmentAttr(MaybeAlign Align)
This turns a stack alignment into the form used internally in Attribute.
std::string utostr(uint64_t X, bool isNeg=false)
static void adjustNullPointerValidAttr(Function &Caller, const Function &Callee)
If the inlined function has "null-pointer-is-valid=true" attribute, set this attribute in the caller ...
static void setOR(Function &Caller, const Function &Callee)
Compute the logical OR of the attributes of the caller and the callee.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void mergeAttributesForInlining(Function &Caller, const Function &Callee)
Merge caller's and callee's attributes.
unsigned getNumAttrSets() const
amdgpu Simplify well known AMD library false FunctionCallee Callee
bool isEnumAttribute() const
iterator insert(iterator I, T &&Elt)
uint64_t getDereferenceableOrNullBytes() const
bool isIntAttribute() const
Return true if the attribute is an integer attribute.
bool hasAttribute(Attribute::AttrKind Kind) const
void removeAttributes(unsigned i, const AttrBuilder &Attrs)
removes the attributes from the list of attributes.
MaybeAlign getStackAlignment() const
LLVM_NODISCARD AttributeList addAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
LLVM_NODISCARD AttributeList addDereferenceableAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
StringRef getValueAsString() const
Return the attribute's value as a string.
LLVM_NODISCARD AttributeList removeAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified index from this attribute list.
static Attribute getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
friend class AttributeList
void AddString(StringRef String)
uint64_t getValueAsInt() const
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
StringRef getValueAsString() const
Type * getByValType() const
void removeFnAttr(Attribute::AttrKind Kind)
Remove function attributes from this function.
LLVM_NODISCARD AttributeSet removeAttributes(LLVMContext &C, const AttrBuilder &AttrsToRemove) const
Remove the specified attributes from this set.
LLVM_NODISCARD AttributeList addAttributes(LLVMContext &C, unsigned Index, const AttrBuilder &B) const
Add attributes to the attribute set at the given index.
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...
std::string getAsString(bool InAttrGrp=false) const
The Attribute is converted to a string of equivalent mnemonic.
AttrBuilder & merge(const AttrBuilder &B)
Add the attributes from the builder.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Equivalent to hasAttribute(AttributeList::FunctionIndex, Kind) but may be faster. ...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool hasAttributes() const
Return true if attributes exists in this set.
A raw_ostream that writes to an std::string.
LLVM Value Representation.
AttrBuilder typeIncompatible(Type *Ty)
Which attributes cannot be applied to a type.
AttributeSet getFnAttributes() const
The function attributes are returned.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
FoldingSet< AttributeSetNode > AttrsSetNodes
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
StringRef - Represent a constant reference to a string, i.e.
static uint64_t packAllocSizeArgs(unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
bool nullPointerIsDefined() const
Check if null pointer dereferencing is considered undefined behavior for the function.
static LazyValueInfoImpl & getImpl(void *&PImpl, AssumptionCache *AC, const DataLayout *DL, DominatorTree *DT=nullptr)
This lazily constructs the LazyValueInfoImpl.
OutputIt copy(R &&Range, OutputIt Out)
Type * getParamByValType(unsigned ArgNo) const
Return the byval type for the specified function parameter.
static AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute >> Attrs)
Create an AttributeList with the specified parameters in it.
bool empty() const
empty - Check if the array is empty.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...