27 #include "llvm/Config/llvm-config.h" 64 "Attempting to pack a reserved value");
66 return uint64_t(ElemSizeArg) << 32 |
67 NumElemsArg.
getValueOr(AllocSizeNumElemsNotPresent);
70 static std::pair<unsigned, Optional<unsigned>>
73 unsigned ElemSizeArg = Num >> 32;
76 if (NumElems != AllocSizeNumElemsNotPresent)
77 NumElemsArg = NumElems;
78 return std::make_pair(ElemSizeArg, NumElemsArg);
98 pImpl->
AttrsSet.InsertNode(PA, InsertPoint);
118 pImpl->
AttrsSet.InsertNode(PA, InsertPoint);
127 assert(Align <= 0x40000000 &&
"Alignment too large.");
134 assert(Align <= 0x100 &&
"Alignment too large.");
140 assert(Bytes &&
"Bytes must be non-zero.");
141 return get(
Context, Dereferenceable, Bytes);
146 assert(Bytes &&
"Bytes must be non-zero.");
147 return get(
Context, DereferenceableOrNull, Bytes);
153 assert(!(ElemSizeArg == 0 && NumElemsArg && *NumElemsArg == 0) &&
154 "Invalid allocsize arguments -- given allocsize(0, 0)");
175 if (!pImpl)
return None;
177 "Invalid attribute type to get the kind as an enum!");
182 if (!pImpl)
return 0;
184 "Expected the attribute to be an integer attribute!");
189 if (!pImpl)
return {};
191 "Invalid attribute type to get the kind as a string!");
196 if (!pImpl)
return {};
198 "Invalid attribute type to get the value as a string!");
213 "Trying to get alignment from non-alignment attribute!");
219 "Trying to get alignment from non-alignment attribute!");
225 "Trying to get dereferenceable bytes from " 226 "non-dereferenceable attribute!");
232 "Trying to get dereferenceable bytes from " 233 "non-dereferenceable attribute!");
239 "Trying to get allocsize args from non-allocsize attribute");
244 if (!pImpl)
return {};
247 return "sanitize_address";
249 return "sanitize_hwaddress";
251 return "alwaysinline";
265 return "inaccessiblememonly";
266 if (
hasAttribute(Attribute::InaccessibleMemOrArgMemOnly))
267 return "inaccessiblemem_or_argmemonly";
289 return "noduplicate";
291 return "noimplicitfloat";
295 return "nonlazybind";
309 return "optforfuzzing";
323 return "returns_twice";
327 return "speculatable";
337 return "shadowcallstack";
343 return "sanitize_thread";
345 return "sanitize_memory";
361 Result += (InAttrGrp) ?
"=" :
" ";
366 auto AttrWithBytesToString = [&](
const char *
Name) {
381 return AttrWithBytesToString(
"alignstack");
384 return AttrWithBytesToString(
"dereferenceable");
387 return AttrWithBytesToString(
"dereferenceable_or_null");
394 std::string
Result =
"allocsize(";
395 Result +=
utostr(ElemSize);
398 Result +=
utostr(*NumElems);
414 if (AttrVal.empty())
return Result;
432 if (!pImpl && !A.pImpl)
return false;
433 if (!pImpl)
return true;
434 if (!A.pImpl)
return false;
435 return *pImpl < *A.pImpl;
445 void EnumAttributeImpl::anchor() {}
447 void IntAttributeImpl::anchor() {}
449 void StringAttributeImpl::anchor() {}
536 if (!hasAttributes())
543 for (
const auto I : *
this)
573 return SetNode ? SetNode->getNumAttributes() : 0;
577 return SetNode ? SetNode->hasAttribute(Kind) :
false;
581 return SetNode ? SetNode->hasAttribute(Kind) :
false;
585 return SetNode ? SetNode->getAttribute(Kind) :
Attribute();
589 return SetNode ? SetNode->getAttribute(Kind) :
Attribute();
593 return SetNode ? SetNode->getAlignment() : 0;
597 return SetNode ? SetNode->getStackAlignment() : 0;
601 return SetNode ? SetNode->getDereferenceableBytes() : 0;
605 return SetNode ? SetNode->getDereferenceableOrNullBytes() : 0;
609 return SetNode ? SetNode->getAllocSizeArgs()
610 : std::pair<unsigned, Optional<unsigned>>(0, 0);
614 return SetNode ? SetNode->getAsString(InAttrGrp) :
"";
618 return SetNode ? SetNode->begin() :
nullptr;
622 return SetNode ? SetNode->end() :
nullptr;
625 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 638 : AvailableAttrs(0), NumAttrs(Attrs.
size()) {
642 for (
const auto I : *
this) {
643 if (!
I.isStringAttribute()) {
644 AvailableAttrs |= ((uint64_t)1) <<
I.getKindAsEnum();
659 llvm::sort(SortedAttrs.begin(), SortedAttrs.end());
661 for (
const auto Attr : SortedAttrs)
672 void *Mem = ::operator
new(totalSizeToAlloc<Attribute>(SortedAttrs.size()));
691 case Attribute::Alignment:
694 case Attribute::StackAlignment:
697 case Attribute::Dereferenceable:
701 case Attribute::DereferenceableOrNull:
705 case Attribute::AllocSize: {
717 for (
const auto &TDA : B.
td_attrs())
724 for (
const auto I : *
this)
725 if (
I.hasAttribute(Kind))
732 for (
const auto I : *
this)
733 if (
I.hasAttribute(Kind))
740 for (
const auto I : *
this)
741 if (
I.hasAttribute(Kind))
747 for (
const auto I : *
this)
748 if (
I.hasAttribute(Attribute::Alignment))
749 return I.getAlignment();
754 for (
const auto I : *
this)
755 if (
I.hasAttribute(Attribute::StackAlignment))
756 return I.getStackAlignment();
761 for (
const auto I : *
this)
762 if (
I.hasAttribute(Attribute::Dereferenceable))
763 return I.getDereferenceableBytes();
768 for (
const auto I : *
this)
769 if (
I.hasAttribute(Attribute::DereferenceableOrNull))
770 return I.getDereferenceableOrNullBytes();
774 std::pair<unsigned, Optional<unsigned>>
776 for (
const auto I : *
this)
777 if (
I.hasAttribute(Attribute::AllocSize))
778 return I.getAllocSizeArgs();
779 return std::make_pair(0, 0);
787 Str +=
I->getAsString(InAttrGrp);
806 : AvailableFunctionAttrs(0),
Context(C), NumAttrSets(Sets.
size()) {
807 assert(!Sets.
empty() &&
"pointless AttributeListImpl");
814 sizeof(AvailableFunctionAttrs) * CHAR_BIT,
815 "Too many attributes");
817 "function should be stored in slot 0");
818 for (
const auto I : Sets[0]) {
819 if (!
I.isStringAttribute())
820 AvailableFunctionAttrs |= 1ULL <<
I.getKindAsEnum();
830 for (
const auto &Set : Sets)
834 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 846 assert(!AttrSets.
empty() &&
"pointless AttributeListImpl");
854 pImpl->AttrsLists.FindNodeOrInsertPos(ID, InsertPoint);
860 void *Mem = ::operator
new(
861 AttributeListImpl::totalSizeToAlloc<AttributeSet>(AttrSets.
size()));
863 pImpl->AttrsLists.InsertNode(PA, InsertPoint);
872 ArrayRef<std::pair<unsigned, Attribute>> Attrs) {
878 [](
const std::pair<unsigned, Attribute> &LHS,
879 const std::pair<unsigned, Attribute> &RHS) {
880 return LHS.first < RHS.first;
881 }) &&
"Misordered Attributes list!");
883 [](
const std::pair<unsigned, Attribute> &Pair) {
886 "Pointless attribute!");
892 E = Attrs.
end();
I !=
E; ) {
893 unsigned Index =
I->first;
895 while (
I !=
E &&
I->first == Index) {
903 return get(
C, AttrPairVec);
908 ArrayRef<std::pair<unsigned, AttributeSet>> Attrs) {
914 [](
const std::pair<unsigned, AttributeSet> &LHS,
915 const std::pair<unsigned, AttributeSet> &RHS) {
916 return LHS.first < RHS.first;
918 "Misordered Attributes list!");
920 [](
const std::pair<unsigned, AttributeSet> &Pair) {
921 return !Pair.second.hasAttributes();
923 "Pointless attribute!");
925 unsigned MaxIndex = Attrs.
back().first;
928 if (MaxIndex == FunctionIndex && Attrs.
size() > 1)
929 MaxIndex = Attrs[Attrs.
size() - 2].first;
932 for (
const auto Pair : Attrs)
944 unsigned NumSets = 0;
945 for (
size_t I = ArgAttrs.
size();
I != 0; --
I) {
946 if (ArgAttrs[
I - 1].hasAttributes()) {
992 for (
const auto K : Kinds)
1000 for (
const auto K : Kinds)
1009 if (Attrs.
size() == 1)
1012 unsigned MaxSize = 0;
1013 for (
const auto List : Attrs)
1021 for (
unsigned I = 0;
I < MaxSize; ++
I) {
1023 for (
const auto List : Attrs)
1028 return getImpl(C, NewAttrSets);
1033 if (hasAttribute(Index, Kind))
return *
this;
1036 return addAttributes(C, Index, B);
1044 return addAttributes(C, Index, B);
1051 return addAttributes(C, Index, B);
1067 assert((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
1068 "Attempt to change alignment!");
1073 if (Index >= AttrSets.
size())
1074 AttrSets.
resize(Index + 1);
1090 if (MaxIndex >= AttrSets.
size())
1091 AttrSets.
resize(MaxIndex + 1);
1093 for (
unsigned ArgNo : ArgNos) {
1105 if (!hasAttribute(Index, Kind))
return *
this;
1111 AttrSets[
Index] = AttrSets[
Index].removeAttribute(C, Kind);
1118 if (!hasAttribute(Index, Kind))
return *
this;
1124 AttrSets[
Index] = AttrSets[
Index].removeAttribute(C, Kind);
1137 if (Index >= AttrSets.
size())
1138 AttrSets.
resize(Index + 1);
1140 AttrSets[
Index] = AttrSets[
Index].removeAttributes(C, AttrsToRemove);
1146 unsigned WithoutIndex)
const {
1150 if (WithoutIndex >= getNumAttrSets())
1159 uint64_t Bytes)
const {
1162 return addAttributes(C, Index, B);
1167 uint64_t Bytes)
const {
1170 return addAttributes(C, Index, B);
1175 unsigned ElemSizeArg,
1179 return addAttributes(C, Index, B);
1214 return pImpl && pImpl->hasFnAttribute(Kind);
1223 return hasAttribute(ArgNo + FirstArgIndex, Kind);
1227 unsigned *
Index)
const {
1228 if (!pImpl)
return false;
1230 for (
unsigned I = index_begin(),
E = index_end();
I !=
E; ++
I) {
1231 if (hasAttribute(
I, Attr)) {
1270 std::pair<unsigned, Optional<unsigned>>
1281 if (!pImpl || Index >= getNumAttrSets())
1283 return pImpl->begin()[
Index];
1287 return pImpl ? pImpl->
begin() :
nullptr;
1291 return pImpl ? pImpl->
end() :
nullptr;
1299 return pImpl ? pImpl->NumAttrSets : 0;
1302 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 1306 for (
unsigned i = index_begin(), e = index_end(); i != e; ++i) {
1308 dbgs() <<
" { " << i <<
" => " << getAsString(i) <<
" }\n";
1322 for (
const auto &
A : AS)
1327 for (
const auto &
A : AS)
1333 TargetDepAttrs.clear();
1334 Alignment = StackAlignment = DerefBytes = DerefOrNullBytes = 0;
1340 assert(Val != Attribute::Alignment && Val != Attribute::StackAlignment &&
1341 Val != Attribute::Dereferenceable && Val != Attribute::AllocSize &&
1342 "Adding integer attribute without adding a value!");
1356 if (Kind == Attribute::Alignment)
1358 else if (Kind == Attribute::StackAlignment)
1360 else if (Kind == Attribute::Dereferenceable)
1362 else if (Kind == Attribute::DereferenceableOrNull)
1364 else if (Kind == Attribute::AllocSize)
1370 TargetDepAttrs[
A] = V;
1378 if (Val == Attribute::Alignment)
1380 else if (Val == Attribute::StackAlignment)
1382 else if (Val == Attribute::Dereferenceable)
1384 else if (Val == Attribute::DereferenceableOrNull)
1385 DerefOrNullBytes = 0;
1386 else if (Val == Attribute::AllocSize)
1398 auto I = TargetDepAttrs.find(A);
1399 if (
I != TargetDepAttrs.end())
1400 TargetDepAttrs.erase(
I);
1409 if (Align == 0)
return *
this;
1412 assert(Align <= 0x40000000 &&
"Alignment too large.");
1414 Attrs[Attribute::Alignment] =
true;
1421 if (Align == 0)
return *
this;
1424 assert(Align <= 0x100 &&
"Alignment too large.");
1426 Attrs[Attribute::StackAlignment] =
true;
1427 StackAlignment =
Align;
1432 if (Bytes == 0)
return *
this;
1434 Attrs[Attribute::Dereferenceable] =
true;
1443 Attrs[Attribute::DereferenceableOrNull] =
true;
1444 DerefOrNullBytes = Bytes;
1455 assert(RawArgs &&
"Invalid allocsize arguments -- given allocsize(0, 0)");
1457 Attrs[Attribute::AllocSize] =
true;
1460 AllocSizeArgs = RawArgs;
1467 Alignment = B.Alignment;
1469 if (!StackAlignment)
1470 StackAlignment = B.StackAlignment;
1473 DerefBytes = B.DerefBytes;
1475 if (!DerefOrNullBytes)
1476 DerefOrNullBytes = B.DerefOrNullBytes;
1479 AllocSizeArgs = B.AllocSizeArgs;
1484 TargetDepAttrs[
I.first] =
I.second;
1494 if (B.StackAlignment)
1500 if (B.DerefOrNullBytes)
1501 DerefOrNullBytes = 0;
1503 if (B.AllocSizeArgs)
1509 TargetDepAttrs.erase(
I.first);
1516 if ((Attrs & B.Attrs).any())
1520 for (
const auto &
I : td_attrs())
1528 return TargetDepAttrs.find(A) != TargetDepAttrs.end();
1532 return !Attrs.none() || !TargetDepAttrs.
empty();
1538 for (
const auto Attr : AS) {
1539 if (Attr.isEnumAttribute() || Attr.isIntAttribute()) {
1540 if (
contains(Attr.getKindAsEnum()))
1543 assert(Attr.isStringAttribute() &&
"Invalid attribute kind!");
1544 return contains(Attr.getKindAsString());
1552 return Alignment != 0;
1556 if (Attrs != B.Attrs)
1560 E = TargetDepAttrs.end();
I !=
E; ++
I)
1561 if (B.TargetDepAttrs.find(
I->first) == B.TargetDepAttrs.end())
1564 return Alignment == B.Alignment && StackAlignment == B.StackAlignment &&
1565 DerefBytes == B.DerefBytes;
1595 return Incompatible;
1598 template<
typename AttrClass>
1609 template<
typename AttrClass>
1611 if (AttrClass::isSet(Caller, AttrClass::getKind()) &&
1612 !AttrClass::isSet(Callee, AttrClass::getKind()))
1613 AttrClass::set(Caller, AttrClass::getKind(),
false);
1621 template<
typename AttrClass>
1623 if (!AttrClass::isSet(Caller, AttrClass::getKind()) &&
1624 AttrClass::isSet(Callee, AttrClass::getKind()))
1625 AttrClass::set(Caller, AttrClass::getKind(),
true);
1641 Caller.
addFnAttr(Attribute::StackProtectReq);
1642 }
else if (Callee.
hasFnAttribute(Attribute::StackProtectStrong) &&
1645 Caller.
addFnAttr(Attribute::StackProtectStrong);
1649 Caller.
addFnAttr(Attribute::StackProtect);
1667 uint64_t CalleeStackProbeSize;
1672 uint64_t CallerStackProbeSize;
1676 if (CallerStackProbeSize > CalleeStackProbeSize) {
1694 uint64_t CalleeVectorWidth;
1699 uint64_t CallerVectorWidth;
1703 if (CallerVectorWidth < CalleeVectorWidth) {
1721 #define GET_ATTR_COMPAT_FUNC 1722 #include "AttributesCompatFunc.inc" 1726 return hasCompatibleFnAttrs(Caller, Callee);
1731 mergeFnAttrs(Caller, Callee);
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs() const
Retrieve the allocsize args, if the allocsize attribute exists.
unsigned getStackAlignment() const
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
void push_back(const T &Elt)
const_iterator end(StringRef path)
Get end iterator over path.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
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
ArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
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)
Compute iterated dominance frontiers using a linear time algorithm.
uint64_t getDereferenceableOrNullBytes() const
Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute...
unsigned getStackAlignment() const
Returns the stack alignment field of an attribute as a byte alignment value.
static Attribute getWithAlignment(LLVMContext &Context, uint64_t Align)
Return a uniquified Attribute object that has the specific alignment set.
static Attribute getWithDereferenceableBytes(LLVMContext &Context, uint64_t Bytes)
unsigned getAlignment() const
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)
unsigned getRetAlignment() const
Return the alignment of the return value.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
std::string getAsString(bool InAttrGrp) const
void reserve(size_type N)
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...
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.
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
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)
bool hasAttributes(unsigned Index) const
Return true if attribute exists at the given index.
LLVMContext & getContext() const
Retrieve the LLVM context.
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
unsigned getStackAlignment() const
uint64_t getStackAlignment() const
Retrieve the stack alignment attribute, if it exists.
static bool isEqual(const Function &Caller, const Function &Callee)
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.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
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
AttrBuilder & remove(const AttrBuilder &B)
Remove the attributes from the builder.
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).
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.
amdgpu Simplify well known AMD library false Value * Callee
bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
static Attribute getWithStackAlignment(LLVMContext &Context, uint64_t Align)
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...
unsigned getStackAlignment(unsigned Index) const
Get the stack alignment.
bool operator==(const AttrBuilder &B)
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
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
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
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.
AttributeSet removeAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute from this set.
uint64_t getAlignment() const
Retrieve the alignment attribute, if it exists.
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.
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.
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.
LLVMContextImpl *const pImpl
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.
bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
unsigned getAlignment() const
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).
bool overlaps(const AttrBuilder &B) const
Return true if the builder has any attribute that's in the specified builder.
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
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.
unsigned getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
AttributeList addAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
unsigned getAlignment() const
Returns the alignment field of an attribute as a byte alignment value.
AttributeList addDereferenceableAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
void emplace_back(ArgTypes &&... Args)
StringRef getValueAsString() const
Return the attribute's value as a string.
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
AttributeSet removeAttributes(LLVMContext &C, const AttrBuilder &AttrsToRemove) const
Remove the specified attributes from this set.
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.
AttrBuilder & addStackAlignmentAttr(unsigned Align)
This turns an int stack alignment (which must be a power of 2) into the form used internally in Attri...
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
FoldingSet< AttributeSetNode > AttrsSetNodes
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
StringRef - Represent a constant reference to a string, i.e.
AttrBuilder & addAlignmentAttr(unsigned Align)
This turns an int alignment (which must be a power of 2) into the form used internally in Attribute...
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)
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...