LLVM 20.0.0git
Attributes.h
Go to the documentation of this file.
1//===- llvm/Attributes.h - Container for Attributes -------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// \file
10/// This file contains the simple types necessary to represent the
11/// attributes associated with functions and their calls.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_IR_ATTRIBUTES_H
16#define LLVM_IR_ATTRIBUTES_H
17
18#include "llvm-c/Types.h"
19#include "llvm/ADT/ArrayRef.h"
21#include "llvm/ADT/StringRef.h"
22#include "llvm/Config/llvm-config.h"
25#include "llvm/Support/ModRef.h"
27#include <cassert>
28#include <cstdint>
29#include <optional>
30#include <string>
31#include <utility>
32
33namespace llvm {
34
35class AttrBuilder;
36class AttributeMask;
37class AttributeImpl;
38class AttributeListImpl;
39class AttributeSetNode;
40class ConstantRange;
41class ConstantRangeList;
42class FoldingSetNodeID;
43class Function;
44class LLVMContext;
45class Type;
46class raw_ostream;
48
49enum class AllocFnKind : uint64_t {
50 Unknown = 0,
51 Alloc = 1 << 0, // Allocator function returns a new allocation
52 Realloc = 1 << 1, // Allocator function resizes the `allocptr` argument
53 Free = 1 << 2, // Allocator function frees the `allocptr` argument
54 Uninitialized = 1 << 3, // Allocator function returns uninitialized memory
55 Zeroed = 1 << 4, // Allocator function returns zeroed memory
56 Aligned = 1 << 5, // Allocator function aligns allocations per the
57 // `allocalign` argument
58 LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ Aligned)
59};
60
61//===----------------------------------------------------------------------===//
62/// \class
63/// Functions, function parameters, and return types can have attributes
64/// to indicate how they should be treated by optimizations and code
65/// generation. This class represents one of those attributes. It's light-weight
66/// and should be passed around by-value.
67class Attribute {
68public:
69 /// This enumeration lists the attributes that can be associated with
70 /// parameters, function results, or the function itself.
71 ///
72 /// Note: The `uwtable' attribute is about the ABI or the user mandating an
73 /// entry in the unwind table. The `nounwind' attribute is about an exception
74 /// passing by the function.
75 ///
76 /// In a theoretical system that uses tables for profiling and SjLj for
77 /// exceptions, they would be fully independent. In a normal system that uses
78 /// tables for both, the semantics are:
79 ///
80 /// nil = Needs an entry because an exception might pass by.
81 /// nounwind = No need for an entry
82 /// uwtable = Needs an entry because the ABI says so and because
83 /// an exception might pass by.
84 /// uwtable + nounwind = Needs an entry because the ABI says so.
85
86 enum AttrKind {
87 // IR-Level Attributes
88 None, ///< No attributes have been set
89 #define GET_ATTR_ENUM
90 #include "llvm/IR/Attributes.inc"
91 EndAttrKinds, ///< Sentinel value useful for loops
92 EmptyKey, ///< Use as Empty key for DenseMap of AttrKind
93 TombstoneKey, ///< Use as Tombstone key for DenseMap of AttrKind
94 };
95
96 static const unsigned NumIntAttrKinds = LastIntAttr - FirstIntAttr + 1;
97 static const unsigned NumTypeAttrKinds = LastTypeAttr - FirstTypeAttr + 1;
98
99 static bool isEnumAttrKind(AttrKind Kind) {
100 return Kind >= FirstEnumAttr && Kind <= LastEnumAttr;
101 }
102 static bool isIntAttrKind(AttrKind Kind) {
103 return Kind >= FirstIntAttr && Kind <= LastIntAttr;
104 }
105 static bool isTypeAttrKind(AttrKind Kind) {
106 return Kind >= FirstTypeAttr && Kind <= LastTypeAttr;
107 }
109 return Kind >= FirstConstantRangeAttr && Kind <= LastConstantRangeAttr;
110 }
112 return Kind >= FirstConstantRangeListAttr &&
113 Kind <= LastConstantRangeListAttr;
114 }
115
116 static bool canUseAsFnAttr(AttrKind Kind);
117 static bool canUseAsParamAttr(AttrKind Kind);
118 static bool canUseAsRetAttr(AttrKind Kind);
119
120 static bool intersectMustPreserve(AttrKind Kind);
121 static bool intersectWithAnd(AttrKind Kind);
122 static bool intersectWithMin(AttrKind Kind);
123 static bool intersectWithCustom(AttrKind Kind);
124
125private:
126 AttributeImpl *pImpl = nullptr;
127
128 Attribute(AttributeImpl *A) : pImpl(A) {}
129
130public:
131 Attribute() = default;
132
133 //===--------------------------------------------------------------------===//
134 // Attribute Construction
135 //===--------------------------------------------------------------------===//
136
137 /// Return a uniquified Attribute object.
138 static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val = 0);
139 static Attribute get(LLVMContext &Context, StringRef Kind,
140 StringRef Val = StringRef());
141 static Attribute get(LLVMContext &Context, AttrKind Kind, Type *Ty);
142 static Attribute get(LLVMContext &Context, AttrKind Kind,
143 const ConstantRange &CR);
144 static Attribute get(LLVMContext &Context, AttrKind Kind,
146
147 /// Return a uniquified Attribute object that has the specific
148 /// alignment set.
149 static Attribute getWithAlignment(LLVMContext &Context, Align Alignment);
150 static Attribute getWithStackAlignment(LLVMContext &Context, Align Alignment);
152 uint64_t Bytes);
154 uint64_t Bytes);
156 LLVMContext &Context, unsigned ElemSizeArg,
157 const std::optional<unsigned> &NumElemsArg);
159 unsigned MinValue, unsigned MaxValue);
160 static Attribute getWithByValType(LLVMContext &Context, Type *Ty);
161 static Attribute getWithStructRetType(LLVMContext &Context, Type *Ty);
162 static Attribute getWithByRefType(LLVMContext &Context, Type *Ty);
164 static Attribute getWithInAllocaType(LLVMContext &Context, Type *Ty);
167 static Attribute getWithNoFPClass(LLVMContext &Context, FPClassTest Mask);
168
169 /// For a typed attribute, return the equivalent attribute with the type
170 /// changed to \p ReplacementTy.
171 Attribute getWithNewType(LLVMContext &Context, Type *ReplacementTy) {
172 assert(isTypeAttribute() && "this requires a typed attribute");
173 return get(Context, getKindAsEnum(), ReplacementTy);
174 }
175
177
179
180 /// Return true if the provided string matches the IR name of an attribute.
181 /// example: "noalias" return true but not "NoAlias"
183
184 //===--------------------------------------------------------------------===//
185 // Attribute Accessors
186 //===--------------------------------------------------------------------===//
187
188 /// Return true if the attribute is an Attribute::AttrKind type.
189 bool isEnumAttribute() const;
190
191 /// Return true if the attribute is an integer attribute.
192 bool isIntAttribute() const;
193
194 /// Return true if the attribute is a string (target-dependent)
195 /// attribute.
196 bool isStringAttribute() const;
197
198 /// Return true if the attribute is a type attribute.
199 bool isTypeAttribute() const;
200
201 /// Return true if the attribute is a ConstantRange attribute.
202 bool isConstantRangeAttribute() const;
203
204 /// Return true if the attribute is a ConstantRangeList attribute.
205 bool isConstantRangeListAttribute() const;
206
207 /// Return true if the attribute is any kind of attribute.
208 bool isValid() const { return pImpl; }
209
210 /// Return true if the attribute is present.
211 bool hasAttribute(AttrKind Val) const;
212
213 /// Return true if the target-dependent attribute is present.
214 bool hasAttribute(StringRef Val) const;
215
216 /// Returns true if the attribute's kind can be represented as an enum (Enum,
217 /// Integer, Type, ConstantRange, or ConstantRangeList attribute).
218 bool hasKindAsEnum() const { return !isStringAttribute(); }
219
220 /// Return the attribute's kind as an enum (Attribute::AttrKind). This
221 /// requires the attribute be representable as an enum (see: `hasKindAsEnum`).
223
224 /// Return the attribute's value as an integer. This requires that the
225 /// attribute be an integer attribute.
226 uint64_t getValueAsInt() const;
227
228 /// Return the attribute's value as a boolean. This requires that the
229 /// attribute be a string attribute.
230 bool getValueAsBool() const;
231
232 /// Return the attribute's kind as a string. This requires the
233 /// attribute to be a string attribute.
235
236 /// Return the attribute's value as a string. This requires the
237 /// attribute to be a string attribute.
239
240 /// Return the attribute's value as a Type. This requires the attribute to be
241 /// a type attribute.
242 Type *getValueAsType() const;
243
244 /// Return the attribute's value as a ConstantRange. This requires the
245 /// attribute to be a ConstantRange attribute.
247
248 /// Return the attribute's value as a ConstantRange array. This requires the
249 /// attribute to be a ConstantRangeList attribute.
251
252 /// Returns the alignment field of an attribute as a byte alignment
253 /// value.
254 MaybeAlign getAlignment() const;
255
256 /// Returns the stack alignment field of an attribute as a byte
257 /// alignment value.
259
260 /// Returns the number of dereferenceable bytes from the
261 /// dereferenceable attribute.
263
264 /// Returns the number of dereferenceable_or_null bytes from the
265 /// dereferenceable_or_null attribute.
267
268 /// Returns the argument numbers for the allocsize attribute.
269 std::pair<unsigned, std::optional<unsigned>> getAllocSizeArgs() const;
270
271 /// Returns the minimum value for the vscale_range attribute.
272 unsigned getVScaleRangeMin() const;
273
274 /// Returns the maximum value for the vscale_range attribute or std::nullopt
275 /// when unknown.
276 std::optional<unsigned> getVScaleRangeMax() const;
277
278 // Returns the unwind table kind.
280
281 // Returns the allocator function kind.
283
284 /// Returns memory effects.
286
287 /// Returns information from captures attribute.
289
290 /// Return the FPClassTest for nofpclass
292
293 /// Returns the value of the range attribute.
294 const ConstantRange &getRange() const;
295
296 /// Returns the value of the initializes attribute.
298
299 /// The Attribute is converted to a string of equivalent mnemonic. This
300 /// is, presumably, for writing out the mnemonics for the assembly writer.
301 std::string getAsString(bool InAttrGrp = false) const;
302
303 /// Return true if this attribute belongs to the LLVMContext.
304 bool hasParentContext(LLVMContext &C) const;
305
306 /// Equality and non-equality operators.
307 bool operator==(Attribute A) const { return pImpl == A.pImpl; }
308 bool operator!=(Attribute A) const { return pImpl != A.pImpl; }
309
310 /// Used to sort attribute by kind.
311 int cmpKind(Attribute A) const;
312
313 /// Less-than operator. Useful for sorting the attributes list.
314 bool operator<(Attribute A) const;
315
316 void Profile(FoldingSetNodeID &ID) const;
317
318 /// Return a raw pointer that uniquely identifies this attribute.
319 void *getRawPointer() const {
320 return pImpl;
321 }
322
323 /// Get an attribute from a raw pointer created by getRawPointer.
324 static Attribute fromRawPointer(void *RawPtr) {
325 return Attribute(reinterpret_cast<AttributeImpl*>(RawPtr));
326 }
327};
328
329// Specialized opaque value conversions.
331 return reinterpret_cast<LLVMAttributeRef>(Attr.getRawPointer());
332}
333
334// Specialized opaque value conversions.
336 return Attribute::fromRawPointer(Attr);
337}
338
339//===----------------------------------------------------------------------===//
340/// \class
341/// This class holds the attributes for a particular argument, parameter,
342/// function, or return value. It is an immutable value type that is cheap to
343/// copy. Adding and removing enum attributes is intended to be fast, but adding
344/// and removing string or integer attributes involves a FoldingSet lookup.
346 friend AttributeListImpl;
347 template <typename Ty, typename Enable> friend struct DenseMapInfo;
348
349 // TODO: Extract AvailableAttrs from AttributeSetNode and store them here.
350 // This will allow an efficient implementation of addAttribute and
351 // removeAttribute for enum attrs.
352
353 /// Private implementation pointer.
354 AttributeSetNode *SetNode = nullptr;
355
356private:
357 explicit AttributeSet(AttributeSetNode *ASN) : SetNode(ASN) {}
358
359public:
360 /// AttributeSet is a trivially copyable value type.
361 AttributeSet() = default;
362 AttributeSet(const AttributeSet &) = default;
363 ~AttributeSet() = default;
364
365 static AttributeSet get(LLVMContext &C, const AttrBuilder &B);
367
368 bool operator==(const AttributeSet &O) const { return SetNode == O.SetNode; }
369 bool operator!=(const AttributeSet &O) const { return !(*this == O); }
370
371 /// Add an argument attribute. Returns a new set because attribute sets are
372 /// immutable.
373 [[nodiscard]] AttributeSet addAttribute(LLVMContext &C,
374 Attribute::AttrKind Kind) const;
375
376 /// Add a target-dependent attribute. Returns a new set because attribute sets
377 /// are immutable.
378 [[nodiscard]] AttributeSet addAttribute(LLVMContext &C, StringRef Kind,
379 StringRef Value = StringRef()) const;
380
381 /// Add attributes to the attribute set. Returns a new set because attribute
382 /// sets are immutable.
384 AttributeSet AS) const;
385
386 /// Remove the specified attribute from this set. Returns a new set because
387 /// attribute sets are immutable.
389 Attribute::AttrKind Kind) const;
390
391 /// Remove the specified attribute from this set. Returns a new set because
392 /// attribute sets are immutable.
394 StringRef Kind) const;
395
396 /// Remove the specified attributes from this set. Returns a new set because
397 /// attribute sets are immutable.
398 [[nodiscard]] AttributeSet
399 removeAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const;
400
401 /// Try to intersect this AttributeSet with Other. Returns std::nullopt if
402 /// the two lists are inherently incompatible (imply different behavior, not
403 /// just analysis).
404 [[nodiscard]] std::optional<AttributeSet>
406
407 /// Return the number of attributes in this set.
408 unsigned getNumAttributes() const;
409
410 /// Return true if attributes exists in this set.
411 bool hasAttributes() const { return SetNode != nullptr; }
412
413 /// Return true if the attribute exists in this set.
414 bool hasAttribute(Attribute::AttrKind Kind) const;
415
416 /// Return true if the attribute exists in this set.
417 bool hasAttribute(StringRef Kind) const;
418
419 /// Return the attribute object.
421
422 /// Return the target-dependent attribute object.
423 Attribute getAttribute(StringRef Kind) const;
424
425 MaybeAlign getAlignment() const;
429 Type *getByValType() const;
430 Type *getStructRetType() const;
431 Type *getByRefType() const;
432 Type *getPreallocatedType() const;
433 Type *getInAllocaType() const;
434 Type *getElementType() const;
435 std::optional<std::pair<unsigned, std::optional<unsigned>>> getAllocSizeArgs()
436 const;
437 unsigned getVScaleRangeMin() const;
438 std::optional<unsigned> getVScaleRangeMax() const;
444 std::string getAsString(bool InAttrGrp = false) const;
445
446 /// Return true if this attribute set belongs to the LLVMContext.
447 bool hasParentContext(LLVMContext &C) const;
448
449 using iterator = const Attribute *;
450
451 iterator begin() const;
452 iterator end() const;
453#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
454 void dump() const;
455#endif
456};
457
458//===----------------------------------------------------------------------===//
459/// \class
460/// Provide DenseMapInfo for AttributeSet.
461template <> struct DenseMapInfo<AttributeSet, void> {
463 auto Val = static_cast<uintptr_t>(-1);
464 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
465 return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
466 }
467
469 auto Val = static_cast<uintptr_t>(-2);
470 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
471 return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
472 }
473
474 static unsigned getHashValue(AttributeSet AS) {
475 return (unsigned((uintptr_t)AS.SetNode) >> 4) ^
476 (unsigned((uintptr_t)AS.SetNode) >> 9);
477 }
478
479 static bool isEqual(AttributeSet LHS, AttributeSet RHS) { return LHS == RHS; }
480};
481
482//===----------------------------------------------------------------------===//
483/// \class
484/// This class holds the attributes for a function, its return value, and
485/// its parameters. You access the attributes for each of them via an index into
486/// the AttributeList object. The function attributes are at index
487/// `AttributeList::FunctionIndex', the return value is at index
488/// `AttributeList::ReturnIndex', and the attributes for the parameters start at
489/// index `AttributeList::FirstArgIndex'.
491public:
492 enum AttrIndex : unsigned {
496 };
497
498private:
499 friend class AttrBuilder;
500 friend class AttributeListImpl;
501 friend class AttributeSet;
502 friend class AttributeSetNode;
503 template <typename Ty, typename Enable> friend struct DenseMapInfo;
504
505 /// The attributes that we are managing. This can be null to represent
506 /// the empty attributes list.
507 AttributeListImpl *pImpl = nullptr;
508
509public:
510 /// Create an AttributeList with the specified parameters in it.
512 ArrayRef<std::pair<unsigned, Attribute>> Attrs);
514 ArrayRef<std::pair<unsigned, AttributeSet>> Attrs);
515
516 /// Create an AttributeList from attribute sets for a function, its
517 /// return value, and all of its arguments.
518 static AttributeList get(LLVMContext &C, AttributeSet FnAttrs,
519 AttributeSet RetAttrs,
520 ArrayRef<AttributeSet> ArgAttrs);
521
522private:
523 explicit AttributeList(AttributeListImpl *LI) : pImpl(LI) {}
524
525 static AttributeList getImpl(LLVMContext &C, ArrayRef<AttributeSet> AttrSets);
526
527 AttributeList setAttributesAtIndex(LLVMContext &C, unsigned Index,
528 AttributeSet Attrs) const;
529
530public:
531 AttributeList() = default;
532
533 //===--------------------------------------------------------------------===//
534 // AttributeList Construction and Mutation
535 //===--------------------------------------------------------------------===//
536
537 /// Return an AttributeList with the specified parameters in it.
539 static AttributeList get(LLVMContext &C, unsigned Index,
541 static AttributeList get(LLVMContext &C, unsigned Index,
543 ArrayRef<uint64_t> Values);
544 static AttributeList get(LLVMContext &C, unsigned Index,
546 static AttributeList get(LLVMContext &C, unsigned Index,
547 AttributeSet Attrs);
548 static AttributeList get(LLVMContext &C, unsigned Index,
549 const AttrBuilder &B);
550
551 // TODO: remove non-AtIndex versions of these methods.
552 /// Add an attribute to the attribute set at the given index.
553 /// Returns a new list because attribute lists are immutable.
554 [[nodiscard]] AttributeList
556 Attribute::AttrKind Kind) const;
557
558 /// Add an attribute to the attribute set at the given index.
559 /// Returns a new list because attribute lists are immutable.
560 [[nodiscard]] AttributeList
562 StringRef Value = StringRef()) const;
563
564 /// Add an attribute to the attribute set at the given index.
565 /// Returns a new list because attribute lists are immutable.
566 [[nodiscard]] AttributeList
568
569 /// Add attributes to the attribute set at the given index.
570 /// Returns a new list because attribute lists are immutable.
572 unsigned Index,
573 const AttrBuilder &B) const;
574
575 /// Add a function attribute to the list. Returns a new list because
576 /// attribute lists are immutable.
578 Attribute::AttrKind Kind) const {
579 return addAttributeAtIndex(C, FunctionIndex, Kind);
580 }
581
582 /// Add a function attribute to the list. Returns a new list because
583 /// attribute lists are immutable.
585 Attribute Attr) const {
586 return addAttributeAtIndex(C, FunctionIndex, Attr);
587 }
588
589 /// Add a function attribute to the list. Returns a new list because
590 /// attribute lists are immutable.
591 [[nodiscard]] AttributeList
593 StringRef Value = StringRef()) const {
595 }
596
597 /// Add function attribute to the list. Returns a new list because
598 /// attribute lists are immutable.
600 const AttrBuilder &B) const {
602 }
603
604 /// Add a return value attribute to the list. Returns a new list because
605 /// attribute lists are immutable.
607 Attribute::AttrKind Kind) const {
608 return addAttributeAtIndex(C, ReturnIndex, Kind);
609 }
610
611 /// Add a return value attribute to the list. Returns a new list because
612 /// attribute lists are immutable.
614 Attribute Attr) const {
615 return addAttributeAtIndex(C, ReturnIndex, Attr);
616 }
617
618 /// Add a return value attribute to the list. Returns a new list because
619 /// attribute lists are immutable.
621 const AttrBuilder &B) const {
623 }
624
625 /// Add an argument attribute to the list. Returns a new list because
626 /// attribute lists are immutable.
627 [[nodiscard]] AttributeList
629 Attribute::AttrKind Kind) const {
630 return addAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
631 }
632
633 /// Add an argument attribute to the list. Returns a new list because
634 /// attribute lists are immutable.
635 [[nodiscard]] AttributeList
636 addParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind,
637 StringRef Value = StringRef()) const {
638 return addAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind, Value);
639 }
640
641 /// Add an attribute to the attribute list at the given arg indices. Returns a
642 /// new list because attribute lists are immutable.
644 ArrayRef<unsigned> ArgNos,
645 Attribute A) const;
646
647 /// Add an argument attribute to the list. Returns a new list because
648 /// attribute lists are immutable.
649 [[nodiscard]] AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo,
650 const AttrBuilder &B) const {
651 return addAttributesAtIndex(C, ArgNo + FirstArgIndex, B);
652 }
653
654 /// Remove the specified attribute at the specified index from this
655 /// attribute list. Returns a new list because attribute lists are immutable.
656 [[nodiscard]] AttributeList
658 Attribute::AttrKind Kind) const;
659
660 /// Remove the specified attribute at the specified index from this
661 /// attribute list. Returns a new list because attribute lists are immutable.
662 [[nodiscard]] AttributeList
663 removeAttributeAtIndex(LLVMContext &C, unsigned Index, StringRef Kind) const;
665 StringRef Kind) const {
666 return removeAttributeAtIndex(C, Index, Kind);
667 }
668
669 /// Remove the specified attributes at the specified index from this
670 /// attribute list. Returns a new list because attribute lists are immutable.
671 [[nodiscard]] AttributeList
673 const AttributeMask &AttrsToRemove) const;
674
675 /// Remove all attributes at the specified index from this
676 /// attribute list. Returns a new list because attribute lists are immutable.
678 unsigned Index) const;
679
680 /// Remove the specified attribute at the function index from this
681 /// attribute list. Returns a new list because attribute lists are immutable.
682 [[nodiscard]] AttributeList
685 }
686
687 /// Remove the specified attribute at the function index from this
688 /// attribute list. Returns a new list because attribute lists are immutable.
690 StringRef Kind) const {
692 }
693
694 /// Remove the specified attribute at the function index from this
695 /// attribute list. Returns a new list because attribute lists are immutable.
696 [[nodiscard]] AttributeList
697 removeFnAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const {
698 return removeAttributesAtIndex(C, FunctionIndex, AttrsToRemove);
699 }
700
701 /// Remove the attributes at the function index from this
702 /// attribute list. Returns a new list because attribute lists are immutable.
705 }
706
707 /// Remove the specified attribute at the return value index from this
708 /// attribute list. Returns a new list because attribute lists are immutable.
709 [[nodiscard]] AttributeList
711 return removeAttributeAtIndex(C, ReturnIndex, Kind);
712 }
713
714 /// Remove the specified attribute at the return value index from this
715 /// attribute list. Returns a new list because attribute lists are immutable.
717 StringRef Kind) const {
718 return removeAttributeAtIndex(C, ReturnIndex, Kind);
719 }
720
721 /// Remove the specified attribute at the return value index from this
722 /// attribute list. Returns a new list because attribute lists are immutable.
723 [[nodiscard]] AttributeList
725 const AttributeMask &AttrsToRemove) const {
726 return removeAttributesAtIndex(C, ReturnIndex, AttrsToRemove);
727 }
728
729 /// Remove the specified attribute at the specified arg index from this
730 /// attribute list. Returns a new list because attribute lists are immutable.
731 [[nodiscard]] AttributeList
733 Attribute::AttrKind Kind) const {
734 return removeAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
735 }
736
737 /// Remove the specified attribute at the specified arg index from this
738 /// attribute list. Returns a new list because attribute lists are immutable.
739 [[nodiscard]] AttributeList
740 removeParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind) const {
741 return removeAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
742 }
743
744 /// Remove the specified attribute at the specified arg index from this
745 /// attribute list. Returns a new list because attribute lists are immutable.
746 [[nodiscard]] AttributeList
748 const AttributeMask &AttrsToRemove) const {
749 return removeAttributesAtIndex(C, ArgNo + FirstArgIndex, AttrsToRemove);
750 }
751
752 /// Remove all attributes at the specified arg index from this
753 /// attribute list. Returns a new list because attribute lists are immutable.
755 unsigned ArgNo) const {
756 return removeAttributesAtIndex(C, ArgNo + FirstArgIndex);
757 }
758
759 /// Replace the type contained by attribute \p AttrKind at index \p ArgNo wih
760 /// \p ReplacementTy, preserving all other attributes.
761 [[nodiscard]] AttributeList
764 Type *ReplacementTy) const {
765 Attribute Attr = getAttributeAtIndex(ArgNo, Kind);
766 auto Attrs = removeAttributeAtIndex(C, ArgNo, Kind);
767 return Attrs.addAttributeAtIndex(C, ArgNo,
768 Attr.getWithNewType(C, ReplacementTy));
769 }
770
771 /// \brief Add the dereferenceable attribute to the attribute set at the given
772 /// index. Returns a new list because attribute lists are immutable.
774 uint64_t Bytes) const;
775
776 /// \brief Add the dereferenceable attribute to the attribute set at the given
777 /// arg index. Returns a new list because attribute lists are immutable.
779 unsigned ArgNo,
780 uint64_t Bytes) const;
781
782 /// Add the dereferenceable_or_null attribute to the attribute set at
783 /// the given arg index. Returns a new list because attribute lists are
784 /// immutable.
785 [[nodiscard]] AttributeList
787 uint64_t Bytes) const;
788
789 /// Add the range attribute to the attribute set at the return value index.
790 /// Returns a new list because attribute lists are immutable.
792 const ConstantRange &CR) const;
793
794 /// Add the allocsize attribute to the attribute set at the given arg index.
795 /// Returns a new list because attribute lists are immutable.
796 [[nodiscard]] AttributeList
797 addAllocSizeParamAttr(LLVMContext &C, unsigned ArgNo, unsigned ElemSizeArg,
798 const std::optional<unsigned> &NumElemsArg) const;
799
800 /// Try to intersect this AttributeList with Other. Returns std::nullopt if
801 /// the two lists are inherently incompatible (imply different behavior, not
802 /// just analysis).
803 [[nodiscard]] std::optional<AttributeList>
805
806 //===--------------------------------------------------------------------===//
807 // AttributeList Accessors
808 //===--------------------------------------------------------------------===//
809
810 /// The attributes for the specified index are returned.
811 AttributeSet getAttributes(unsigned Index) const;
812
813 /// The attributes for the argument or parameter at the given index are
814 /// returned.
815 AttributeSet getParamAttrs(unsigned ArgNo) const;
816
817 /// The attributes for the ret value are returned.
819
820 /// The function attributes are returned.
821 AttributeSet getFnAttrs() const;
822
823 /// Return true if the attribute exists at the given index.
824 bool hasAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const;
825
826 /// Return true if the attribute exists at the given index.
827 bool hasAttributeAtIndex(unsigned Index, StringRef Kind) const;
828
829 /// Return true if attribute exists at the given index.
830 bool hasAttributesAtIndex(unsigned Index) const;
831
832 /// Return true if the attribute exists for the given argument
833 bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
834 return hasAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
835 }
836
837 /// Return true if the attribute exists for the given argument
838 bool hasParamAttr(unsigned ArgNo, StringRef Kind) const {
839 return hasAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
840 }
841
842 /// Return true if attributes exists for the given argument
843 bool hasParamAttrs(unsigned ArgNo) const {
844 return hasAttributesAtIndex(ArgNo + FirstArgIndex);
845 }
846
847 /// Return true if the attribute exists for the return value.
849 return hasAttributeAtIndex(ReturnIndex, Kind);
850 }
851
852 /// Return true if the attribute exists for the return value.
853 bool hasRetAttr(StringRef Kind) const {
854 return hasAttributeAtIndex(ReturnIndex, Kind);
855 }
856
857 /// Return true if attributes exist for the return value.
859
860 /// Return true if the attribute exists for the function.
861 bool hasFnAttr(Attribute::AttrKind Kind) const;
862
863 /// Return true if the attribute exists for the function.
864 bool hasFnAttr(StringRef Kind) const;
865
866 /// Return true the attributes exist for the function.
868
869 /// Return true if the specified attribute is set for at least one
870 /// parameter or for the return value. If Index is not nullptr, the index
871 /// of a parameter with the specified attribute is provided.
873 unsigned *Index = nullptr) const;
874
875 /// Return the attribute object that exists at the given index.
877
878 /// Return the attribute object that exists at the given index.
879 Attribute getAttributeAtIndex(unsigned Index, StringRef Kind) const;
880
881 /// Return the attribute object that exists at the arg index.
882 Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
883 return getAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
884 }
885
886 /// Return the attribute object that exists at the given index.
887 Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const {
888 return getAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
889 }
890
891 /// Return the attribute object that exists for the function.
894 }
895
896 /// Return the attribute object that exists for the function.
899 }
900
901 /// Return the attribute for the given attribute kind for the return value.
903 return getAttributeAtIndex(ReturnIndex, Kind);
904 }
905
906 /// Return the alignment of the return value.
908
909 /// Return the alignment for the specified function parameter.
910 MaybeAlign getParamAlignment(unsigned ArgNo) const;
911
912 /// Return the stack alignment for the specified function parameter.
913 MaybeAlign getParamStackAlignment(unsigned ArgNo) const;
914
915 /// Return the byval type for the specified function parameter.
916 Type *getParamByValType(unsigned ArgNo) const;
917
918 /// Return the sret type for the specified function parameter.
919 Type *getParamStructRetType(unsigned ArgNo) const;
920
921 /// Return the byref type for the specified function parameter.
922 Type *getParamByRefType(unsigned ArgNo) const;
923
924 /// Return the preallocated type for the specified function parameter.
925 Type *getParamPreallocatedType(unsigned ArgNo) const;
926
927 /// Return the inalloca type for the specified function parameter.
928 Type *getParamInAllocaType(unsigned ArgNo) const;
929
930 /// Return the elementtype type for the specified function parameter.
931 Type *getParamElementType(unsigned ArgNo) const;
932
933 /// Get the stack alignment of the function.
935
936 /// Get the stack alignment of the return value.
938
939 /// Get the number of dereferenceable bytes (or zero if unknown) of the return
940 /// value.
942
943 /// Get the number of dereferenceable bytes (or zero if unknown) of an arg.
945
946 /// Get the number of dereferenceable_or_null bytes (or zero if unknown) of
947 /// the return value.
949
950 /// Get the number of dereferenceable_or_null bytes (or zero if unknown) of an
951 /// arg.
952 uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const;
953
954 /// Get range (or std::nullopt if unknown) of an arg.
955 std::optional<ConstantRange> getParamRange(unsigned ArgNo) const;
956
957 /// Get the disallowed floating-point classes of the return value.
959
960 /// Get the disallowed floating-point classes of the argument value.
961 FPClassTest getParamNoFPClass(unsigned ArgNo) const;
962
963 /// Get the unwind table kind requested for the function.
965
967
968 /// Returns memory effects of the function.
970
971 /// Return the attributes at the index as a string.
972 std::string getAsString(unsigned Index, bool InAttrGrp = false) const;
973
974 /// Return true if this attribute list belongs to the LLVMContext.
975 bool hasParentContext(LLVMContext &C) const;
976
977 //===--------------------------------------------------------------------===//
978 // AttributeList Introspection
979 //===--------------------------------------------------------------------===//
980
981 using iterator = const AttributeSet *;
982
983 iterator begin() const;
984 iterator end() const;
985
986 unsigned getNumAttrSets() const;
987
988 // Implementation of indexes(). Produces iterators that wrap an index. Mostly
989 // to hide the awkwardness of unsigned wrapping when iterating over valid
990 // indexes.
992 unsigned NumAttrSets;
994 struct int_wrapper {
995 int_wrapper(unsigned i) : i(i) {}
996 unsigned i;
997 unsigned operator*() { return i; }
998 bool operator!=(const int_wrapper &Other) { return i != Other.i; }
1000 // This is expected to undergo unsigned wrapping since FunctionIndex is
1001 // ~0 and that's where we start.
1002 ++i;
1003 return *this;
1004 }
1005 };
1006
1008
1010 };
1011
1012 /// Use this to iterate over the valid attribute indexes.
1014
1015 /// operator==/!= - Provide equality predicates.
1016 bool operator==(const AttributeList &RHS) const { return pImpl == RHS.pImpl; }
1017 bool operator!=(const AttributeList &RHS) const { return pImpl != RHS.pImpl; }
1018
1019 /// Return a raw pointer that uniquely identifies this attribute list.
1020 void *getRawPointer() const {
1021 return pImpl;
1022 }
1023
1024 /// Return true if there are no attributes.
1025 bool isEmpty() const { return pImpl == nullptr; }
1026
1027 void print(raw_ostream &O) const;
1028
1029 void dump() const;
1030};
1031
1032//===----------------------------------------------------------------------===//
1033/// \class
1034/// Provide DenseMapInfo for AttributeList.
1035template <> struct DenseMapInfo<AttributeList, void> {
1037 auto Val = static_cast<uintptr_t>(-1);
1038 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
1039 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
1040 }
1041
1043 auto Val = static_cast<uintptr_t>(-2);
1044 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
1045 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
1046 }
1047
1048 static unsigned getHashValue(AttributeList AS) {
1049 return (unsigned((uintptr_t)AS.pImpl) >> 4) ^
1050 (unsigned((uintptr_t)AS.pImpl) >> 9);
1051 }
1052
1054 return LHS == RHS;
1055 }
1056};
1057
1058//===----------------------------------------------------------------------===//
1059/// \class
1060/// This class is used in conjunction with the Attribute::get method to
1061/// create an Attribute object. The object itself is uniquified. The Builder's
1062/// value, however, is not. So this can be used as a quick way to test for
1063/// equality, presence of attributes, etc.
1065 LLVMContext &Ctx;
1067
1068public:
1069 AttrBuilder(LLVMContext &Ctx) : Ctx(Ctx) {}
1070 AttrBuilder(const AttrBuilder &) = delete;
1072
1073 AttrBuilder(LLVMContext &Ctx, const Attribute &A) : Ctx(Ctx) {
1074 addAttribute(A);
1075 }
1076
1078
1079 void clear();
1080
1081 /// Add an attribute to the builder.
1083
1084 /// Add the Attribute object to the builder.
1086
1087 /// Add the target-dependent attribute to the builder.
1089
1090 /// Remove an attribute from the builder.
1092
1093 /// Remove the target-dependent attribute from the builder.
1095
1096 /// Remove the target-dependent attribute from the builder.
1098 if (A.isStringAttribute())
1099 return removeAttribute(A.getKindAsString());
1100 else
1101 return removeAttribute(A.getKindAsEnum());
1102 }
1103
1104 /// Add the attributes from the builder. Attributes in the passed builder
1105 /// overwrite attributes in this builder if they have the same key.
1106 AttrBuilder &merge(const AttrBuilder &B);
1107
1108 /// Remove the attributes from the builder.
1109 AttrBuilder &remove(const AttributeMask &AM);
1110
1111 /// Return true if the builder has any attribute that's in the
1112 /// specified builder.
1113 bool overlaps(const AttributeMask &AM) const;
1114
1115 /// Return true if the builder has the specified attribute.
1116 bool contains(Attribute::AttrKind A) const;
1117
1118 /// Return true if the builder has the specified target-dependent
1119 /// attribute.
1120 bool contains(StringRef A) const;
1121
1122 /// Return true if the builder has IR-level attributes.
1123 bool hasAttributes() const { return !Attrs.empty(); }
1124
1125 /// Return Attribute with the given Kind. The returned attribute will be
1126 /// invalid if the Kind is not present in the builder.
1128
1129 /// Return Attribute with the given Kind. The returned attribute will be
1130 /// invalid if the Kind is not present in the builder.
1131 Attribute getAttribute(StringRef Kind) const;
1132
1133 /// Retrieve the range if the attribute exists (std::nullopt is returned
1134 /// otherwise).
1135 std::optional<ConstantRange> getRange() const;
1136
1137 /// Return raw (possibly packed/encoded) value of integer attribute or
1138 /// std::nullopt if not set.
1139 std::optional<uint64_t> getRawIntAttr(Attribute::AttrKind Kind) const;
1140
1141 /// Retrieve the alignment attribute, if it exists.
1143 return MaybeAlign(getRawIntAttr(Attribute::Alignment).value_or(0));
1144 }
1145
1146 /// Retrieve the stack alignment attribute, if it exists.
1148 return MaybeAlign(getRawIntAttr(Attribute::StackAlignment).value_or(0));
1149 }
1150
1151 /// Retrieve the number of dereferenceable bytes, if the
1152 /// dereferenceable attribute exists (zero is returned otherwise).
1154 return getRawIntAttr(Attribute::Dereferenceable).value_or(0);
1155 }
1156
1157 /// Retrieve the number of dereferenceable_or_null bytes, if the
1158 /// dereferenceable_or_null attribute exists (zero is returned otherwise).
1160 return getRawIntAttr(Attribute::DereferenceableOrNull).value_or(0);
1161 }
1162
1163 /// Retrieve type for the given type attribute.
1165
1166 /// Retrieve the byval type.
1167 Type *getByValType() const { return getTypeAttr(Attribute::ByVal); }
1168
1169 /// Retrieve the sret type.
1170 Type *getStructRetType() const { return getTypeAttr(Attribute::StructRet); }
1171
1172 /// Retrieve the byref type.
1173 Type *getByRefType() const { return getTypeAttr(Attribute::ByRef); }
1174
1175 /// Retrieve the preallocated type.
1177 return getTypeAttr(Attribute::Preallocated);
1178 }
1179
1180 /// Retrieve the inalloca type.
1181 Type *getInAllocaType() const { return getTypeAttr(Attribute::InAlloca); }
1182
1183 /// Retrieve the allocsize args, or std::nullopt if the attribute does not
1184 /// exist.
1185 std::optional<std::pair<unsigned, std::optional<unsigned>>> getAllocSizeArgs()
1186 const;
1187
1188 /// Add integer attribute with raw value (packed/encoded if necessary).
1190
1191 /// This turns an alignment into the form used internally in Attribute.
1192 /// This call has no effect if Align is not set.
1194
1195 /// This turns an int alignment (which must be a power of 2) into the
1196 /// form used internally in Attribute.
1197 /// This call has no effect if Align is 0.
1198 /// Deprecated, use the version using a MaybeAlign.
1201 }
1202
1203 /// This turns a stack alignment into the form used internally in Attribute.
1204 /// This call has no effect if Align is not set.
1206
1207 /// This turns an int stack alignment (which must be a power of 2) into
1208 /// the form used internally in Attribute.
1209 /// This call has no effect if Align is 0.
1210 /// Deprecated, use the version using a MaybeAlign.
1213 }
1214
1215 /// This turns the number of dereferenceable bytes into the form used
1216 /// internally in Attribute.
1218
1219 /// This turns the number of dereferenceable_or_null bytes into the
1220 /// form used internally in Attribute.
1222
1223 /// This turns one (or two) ints into the form used internally in Attribute.
1224 AttrBuilder &addAllocSizeAttr(unsigned ElemSizeArg,
1225 const std::optional<unsigned> &NumElemsArg);
1226
1227 /// This turns two ints into the form used internally in Attribute.
1228 AttrBuilder &addVScaleRangeAttr(unsigned MinValue,
1229 std::optional<unsigned> MaxValue);
1230
1231 /// Add a type attribute with the given type.
1233
1234 /// This turns a byval type into the form used internally in Attribute.
1236
1237 /// This turns a sret type into the form used internally in Attribute.
1239
1240 /// This turns a byref type into the form used internally in Attribute.
1242
1243 /// This turns a preallocated type into the form used internally in Attribute.
1245
1246 /// This turns an inalloca type into the form used internally in Attribute.
1248
1249 /// Add an allocsize attribute, using the representation returned by
1250 /// Attribute.getIntValue().
1252
1253 /// Add a vscale_range attribute, using the representation returned by
1254 /// Attribute.getIntValue().
1256
1257 /// This turns the unwind table kind into the form used internally in
1258 /// Attribute.
1260
1261 // This turns the allocator kind into the form used internally in Attribute.
1263
1264 /// Add memory effect attribute.
1266
1267 /// Add captures attribute.
1269
1270 // Add nofpclass attribute
1272
1273 /// Add a ConstantRange attribute with the given range.
1275 const ConstantRange &CR);
1276
1277 /// Add range attribute.
1279
1280 /// Add a ConstantRangeList attribute with the given ranges.
1283
1284 /// Add initializes attribute.
1286
1287 ArrayRef<Attribute> attrs() const { return Attrs; }
1288
1289 bool operator==(const AttrBuilder &B) const;
1290 bool operator!=(const AttrBuilder &B) const { return !(*this == B); }
1291};
1292
1293namespace AttributeFuncs {
1294
1299};
1300
1301/// Returns true if this is a type legal for the 'nofpclass' attribute. This
1302/// follows the same type rules as FPMathOperator.
1304
1305/// Which attributes cannot be applied to a type. The argument \p AS
1306/// is used as a hint for the attributes whose compatibility is being
1307/// checked against \p Ty. This does not mean the return will be a
1308/// subset of \p AS, just that attributes that have specific dynamic
1309/// type compatibilities (i.e `range`) will be checked against what is
1310/// contained in \p AS. The argument \p ASK indicates, if only
1311/// attributes that are known to be safely droppable are contained in
1312/// the mask; only attributes that might be unsafe to drop (e.g.,
1313/// ABI-related attributes) are in the mask; or both.
1316
1317/// Get param/return attributes which imply immediate undefined behavior if an
1318/// invalid value is passed. For example, this includes noundef (where undef
1319/// implies UB), but not nonnull (where null implies poison). It also does not
1320/// include attributes like nocapture, which constrain the function
1321/// implementation rather than the passed value.
1323
1324/// \returns Return true if the two functions have compatible target-independent
1325/// attributes for inlining purposes.
1326bool areInlineCompatible(const Function &Caller, const Function &Callee);
1327
1328
1329/// Checks if there are any incompatible function attributes between
1330/// \p A and \p B.
1331///
1332/// \param [in] A - The first function to be compared with.
1333/// \param [in] B - The second function to be compared with.
1334/// \returns true if the functions have compatible attributes.
1335bool areOutlineCompatible(const Function &A, const Function &B);
1336
1337/// Merge caller's and callee's attributes.
1338void mergeAttributesForInlining(Function &Caller, const Function &Callee);
1339
1340/// Merges the functions attributes from \p ToMerge into function \p Base.
1341///
1342/// \param [in,out] Base - The function being merged into.
1343/// \param [in] ToMerge - The function to merge attributes from.
1344void mergeAttributesForOutlining(Function &Base, const Function &ToMerge);
1345
1346/// Update min-legal-vector-width if it is in Attribute and less than Width.
1348
1349} // end namespace AttributeFuncs
1350
1351} // end namespace llvm
1352
1353#endif // LLVM_IR_ATTRIBUTES_H
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
RelocType Type
Definition: COFFYAML.cpp:410
std::string Name
uint32_t Index
Load MIR Sample Profile
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Value * RHS
Value * LHS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
AttrBuilder & addStructRetAttr(Type *Ty)
This turns a sret type into the form used internally in Attribute.
AttrBuilder & addAlignmentAttr(MaybeAlign Align)
This turns an alignment into the form used internally in Attribute.
Type * getByValType() const
Retrieve the byval type.
Definition: Attributes.h:1167
AttrBuilder(AttrBuilder &&)=default
AttrBuilder & addVScaleRangeAttrFromRawRepr(uint64_t RawVScaleRangeRepr)
Add a vscale_range attribute, using the representation returned by Attribute.getIntValue().
AttrBuilder(const AttrBuilder &)=delete
std::optional< uint64_t > getRawIntAttr(Attribute::AttrKind Kind) const
Return raw (possibly packed/encoded) value of integer attribute or std::nullopt if not set.
AttrBuilder & addStackAlignmentAttr(unsigned Align)
This turns an int stack alignment (which must be a power of 2) into the form used internally in Attri...
Definition: Attributes.h:1211
AttrBuilder & addAllocKindAttr(AllocFnKind Kind)
Attribute getAttribute(Attribute::AttrKind Kind) const
Return Attribute with the given Kind.
AttrBuilder & addByRefAttr(Type *Ty)
This turns a byref type into the form used internally in Attribute.
AttrBuilder & addNoFPClassAttr(FPClassTest NoFPClassMask)
AttrBuilder & addCapturesAttr(CaptureInfo CI)
Add captures attribute.
bool overlaps(const AttributeMask &AM) const
Return true if the builder has any attribute that's in the specified builder.
AttrBuilder & merge(const AttrBuilder &B)
Add the attributes from the builder.
MaybeAlign getStackAlignment() const
Retrieve the stack alignment attribute, if it exists.
Definition: Attributes.h:1147
Type * getByRefType() const
Retrieve the byref type.
Definition: Attributes.h:1173
AttrBuilder & addVScaleRangeAttr(unsigned MinValue, std::optional< unsigned > MaxValue)
This turns two ints into the form used internally in Attribute.
AttrBuilder(LLVMContext &Ctx)
Definition: Attributes.h:1069
uint64_t getDereferenceableBytes() const
Retrieve the number of dereferenceable bytes, if the dereferenceable attribute exists (zero is return...
Definition: Attributes.h:1153
bool hasAttributes() const
Return true if the builder has IR-level attributes.
Definition: Attributes.h:1123
AttrBuilder & addRawIntAttr(Attribute::AttrKind Kind, uint64_t Value)
Add integer attribute with raw value (packed/encoded if necessary).
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
MaybeAlign getAlignment() const
Retrieve the alignment attribute, if it exists.
Definition: Attributes.h:1142
AttrBuilder & addByValAttr(Type *Ty)
This turns a byval type into the form used internally in Attribute.
AttrBuilder & addDereferenceableAttr(uint64_t Bytes)
This turns the number of dereferenceable bytes into the form used internally in Attribute.
Type * getPreallocatedType() const
Retrieve the preallocated type.
Definition: Attributes.h:1176
AttrBuilder & addInitializesAttr(const ConstantRangeList &CRL)
Add initializes attribute.
bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
AttrBuilder & addMemoryAttr(MemoryEffects ME)
Add memory effect attribute.
AttrBuilder & addConstantRangeListAttr(Attribute::AttrKind Kind, ArrayRef< ConstantRange > Val)
Add a ConstantRangeList attribute with the given ranges.
AttrBuilder & addConstantRangeAttr(Attribute::AttrKind Kind, const ConstantRange &CR)
Add a ConstantRange attribute with the given range.
AttrBuilder & addAllocSizeAttrFromRawRepr(uint64_t RawAllocSizeRepr)
Add an allocsize attribute, using the representation returned by Attribute.getIntValue().
AttrBuilder & addPreallocatedAttr(Type *Ty)
This turns a preallocated type into the form used internally in Attribute.
Type * getInAllocaType() const
Retrieve the inalloca type.
Definition: Attributes.h:1181
AttrBuilder & addStackAlignmentAttr(MaybeAlign Align)
This turns a stack alignment into the form used internally in Attribute.
AttrBuilder & removeAttribute(Attribute A)
Remove the target-dependent attribute from the builder.
Definition: Attributes.h:1097
uint64_t getDereferenceableOrNullBytes() const
Retrieve the number of dereferenceable_or_null bytes, if the dereferenceable_or_null attribute exists...
Definition: Attributes.h:1159
ArrayRef< Attribute > attrs() const
Definition: Attributes.h:1287
AttrBuilder & addInAllocaAttr(Type *Ty)
This turns an inalloca type into the form used internally in Attribute.
AttrBuilder & removeAttribute(Attribute::AttrKind Val)
Remove an attribute from the builder.
Type * getTypeAttr(Attribute::AttrKind Kind) const
Retrieve type for the given type attribute.
AttrBuilder & remove(const AttributeMask &AM)
Remove the attributes from the builder.
std::optional< ConstantRange > getRange() const
Retrieve the range if the attribute exists (std::nullopt is returned otherwise).
AttrBuilder & addDereferenceableOrNullAttr(uint64_t Bytes)
This turns the number of dereferenceable_or_null bytes into the form used internally in Attribute.
AttrBuilder & addAlignmentAttr(unsigned Align)
This turns an int alignment (which must be a power of 2) into the form used internally in Attribute.
Definition: Attributes.h:1199
AttrBuilder & addTypeAttr(Attribute::AttrKind Kind, Type *Ty)
Add a type attribute with the given type.
std::optional< std::pair< unsigned, std::optional< unsigned > > > getAllocSizeArgs() const
Retrieve the allocsize args, or std::nullopt if the attribute does not exist.
AttrBuilder & addAllocSizeAttr(unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg)
This turns one (or two) ints into the form used internally in Attribute.
bool operator!=(const AttrBuilder &B) const
Definition: Attributes.h:1290
Type * getStructRetType() const
Retrieve the sret type.
Definition: Attributes.h:1170
AttrBuilder & addRangeAttr(const ConstantRange &CR)
Add range attribute.
AttrBuilder(LLVMContext &Ctx, const Attribute &A)
Definition: Attributes.h:1073
AttrBuilder & addUWTableAttr(UWTableKind Kind)
This turns the unwind table kind into the form used internally in Attribute.
Attribute getFnAttr(StringRef Kind) const
Return the attribute object that exists for the function.
Definition: Attributes.h:897
bool operator==(const AttributeList &RHS) const
operator==/!= - Provide equality predicates.
Definition: Attributes.h:1016
bool hasAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
Type * getParamStructRetType(unsigned ArgNo) const
Return the sret type for the specified function parameter.
AttributeList addDereferenceableParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given arg index.
AttributeList removeAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified index from this attribute list.
AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo) const
Remove all attributes at the specified arg index from this attribute list.
Definition: Attributes.h:754
AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the specified arg index from this attribute list.
Definition: Attributes.h:747
AttributeList addRangeRetAttr(LLVMContext &C, const ConstantRange &CR) const
Add the range attribute to the attribute set at the return value index.
bool hasAttributesAtIndex(unsigned Index) const
Return true if attribute exists at the given index.
AttributeList removeRetAttribute(LLVMContext &C, StringRef Kind) const
Remove the specified attribute at the return value index from this attribute list.
Definition: Attributes.h:716
bool hasRetAttr(StringRef Kind) const
Return true if the attribute exists for the return value.
Definition: Attributes.h:853
AttributeSet getFnAttrs() const
The function attributes are returned.
index_iterator indexes() const
Use this to iterate over the valid attribute indexes.
Definition: Attributes.h:1013
AttributeList removeAttributesAtIndex(LLVMContext &C, unsigned Index, const AttributeMask &AttrsToRemove) const
Remove the specified attributes at the specified index from this attribute list.
AttributeList()=default
AttributeList addRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a return value attribute to the list.
Definition: Attributes.h:606
iterator begin() const
bool hasParamAttrs(unsigned ArgNo) const
Return true if attributes exists for the given argument.
Definition: Attributes.h:843
MaybeAlign getRetStackAlignment() const
Get the stack alignment of the return value.
AttributeList addRetAttributes(LLVMContext &C, const AttrBuilder &B) const
Add a return value attribute to the list.
Definition: Attributes.h:620
void print(raw_ostream &O) const
AttributeList addDereferenceableRetAttr(LLVMContext &C, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
AttributeList removeRetAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the return value index from this attribute list.
Definition: Attributes.h:724
static AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute > > Attrs)
Create an AttributeList with the specified parameters in it.
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return the attribute object that exists at the arg index.
Definition: Attributes.h:882
AttributeList removeAttribute(LLVMContext &C, unsigned Index, StringRef Kind) const
Definition: Attributes.h:664
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute list.
Definition: Attributes.h:1020
AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind) const
Remove the specified attribute at the specified arg index from this attribute list.
Definition: Attributes.h:740
AllocFnKind getAllocKind() const
bool isEmpty() const
Return true if there are no attributes.
Definition: Attributes.h:1025
AttributeList addFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a function attribute to the list.
Definition: Attributes.h:577
AttributeSet getRetAttrs() const
The attributes for the ret value are returned.
AttributeList addFnAttributes(LLVMContext &C, const AttrBuilder &B) const
Add function attribute to the list.
Definition: Attributes.h:599
bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the function.
uint64_t getParamDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown) of an arg.
MaybeAlign getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
bool hasParamAttr(unsigned ArgNo, StringRef Kind) const
Return true if the attribute exists for the given argument.
Definition: Attributes.h:838
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind, StringRef Value=StringRef()) const
Add an argument attribute to the list.
Definition: Attributes.h:636
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.
iterator end() const
Type * getParamInAllocaType(unsigned ArgNo) const
Return the inalloca type for the specified function parameter.
unsigned getNumAttrSets() const
bool operator!=(const AttributeList &RHS) const
Definition: Attributes.h:1017
FPClassTest getRetNoFPClass() const
Get the disallowed floating-point classes of the return value.
Attribute getFnAttr(Attribute::AttrKind Kind) const
Return the attribute object that exists for the function.
Definition: Attributes.h:892
std::string getAsString(unsigned Index, bool InAttrGrp=false) const
Return the attributes at the index as a string.
UWTableKind getUWTableKind() const
Get the unwind table kind requested for the function.
MaybeAlign getRetAlignment() const
Return the alignment of the return value.
Type * getParamElementType(unsigned ArgNo) const
Return the elementtype type for the specified function parameter.
Attribute getAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
Type * getParamPreallocatedType(unsigned ArgNo) const
Return the preallocated type for the specified function parameter.
bool hasParentContext(LLVMContext &C) const
Return true if this attribute list belongs to the LLVMContext.
AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified arg index from this attribute list.
Definition: Attributes.h:732
AttributeList addFnAttribute(LLVMContext &C, StringRef Kind, StringRef Value=StringRef()) const
Add a function attribute to the list.
Definition: Attributes.h:592
bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return true if the attribute exists for the given argument.
Definition: Attributes.h:833
MaybeAlign getFnStackAlignment() const
Get the stack alignment of the function.
AttributeList addAttributesAtIndex(LLVMContext &C, unsigned Index, const AttrBuilder &B) const
Add attributes to the attribute set at the given index.
Type * getParamByValType(unsigned ArgNo) const
Return the byval type for the specified function parameter.
AttributeList removeFnAttributes(LLVMContext &C) const
Remove the attributes at the function index from this attribute list.
Definition: Attributes.h:703
Attribute getRetAttr(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind for the return value.
Definition: Attributes.h:902
MaybeAlign getParamStackAlignment(unsigned ArgNo) const
Return the stack alignment for the specified function parameter.
uint64_t getRetDereferenceableBytes() const
Get the number of dereferenceable bytes (or zero if unknown) of the return value.
Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const
Return the attribute object that exists at the given index.
Definition: Attributes.h:887
AttributeList addAllocSizeParamAttr(LLVMContext &C, unsigned ArgNo, unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg) const
Add the allocsize attribute to the attribute set at the given arg index.
AttributeList removeFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:683
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of an arg.
bool hasRetAttrs() const
Return true if attributes exist for the return value.
Definition: Attributes.h:858
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.
AttributeSet getAttributes(unsigned Index) const
The attributes for the specified index are returned.
AttributeList addRetAttribute(LLVMContext &C, Attribute Attr) const
Add a return value attribute to the list.
Definition: Attributes.h:613
FPClassTest getParamNoFPClass(unsigned ArgNo) const
Get the disallowed floating-point classes of the argument value.
AttributeList removeFnAttribute(LLVMContext &C, StringRef Kind) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:689
AttributeList removeFnAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:697
std::optional< AttributeList > intersectWith(LLVMContext &C, AttributeList Other) const
Try to intersect this AttributeList with Other.
bool hasFnAttrs() const
Return true the attributes exist for the function.
Definition: Attributes.h:867
Type * getParamByRefType(unsigned ArgNo) const
Return the byref type for the specified function parameter.
AttributeList addAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
AttributeSet getParamAttrs(unsigned ArgNo) const
The attributes for the argument or parameter at the given index are returned.
AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo, const AttrBuilder &B) const
Add an argument attribute to the list.
Definition: Attributes.h:649
std::optional< ConstantRange > getParamRange(unsigned ArgNo) const
Get range (or std::nullopt if unknown) of an arg.
uint64_t getRetDereferenceableOrNullBytes() const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of the return value.
AttributeList removeRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the return value index from this attribute list.
Definition: Attributes.h:710
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
Definition: Attributes.h:628
AttributeList replaceAttributeTypeAtIndex(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind, Type *ReplacementTy) const
Replace the type contained by attribute AttrKind at index ArgNo wih ReplacementTy,...
Definition: Attributes.h:762
AttributeList addFnAttribute(LLVMContext &C, Attribute Attr) const
Add a function attribute to the list.
Definition: Attributes.h:584
MemoryEffects getMemoryEffects() const
Returns memory effects of the function.
bool hasRetAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the return value.
Definition: Attributes.h:848
AllocFnKind getAllocKind() const
bool hasAttributes() const
Return true if attributes exists in this set.
Definition: Attributes.h:411
AttributeSet removeAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute from this set.
Definition: Attributes.cpp:946
Type * getInAllocaType() const
Type * getByValType() const
bool operator!=(const AttributeSet &O) const
Definition: Attributes.h:369
AttributeSet addAttributes(LLVMContext &C, AttributeSet AS) const
Add attributes to the attribute set.
Definition: Attributes.cpp:933
MemoryEffects getMemoryEffects() const
bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
bool operator==(const AttributeSet &O) const
Definition: Attributes.h:368
std::optional< AttributeSet > intersectWith(LLVMContext &C, AttributeSet Other) const
Try to intersect this AttributeSet with Other.
Definition: Attributes.cpp:974
Type * getStructRetType() const
std::string getAsString(bool InAttrGrp=false) const
~AttributeSet()=default
unsigned getVScaleRangeMin() const
std::optional< std::pair< unsigned, std::optional< unsigned > > > getAllocSizeArgs() const
UWTableKind getUWTableKind() const
bool hasParentContext(LLVMContext &C) const
Return true if this attribute set belongs to the LLVMContext.
iterator begin() const
iterator end() const
AttributeSet removeAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attributes from this set.
Definition: Attributes.cpp:962
std::optional< unsigned > getVScaleRangeMax() const
MaybeAlign getStackAlignment() const
Attribute getAttribute(Attribute::AttrKind Kind) const
Return the attribute object.
Type * getPreallocatedType() const
uint64_t getDereferenceableBytes() const
MaybeAlign getAlignment() const
FPClassTest getNoFPClass() const
AttributeSet(const AttributeSet &)=default
Type * getElementType() const
Type * getByRefType() const
CaptureInfo getCaptureInfo() const
AttributeSet()=default
AttributeSet is a trivially copyable value type.
static AttributeSet get(LLVMContext &C, const AttrBuilder &B)
Definition: Attributes.cpp:910
uint64_t getDereferenceableOrNullBytes() const
unsigned getNumAttributes() const
Return the number of attributes in this set.
AttributeSet addAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add an argument attribute.
Definition: Attributes.cpp:918
void dump() const
static const unsigned NumTypeAttrKinds
Definition: Attributes.h:97
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
Definition: Attributes.cpp:348
static Attribute getWithStructRetType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:260
bool operator==(Attribute A) const
Equality and non-equality operators.
Definition: Attributes.h:307
static Attribute::AttrKind getAttrKindFromName(StringRef AttrName)
Definition: Attributes.cpp:305
bool isEnumAttribute() const
Return true if the attribute is an Attribute::AttrKind type.
Definition: Attributes.cpp:340
static Attribute getWithStackAlignment(LLVMContext &Context, Align Alignment)
Definition: Attributes.cpp:239
const ConstantRange & getRange() const
Returns the value of the range attribute.
Definition: Attributes.cpp:502
static bool intersectWithCustom(AttrKind Kind)
Definition: Attributes.cpp:806
bool isIntAttribute() const
Return true if the attribute is an integer attribute.
Definition: Attributes.cpp:344
static Attribute getWithByRefType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:264
std::optional< unsigned > getVScaleRangeMax() const
Returns the maximum value for the vscale_range attribute or std::nullopt when unknown.
Definition: Attributes.cpp:466
uint64_t getValueAsInt() const
Return the attribute's value as an integer.
Definition: Attributes.cpp:371
unsigned getVScaleRangeMin() const
Returns the minimum value for the vscale_range attribute.
Definition: Attributes.cpp:460
AllocFnKind getAllocKind() const
Definition: Attributes.cpp:478
bool isConstantRangeAttribute() const
Return true if the attribute is a ConstantRange attribute.
Definition: Attributes.cpp:356
StringRef getKindAsString() const
Return the attribute's kind as a string.
Definition: Attributes.cpp:385
static Attribute getWithPreallocatedType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:268
static bool intersectWithMin(AttrKind Kind)
Definition: Attributes.cpp:803
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
Definition: Attributes.cpp:95
static bool canUseAsRetAttr(AttrKind Kind)
Definition: Attributes.cpp:782
static bool isTypeAttrKind(AttrKind Kind)
Definition: Attributes.h:105
std::string getAsString(bool InAttrGrp=false) const
The Attribute is converted to a string of equivalent mnemonic.
Definition: Attributes.cpp:528
uint64_t getDereferenceableOrNullBytes() const
Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute.
Definition: Attributes.cpp:446
static Attribute getWithDereferenceableBytes(LLVMContext &Context, uint64_t Bytes)
Definition: Attributes.cpp:244
std::pair< unsigned, std::optional< unsigned > > getAllocSizeArgs() const
Returns the argument numbers for the allocsize attribute.
Definition: Attributes.cpp:454
static Attribute getWithUWTableKind(LLVMContext &Context, UWTableKind Kind)
Definition: Attributes.cpp:276
bool operator!=(Attribute A) const
Definition: Attributes.h:308
FPClassTest getNoFPClass() const
Return the FPClassTest for nofpclass.
Definition: Attributes.cpp:496
static Attribute getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg)
Definition: Attributes.cpp:292
Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind).
Definition: Attributes.cpp:364
Attribute()=default
bool getValueAsBool() const
Return the attribute's value as a boolean.
Definition: Attributes.cpp:378
ArrayRef< ConstantRange > getInitializes() const
Returns the value of the initializes attribute.
Definition: Attributes.cpp:508
const ConstantRange & getValueAsConstantRange() const
Return the attribute's value as a ConstantRange.
Definition: Attributes.cpp:406
uint64_t getDereferenceableBytes() const
Returns the number of dereferenceable bytes from the dereferenceable attribute.
Definition: Attributes.cpp:439
static Attribute getWithVScaleRangeArgs(LLVMContext &Context, unsigned MinValue, unsigned MaxValue)
Definition: Attributes.cpp:299
MemoryEffects getMemoryEffects() const
Returns memory effects.
Definition: Attributes.cpp:484
UWTableKind getUWTableKind() const
Definition: Attributes.cpp:472
static Attribute getWithDereferenceableOrNullBytes(LLVMContext &Context, uint64_t Bytes)
Definition: Attributes.cpp:250
ArrayRef< ConstantRange > getValueAsConstantRangeList() const
Return the attribute's value as a ConstantRange array.
Definition: Attributes.cpp:412
StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:392
static bool isExistingAttribute(StringRef Name)
Return true if the provided string matches the IR name of an attribute.
Definition: Attributes.cpp:328
bool hasKindAsEnum() const
Returns true if the attribute's kind can be represented as an enum (Enum, Integer,...
Definition: Attributes.h:218
static StringRef getNameFromAttrKind(Attribute::AttrKind AttrKind)
Definition: Attributes.cpp:314
static bool canUseAsFnAttr(AttrKind Kind)
Definition: Attributes.cpp:774
static bool intersectWithAnd(AttrKind Kind)
Definition: Attributes.cpp:800
static Attribute getWithNoFPClass(LLVMContext &Context, FPClassTest Mask)
Definition: Attributes.cpp:286
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition: Attributes.h:86
@ TombstoneKey
Use as Tombstone key for DenseMap of AttrKind.
Definition: Attributes.h:93
@ None
No attributes have been set.
Definition: Attributes.h:88
@ EmptyKey
Use as Empty key for DenseMap of AttrKind.
Definition: Attributes.h:92
@ EndAttrKinds
Sentinel value useful for loops.
Definition: Attributes.h:91
static bool isConstantRangeAttrKind(AttrKind Kind)
Definition: Attributes.h:108
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute.
Definition: Attributes.h:319
bool hasParentContext(LLVMContext &C) const
Return true if this attribute belongs to the LLVMContext.
Definition: Attributes.cpp:720
bool isTypeAttribute() const
Return true if the attribute is a type attribute.
Definition: Attributes.cpp:352
static Attribute getWithInAllocaType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:272
static bool isIntAttrKind(AttrKind Kind)
Definition: Attributes.h:102
static bool isConstantRangeListAttrKind(AttrKind Kind)
Definition: Attributes.h:111
bool isConstantRangeListAttribute() const
Return true if the attribute is a ConstantRangeList attribute.
Definition: Attributes.cpp:360
static Attribute getWithByValType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:256
Attribute getWithNewType(LLVMContext &Context, Type *ReplacementTy)
For a typed attribute, return the equivalent attribute with the type changed to ReplacementTy.
Definition: Attributes.h:171
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
Definition: Attributes.cpp:418
static bool isEnumAttrKind(AttrKind Kind)
Definition: Attributes.h:99
static Attribute getWithMemoryEffects(LLVMContext &Context, MemoryEffects ME)
Definition: Attributes.cpp:281
static bool canUseAsParamAttr(AttrKind Kind)
Definition: Attributes.cpp:778
bool isValid() const
Return true if the attribute is any kind of attribute.
Definition: Attributes.h:208
MaybeAlign getStackAlignment() const
Returns the stack alignment field of an attribute as a byte alignment value.
Definition: Attributes.cpp:433
static Attribute fromRawPointer(void *RawPtr)
Get an attribute from a raw pointer created by getRawPointer.
Definition: Attributes.h:324
static const unsigned NumIntAttrKinds
Definition: Attributes.h:96
MaybeAlign getAlignment() const
Returns the alignment field of an attribute as a byte alignment value.
Definition: Attributes.cpp:427
CaptureInfo getCaptureInfo() const
Returns information from captures attribute.
Definition: Attributes.cpp:490
static bool intersectMustPreserve(AttrKind Kind)
Definition: Attributes.cpp:797
int cmpKind(Attribute A) const
Used to sort attribute by kind.
Definition: Attributes.cpp:728
bool operator<(Attribute A) const
Less-than operator. Useful for sorting the attributes list.
Definition: Attributes.cpp:738
static Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
Definition: Attributes.cpp:234
Type * getValueAsType() const
Return the attribute's value as a Type.
Definition: Attributes.cpp:399
Represents which components of the pointer may be captured in which location.
Definition: ModRef.h:318
This class represents a list of constant ranges.
This class represents a range of values.
Definition: ConstantRange.h:47
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
Definition: FoldingSet.h:327
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
LLVM Value Representation.
Definition: Value.h:74
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
struct LLVMOpaqueAttributeRef * LLVMAttributeRef
Used to represent an attributes.
Definition: Types.h:145
bool areInlineCompatible(const Function &Caller, const Function &Callee)
AttributeMask getUBImplyingAttributes()
Get param/return attributes which imply immediate undefined behavior if an invalid value is passed.
bool isNoFPClassCompatibleType(Type *Ty)
Returns true if this is a type legal for the 'nofpclass' attribute.
bool areOutlineCompatible(const Function &A, const Function &B)
Checks if there are any incompatible function attributes between A and B.
void updateMinLegalVectorWidthAttr(Function &Fn, uint64_t Width)
Update min-legal-vector-width if it is in Attribute and less than Width.
void mergeAttributesForOutlining(Function &Base, const Function &ToMerge)
Merges the functions attributes from ToMerge into function Base.
AttributeMask typeIncompatible(Type *Ty, AttributeSet AS, AttributeSafetyKind ASK=ASK_ALL)
Which attributes cannot be applied to a type.
void mergeAttributesForInlining(Function &Caller, const Function &Callee)
Merge caller's and callee's attributes.
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Uninitialized
Definition: Threading.h:61
AllocFnKind
Definition: Attributes.h:49
UWTableKind
Definition: CodeGen.h:120
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
@ Other
Any other memory.
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:335
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:330
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
bool operator!=(const int_wrapper &Other)
Definition: Attributes.h:998
static unsigned getHashValue(AttributeList AS)
Definition: Attributes.h:1048
static AttributeList getTombstoneKey()
Definition: Attributes.h:1042
static bool isEqual(AttributeList LHS, AttributeList RHS)
Definition: Attributes.h:1053
static AttributeSet getTombstoneKey()
Definition: Attributes.h:468
static bool isEqual(AttributeSet LHS, AttributeSet RHS)
Definition: Attributes.h:479
static unsigned getHashValue(AttributeSet AS)
Definition: Attributes.h:474
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: DenseMapInfo.h:52
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:117