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 /// Return the FPClassTest for nofpclass
289
290 /// Returns the value of the range attribute.
291 const ConstantRange &getRange() const;
292
293 /// Returns the value of the initializes attribute.
295
296 /// The Attribute is converted to a string of equivalent mnemonic. This
297 /// is, presumably, for writing out the mnemonics for the assembly writer.
298 std::string getAsString(bool InAttrGrp = false) const;
299
300 /// Return true if this attribute belongs to the LLVMContext.
301 bool hasParentContext(LLVMContext &C) const;
302
303 /// Equality and non-equality operators.
304 bool operator==(Attribute A) const { return pImpl == A.pImpl; }
305 bool operator!=(Attribute A) const { return pImpl != A.pImpl; }
306
307 /// Used to sort attribute by kind.
308 int cmpKind(Attribute A) const;
309
310 /// Less-than operator. Useful for sorting the attributes list.
311 bool operator<(Attribute A) const;
312
313 void Profile(FoldingSetNodeID &ID) const;
314
315 /// Return a raw pointer that uniquely identifies this attribute.
316 void *getRawPointer() const {
317 return pImpl;
318 }
319
320 /// Get an attribute from a raw pointer created by getRawPointer.
321 static Attribute fromRawPointer(void *RawPtr) {
322 return Attribute(reinterpret_cast<AttributeImpl*>(RawPtr));
323 }
324};
325
326// Specialized opaque value conversions.
328 return reinterpret_cast<LLVMAttributeRef>(Attr.getRawPointer());
329}
330
331// Specialized opaque value conversions.
333 return Attribute::fromRawPointer(Attr);
334}
335
336//===----------------------------------------------------------------------===//
337/// \class
338/// This class holds the attributes for a particular argument, parameter,
339/// function, or return value. It is an immutable value type that is cheap to
340/// copy. Adding and removing enum attributes is intended to be fast, but adding
341/// and removing string or integer attributes involves a FoldingSet lookup.
343 friend AttributeListImpl;
344 template <typename Ty, typename Enable> friend struct DenseMapInfo;
345
346 // TODO: Extract AvailableAttrs from AttributeSetNode and store them here.
347 // This will allow an efficient implementation of addAttribute and
348 // removeAttribute for enum attrs.
349
350 /// Private implementation pointer.
351 AttributeSetNode *SetNode = nullptr;
352
353private:
354 explicit AttributeSet(AttributeSetNode *ASN) : SetNode(ASN) {}
355
356public:
357 /// AttributeSet is a trivially copyable value type.
358 AttributeSet() = default;
359 AttributeSet(const AttributeSet &) = default;
360 ~AttributeSet() = default;
361
362 static AttributeSet get(LLVMContext &C, const AttrBuilder &B);
364
365 bool operator==(const AttributeSet &O) const { return SetNode == O.SetNode; }
366 bool operator!=(const AttributeSet &O) const { return !(*this == O); }
367
368 /// Add an argument attribute. Returns a new set because attribute sets are
369 /// immutable.
370 [[nodiscard]] AttributeSet addAttribute(LLVMContext &C,
371 Attribute::AttrKind Kind) const;
372
373 /// Add a target-dependent attribute. Returns a new set because attribute sets
374 /// are immutable.
375 [[nodiscard]] AttributeSet addAttribute(LLVMContext &C, StringRef Kind,
376 StringRef Value = StringRef()) const;
377
378 /// Add attributes to the attribute set. Returns a new set because attribute
379 /// sets are immutable.
381 AttributeSet AS) const;
382
383 /// Remove the specified attribute from this set. Returns a new set because
384 /// attribute sets are immutable.
386 Attribute::AttrKind Kind) const;
387
388 /// Remove the specified attribute from this set. Returns a new set because
389 /// attribute sets are immutable.
391 StringRef Kind) const;
392
393 /// Remove the specified attributes from this set. Returns a new set because
394 /// attribute sets are immutable.
395 [[nodiscard]] AttributeSet
396 removeAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const;
397
398 /// Try to intersect this AttributeSet with Other. Returns std::nullopt if
399 /// the two lists are inherently incompatible (imply different behavior, not
400 /// just analysis).
401 [[nodiscard]] std::optional<AttributeSet>
403
404 /// Return the number of attributes in this set.
405 unsigned getNumAttributes() const;
406
407 /// Return true if attributes exists in this set.
408 bool hasAttributes() const { return SetNode != nullptr; }
409
410 /// Return true if the attribute exists in this set.
411 bool hasAttribute(Attribute::AttrKind Kind) const;
412
413 /// Return true if the attribute exists in this set.
414 bool hasAttribute(StringRef Kind) const;
415
416 /// Return the attribute object.
418
419 /// Return the target-dependent attribute object.
420 Attribute getAttribute(StringRef Kind) const;
421
422 MaybeAlign getAlignment() const;
426 Type *getByValType() const;
427 Type *getStructRetType() const;
428 Type *getByRefType() const;
429 Type *getPreallocatedType() const;
430 Type *getInAllocaType() const;
431 Type *getElementType() const;
432 std::optional<std::pair<unsigned, std::optional<unsigned>>> getAllocSizeArgs()
433 const;
434 unsigned getVScaleRangeMin() const;
435 std::optional<unsigned> getVScaleRangeMax() const;
440 std::string getAsString(bool InAttrGrp = false) const;
441
442 /// Return true if this attribute set belongs to the LLVMContext.
443 bool hasParentContext(LLVMContext &C) const;
444
445 using iterator = const Attribute *;
446
447 iterator begin() const;
448 iterator end() const;
449#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
450 void dump() const;
451#endif
452};
453
454//===----------------------------------------------------------------------===//
455/// \class
456/// Provide DenseMapInfo for AttributeSet.
457template <> struct DenseMapInfo<AttributeSet, void> {
459 auto Val = static_cast<uintptr_t>(-1);
460 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
461 return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
462 }
463
465 auto Val = static_cast<uintptr_t>(-2);
466 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
467 return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
468 }
469
470 static unsigned getHashValue(AttributeSet AS) {
471 return (unsigned((uintptr_t)AS.SetNode) >> 4) ^
472 (unsigned((uintptr_t)AS.SetNode) >> 9);
473 }
474
475 static bool isEqual(AttributeSet LHS, AttributeSet RHS) { return LHS == RHS; }
476};
477
478//===----------------------------------------------------------------------===//
479/// \class
480/// This class holds the attributes for a function, its return value, and
481/// its parameters. You access the attributes for each of them via an index into
482/// the AttributeList object. The function attributes are at index
483/// `AttributeList::FunctionIndex', the return value is at index
484/// `AttributeList::ReturnIndex', and the attributes for the parameters start at
485/// index `AttributeList::FirstArgIndex'.
487public:
488 enum AttrIndex : unsigned {
492 };
493
494private:
495 friend class AttrBuilder;
496 friend class AttributeListImpl;
497 friend class AttributeSet;
498 friend class AttributeSetNode;
499 template <typename Ty, typename Enable> friend struct DenseMapInfo;
500
501 /// The attributes that we are managing. This can be null to represent
502 /// the empty attributes list.
503 AttributeListImpl *pImpl = nullptr;
504
505public:
506 /// Create an AttributeList with the specified parameters in it.
508 ArrayRef<std::pair<unsigned, Attribute>> Attrs);
510 ArrayRef<std::pair<unsigned, AttributeSet>> Attrs);
511
512 /// Create an AttributeList from attribute sets for a function, its
513 /// return value, and all of its arguments.
514 static AttributeList get(LLVMContext &C, AttributeSet FnAttrs,
515 AttributeSet RetAttrs,
516 ArrayRef<AttributeSet> ArgAttrs);
517
518private:
519 explicit AttributeList(AttributeListImpl *LI) : pImpl(LI) {}
520
521 static AttributeList getImpl(LLVMContext &C, ArrayRef<AttributeSet> AttrSets);
522
523 AttributeList setAttributesAtIndex(LLVMContext &C, unsigned Index,
524 AttributeSet Attrs) const;
525
526public:
527 AttributeList() = default;
528
529 //===--------------------------------------------------------------------===//
530 // AttributeList Construction and Mutation
531 //===--------------------------------------------------------------------===//
532
533 /// Return an AttributeList with the specified parameters in it.
535 static AttributeList get(LLVMContext &C, unsigned Index,
537 static AttributeList get(LLVMContext &C, unsigned Index,
539 ArrayRef<uint64_t> Values);
540 static AttributeList get(LLVMContext &C, unsigned Index,
542 static AttributeList get(LLVMContext &C, unsigned Index,
543 AttributeSet Attrs);
544 static AttributeList get(LLVMContext &C, unsigned Index,
545 const AttrBuilder &B);
546
547 // TODO: remove non-AtIndex versions of these methods.
548 /// Add an attribute to the attribute set at the given index.
549 /// Returns a new list because attribute lists are immutable.
550 [[nodiscard]] AttributeList
552 Attribute::AttrKind Kind) const;
553
554 /// Add an attribute to the attribute set at the given index.
555 /// Returns a new list because attribute lists are immutable.
556 [[nodiscard]] AttributeList
558 StringRef Value = StringRef()) const;
559
560 /// Add an attribute to the attribute set at the given index.
561 /// Returns a new list because attribute lists are immutable.
562 [[nodiscard]] AttributeList
564
565 /// Add attributes to the attribute set at the given index.
566 /// Returns a new list because attribute lists are immutable.
568 unsigned Index,
569 const AttrBuilder &B) const;
570
571 /// Add a function attribute to the list. Returns a new list because
572 /// attribute lists are immutable.
574 Attribute::AttrKind Kind) const {
575 return addAttributeAtIndex(C, FunctionIndex, Kind);
576 }
577
578 /// Add a function attribute to the list. Returns a new list because
579 /// attribute lists are immutable.
581 Attribute Attr) const {
582 return addAttributeAtIndex(C, FunctionIndex, Attr);
583 }
584
585 /// Add a function attribute to the list. Returns a new list because
586 /// attribute lists are immutable.
587 [[nodiscard]] AttributeList
589 StringRef Value = StringRef()) const {
591 }
592
593 /// Add function attribute to the list. Returns a new list because
594 /// attribute lists are immutable.
596 const AttrBuilder &B) const {
598 }
599
600 /// Add a return value attribute to the list. Returns a new list because
601 /// attribute lists are immutable.
603 Attribute::AttrKind Kind) const {
604 return addAttributeAtIndex(C, ReturnIndex, Kind);
605 }
606
607 /// Add a return value attribute to the list. Returns a new list because
608 /// attribute lists are immutable.
610 Attribute Attr) const {
611 return addAttributeAtIndex(C, ReturnIndex, Attr);
612 }
613
614 /// Add a return value attribute to the list. Returns a new list because
615 /// attribute lists are immutable.
617 const AttrBuilder &B) const {
619 }
620
621 /// Add an argument attribute to the list. Returns a new list because
622 /// attribute lists are immutable.
623 [[nodiscard]] AttributeList
625 Attribute::AttrKind Kind) const {
626 return addAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
627 }
628
629 /// Add an argument attribute to the list. Returns a new list because
630 /// attribute lists are immutable.
631 [[nodiscard]] AttributeList
632 addParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind,
633 StringRef Value = StringRef()) const {
634 return addAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind, Value);
635 }
636
637 /// Add an attribute to the attribute list at the given arg indices. Returns a
638 /// new list because attribute lists are immutable.
640 ArrayRef<unsigned> ArgNos,
641 Attribute A) const;
642
643 /// Add an argument attribute to the list. Returns a new list because
644 /// attribute lists are immutable.
645 [[nodiscard]] AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo,
646 const AttrBuilder &B) const {
647 return addAttributesAtIndex(C, ArgNo + FirstArgIndex, B);
648 }
649
650 /// Remove the specified attribute at the specified index from this
651 /// attribute list. Returns a new list because attribute lists are immutable.
652 [[nodiscard]] AttributeList
654 Attribute::AttrKind Kind) const;
655
656 /// Remove the specified attribute at the specified index from this
657 /// attribute list. Returns a new list because attribute lists are immutable.
658 [[nodiscard]] AttributeList
659 removeAttributeAtIndex(LLVMContext &C, unsigned Index, StringRef Kind) const;
661 StringRef Kind) const {
662 return removeAttributeAtIndex(C, Index, Kind);
663 }
664
665 /// Remove the specified attributes at the specified index from this
666 /// attribute list. Returns a new list because attribute lists are immutable.
667 [[nodiscard]] AttributeList
669 const AttributeMask &AttrsToRemove) const;
670
671 /// Remove all attributes at the specified index from this
672 /// attribute list. Returns a new list because attribute lists are immutable.
674 unsigned Index) const;
675
676 /// Remove the specified attribute at the function index from this
677 /// attribute list. Returns a new list because attribute lists are immutable.
678 [[nodiscard]] AttributeList
681 }
682
683 /// Remove the specified attribute at the function index from this
684 /// attribute list. Returns a new list because attribute lists are immutable.
686 StringRef Kind) const {
688 }
689
690 /// Remove the specified attribute at the function index from this
691 /// attribute list. Returns a new list because attribute lists are immutable.
692 [[nodiscard]] AttributeList
693 removeFnAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const {
694 return removeAttributesAtIndex(C, FunctionIndex, AttrsToRemove);
695 }
696
697 /// Remove the attributes at the function index from this
698 /// attribute list. Returns a new list because attribute lists are immutable.
701 }
702
703 /// Remove the specified attribute at the return value index from this
704 /// attribute list. Returns a new list because attribute lists are immutable.
705 [[nodiscard]] AttributeList
707 return removeAttributeAtIndex(C, ReturnIndex, Kind);
708 }
709
710 /// Remove the specified attribute at the return value index from this
711 /// attribute list. Returns a new list because attribute lists are immutable.
713 StringRef Kind) const {
714 return removeAttributeAtIndex(C, ReturnIndex, Kind);
715 }
716
717 /// Remove the specified attribute at the return value index from this
718 /// attribute list. Returns a new list because attribute lists are immutable.
719 [[nodiscard]] AttributeList
721 const AttributeMask &AttrsToRemove) const {
722 return removeAttributesAtIndex(C, ReturnIndex, AttrsToRemove);
723 }
724
725 /// Remove the specified attribute at the specified arg index from this
726 /// attribute list. Returns a new list because attribute lists are immutable.
727 [[nodiscard]] AttributeList
729 Attribute::AttrKind Kind) const {
730 return removeAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
731 }
732
733 /// Remove the specified attribute at the specified arg index from this
734 /// attribute list. Returns a new list because attribute lists are immutable.
735 [[nodiscard]] AttributeList
736 removeParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind) const {
737 return removeAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
738 }
739
740 /// Remove the specified attribute at the specified arg index from this
741 /// attribute list. Returns a new list because attribute lists are immutable.
742 [[nodiscard]] AttributeList
744 const AttributeMask &AttrsToRemove) const {
745 return removeAttributesAtIndex(C, ArgNo + FirstArgIndex, AttrsToRemove);
746 }
747
748 /// Remove all attributes at the specified arg index from this
749 /// attribute list. Returns a new list because attribute lists are immutable.
751 unsigned ArgNo) const {
752 return removeAttributesAtIndex(C, ArgNo + FirstArgIndex);
753 }
754
755 /// Replace the type contained by attribute \p AttrKind at index \p ArgNo wih
756 /// \p ReplacementTy, preserving all other attributes.
757 [[nodiscard]] AttributeList
760 Type *ReplacementTy) const {
761 Attribute Attr = getAttributeAtIndex(ArgNo, Kind);
762 auto Attrs = removeAttributeAtIndex(C, ArgNo, Kind);
763 return Attrs.addAttributeAtIndex(C, ArgNo,
764 Attr.getWithNewType(C, ReplacementTy));
765 }
766
767 /// \brief Add the dereferenceable attribute to the attribute set at the given
768 /// index. Returns a new list because attribute lists are immutable.
770 uint64_t Bytes) const;
771
772 /// \brief Add the dereferenceable attribute to the attribute set at the given
773 /// arg index. Returns a new list because attribute lists are immutable.
775 unsigned ArgNo,
776 uint64_t Bytes) const;
777
778 /// Add the dereferenceable_or_null attribute to the attribute set at
779 /// the given arg index. Returns a new list because attribute lists are
780 /// immutable.
781 [[nodiscard]] AttributeList
783 uint64_t Bytes) const;
784
785 /// Add the range attribute to the attribute set at the return value index.
786 /// Returns a new list because attribute lists are immutable.
788 const ConstantRange &CR) const;
789
790 /// Add the allocsize attribute to the attribute set at the given arg index.
791 /// Returns a new list because attribute lists are immutable.
792 [[nodiscard]] AttributeList
793 addAllocSizeParamAttr(LLVMContext &C, unsigned ArgNo, unsigned ElemSizeArg,
794 const std::optional<unsigned> &NumElemsArg) const;
795
796 /// Try to intersect this AttributeList with Other. Returns std::nullopt if
797 /// the two lists are inherently incompatible (imply different behavior, not
798 /// just analysis).
799 [[nodiscard]] std::optional<AttributeList>
801
802 //===--------------------------------------------------------------------===//
803 // AttributeList Accessors
804 //===--------------------------------------------------------------------===//
805
806 /// The attributes for the specified index are returned.
807 AttributeSet getAttributes(unsigned Index) const;
808
809 /// The attributes for the argument or parameter at the given index are
810 /// returned.
811 AttributeSet getParamAttrs(unsigned ArgNo) const;
812
813 /// The attributes for the ret value are returned.
815
816 /// The function attributes are returned.
817 AttributeSet getFnAttrs() const;
818
819 /// Return true if the attribute exists at the given index.
820 bool hasAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const;
821
822 /// Return true if the attribute exists at the given index.
823 bool hasAttributeAtIndex(unsigned Index, StringRef Kind) const;
824
825 /// Return true if attribute exists at the given index.
826 bool hasAttributesAtIndex(unsigned Index) const;
827
828 /// Return true if the attribute exists for the given argument
829 bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
830 return hasAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
831 }
832
833 /// Return true if the attribute exists for the given argument
834 bool hasParamAttr(unsigned ArgNo, StringRef Kind) const {
835 return hasAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
836 }
837
838 /// Return true if attributes exists for the given argument
839 bool hasParamAttrs(unsigned ArgNo) const {
840 return hasAttributesAtIndex(ArgNo + FirstArgIndex);
841 }
842
843 /// Return true if the attribute exists for the return value.
845 return hasAttributeAtIndex(ReturnIndex, Kind);
846 }
847
848 /// Return true if the attribute exists for the return value.
849 bool hasRetAttr(StringRef Kind) const {
850 return hasAttributeAtIndex(ReturnIndex, Kind);
851 }
852
853 /// Return true if attributes exist for the return value.
855
856 /// Return true if the attribute exists for the function.
857 bool hasFnAttr(Attribute::AttrKind Kind) const;
858
859 /// Return true if the attribute exists for the function.
860 bool hasFnAttr(StringRef Kind) const;
861
862 /// Return true the attributes exist for the function.
864
865 /// Return true if the specified attribute is set for at least one
866 /// parameter or for the return value. If Index is not nullptr, the index
867 /// of a parameter with the specified attribute is provided.
869 unsigned *Index = nullptr) const;
870
871 /// Return the attribute object that exists at the given index.
873
874 /// Return the attribute object that exists at the given index.
875 Attribute getAttributeAtIndex(unsigned Index, StringRef Kind) const;
876
877 /// Return the attribute object that exists at the arg index.
878 Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
879 return getAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
880 }
881
882 /// Return the attribute object that exists at the given index.
883 Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const {
884 return getAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
885 }
886
887 /// Return the attribute object that exists for the function.
890 }
891
892 /// Return the attribute object that exists for the function.
895 }
896
897 /// Return the attribute for the given attribute kind for the return value.
899 return getAttributeAtIndex(ReturnIndex, Kind);
900 }
901
902 /// Return the alignment of the return value.
904
905 /// Return the alignment for the specified function parameter.
906 MaybeAlign getParamAlignment(unsigned ArgNo) const;
907
908 /// Return the stack alignment for the specified function parameter.
909 MaybeAlign getParamStackAlignment(unsigned ArgNo) const;
910
911 /// Return the byval type for the specified function parameter.
912 Type *getParamByValType(unsigned ArgNo) const;
913
914 /// Return the sret type for the specified function parameter.
915 Type *getParamStructRetType(unsigned ArgNo) const;
916
917 /// Return the byref type for the specified function parameter.
918 Type *getParamByRefType(unsigned ArgNo) const;
919
920 /// Return the preallocated type for the specified function parameter.
921 Type *getParamPreallocatedType(unsigned ArgNo) const;
922
923 /// Return the inalloca type for the specified function parameter.
924 Type *getParamInAllocaType(unsigned ArgNo) const;
925
926 /// Return the elementtype type for the specified function parameter.
927 Type *getParamElementType(unsigned ArgNo) const;
928
929 /// Get the stack alignment of the function.
931
932 /// Get the stack alignment of the return value.
934
935 /// Get the number of dereferenceable bytes (or zero if unknown) of the return
936 /// value.
938
939 /// Get the number of dereferenceable bytes (or zero if unknown) of an arg.
941
942 /// Get the number of dereferenceable_or_null bytes (or zero if unknown) of
943 /// the return value.
945
946 /// Get the number of dereferenceable_or_null bytes (or zero if unknown) of an
947 /// arg.
948 uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const;
949
950 /// Get range (or std::nullopt if unknown) of an arg.
951 std::optional<ConstantRange> getParamRange(unsigned ArgNo) const;
952
953 /// Get the disallowed floating-point classes of the return value.
955
956 /// Get the disallowed floating-point classes of the argument value.
957 FPClassTest getParamNoFPClass(unsigned ArgNo) const;
958
959 /// Get the unwind table kind requested for the function.
961
963
964 /// Returns memory effects of the function.
966
967 /// Return the attributes at the index as a string.
968 std::string getAsString(unsigned Index, bool InAttrGrp = false) const;
969
970 /// Return true if this attribute list belongs to the LLVMContext.
971 bool hasParentContext(LLVMContext &C) const;
972
973 //===--------------------------------------------------------------------===//
974 // AttributeList Introspection
975 //===--------------------------------------------------------------------===//
976
977 using iterator = const AttributeSet *;
978
979 iterator begin() const;
980 iterator end() const;
981
982 unsigned getNumAttrSets() const;
983
984 // Implementation of indexes(). Produces iterators that wrap an index. Mostly
985 // to hide the awkwardness of unsigned wrapping when iterating over valid
986 // indexes.
988 unsigned NumAttrSets;
990 struct int_wrapper {
991 int_wrapper(unsigned i) : i(i) {}
992 unsigned i;
993 unsigned operator*() { return i; }
994 bool operator!=(const int_wrapper &Other) { return i != Other.i; }
996 // This is expected to undergo unsigned wrapping since FunctionIndex is
997 // ~0 and that's where we start.
998 ++i;
999 return *this;
1000 }
1001 };
1002
1004
1006 };
1007
1008 /// Use this to iterate over the valid attribute indexes.
1010
1011 /// operator==/!= - Provide equality predicates.
1012 bool operator==(const AttributeList &RHS) const { return pImpl == RHS.pImpl; }
1013 bool operator!=(const AttributeList &RHS) const { return pImpl != RHS.pImpl; }
1014
1015 /// Return a raw pointer that uniquely identifies this attribute list.
1016 void *getRawPointer() const {
1017 return pImpl;
1018 }
1019
1020 /// Return true if there are no attributes.
1021 bool isEmpty() const { return pImpl == nullptr; }
1022
1023 void print(raw_ostream &O) const;
1024
1025 void dump() const;
1026};
1027
1028//===----------------------------------------------------------------------===//
1029/// \class
1030/// Provide DenseMapInfo for AttributeList.
1031template <> struct DenseMapInfo<AttributeList, void> {
1033 auto Val = static_cast<uintptr_t>(-1);
1034 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
1035 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
1036 }
1037
1039 auto Val = static_cast<uintptr_t>(-2);
1040 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
1041 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
1042 }
1043
1044 static unsigned getHashValue(AttributeList AS) {
1045 return (unsigned((uintptr_t)AS.pImpl) >> 4) ^
1046 (unsigned((uintptr_t)AS.pImpl) >> 9);
1047 }
1048
1050 return LHS == RHS;
1051 }
1052};
1053
1054//===----------------------------------------------------------------------===//
1055/// \class
1056/// This class is used in conjunction with the Attribute::get method to
1057/// create an Attribute object. The object itself is uniquified. The Builder's
1058/// value, however, is not. So this can be used as a quick way to test for
1059/// equality, presence of attributes, etc.
1061 LLVMContext &Ctx;
1063
1064public:
1065 AttrBuilder(LLVMContext &Ctx) : Ctx(Ctx) {}
1066 AttrBuilder(const AttrBuilder &) = delete;
1068
1069 AttrBuilder(LLVMContext &Ctx, const Attribute &A) : Ctx(Ctx) {
1070 addAttribute(A);
1071 }
1072
1074
1075 void clear();
1076
1077 /// Add an attribute to the builder.
1079
1080 /// Add the Attribute object to the builder.
1082
1083 /// Add the target-dependent attribute to the builder.
1085
1086 /// Remove an attribute from the builder.
1088
1089 /// Remove the target-dependent attribute from the builder.
1091
1092 /// Remove the target-dependent attribute from the builder.
1094 if (A.isStringAttribute())
1095 return removeAttribute(A.getKindAsString());
1096 else
1097 return removeAttribute(A.getKindAsEnum());
1098 }
1099
1100 /// Add the attributes from the builder. Attributes in the passed builder
1101 /// overwrite attributes in this builder if they have the same key.
1102 AttrBuilder &merge(const AttrBuilder &B);
1103
1104 /// Remove the attributes from the builder.
1105 AttrBuilder &remove(const AttributeMask &AM);
1106
1107 /// Return true if the builder has any attribute that's in the
1108 /// specified builder.
1109 bool overlaps(const AttributeMask &AM) const;
1110
1111 /// Return true if the builder has the specified attribute.
1112 bool contains(Attribute::AttrKind A) const;
1113
1114 /// Return true if the builder has the specified target-dependent
1115 /// attribute.
1116 bool contains(StringRef A) const;
1117
1118 /// Return true if the builder has IR-level attributes.
1119 bool hasAttributes() const { return !Attrs.empty(); }
1120
1121 /// Return Attribute with the given Kind. The returned attribute will be
1122 /// invalid if the Kind is not present in the builder.
1124
1125 /// Return Attribute with the given Kind. The returned attribute will be
1126 /// invalid if the Kind is not present in the builder.
1127 Attribute getAttribute(StringRef Kind) const;
1128
1129 /// Retrieve the range if the attribute exists (std::nullopt is returned
1130 /// otherwise).
1131 std::optional<ConstantRange> getRange() const;
1132
1133 /// Return raw (possibly packed/encoded) value of integer attribute or
1134 /// std::nullopt if not set.
1135 std::optional<uint64_t> getRawIntAttr(Attribute::AttrKind Kind) const;
1136
1137 /// Retrieve the alignment attribute, if it exists.
1139 return MaybeAlign(getRawIntAttr(Attribute::Alignment).value_or(0));
1140 }
1141
1142 /// Retrieve the stack alignment attribute, if it exists.
1144 return MaybeAlign(getRawIntAttr(Attribute::StackAlignment).value_or(0));
1145 }
1146
1147 /// Retrieve the number of dereferenceable bytes, if the
1148 /// dereferenceable attribute exists (zero is returned otherwise).
1150 return getRawIntAttr(Attribute::Dereferenceable).value_or(0);
1151 }
1152
1153 /// Retrieve the number of dereferenceable_or_null bytes, if the
1154 /// dereferenceable_or_null attribute exists (zero is returned otherwise).
1156 return getRawIntAttr(Attribute::DereferenceableOrNull).value_or(0);
1157 }
1158
1159 /// Retrieve type for the given type attribute.
1161
1162 /// Retrieve the byval type.
1163 Type *getByValType() const { return getTypeAttr(Attribute::ByVal); }
1164
1165 /// Retrieve the sret type.
1166 Type *getStructRetType() const { return getTypeAttr(Attribute::StructRet); }
1167
1168 /// Retrieve the byref type.
1169 Type *getByRefType() const { return getTypeAttr(Attribute::ByRef); }
1170
1171 /// Retrieve the preallocated type.
1173 return getTypeAttr(Attribute::Preallocated);
1174 }
1175
1176 /// Retrieve the inalloca type.
1177 Type *getInAllocaType() const { return getTypeAttr(Attribute::InAlloca); }
1178
1179 /// Retrieve the allocsize args, or std::nullopt if the attribute does not
1180 /// exist.
1181 std::optional<std::pair<unsigned, std::optional<unsigned>>> getAllocSizeArgs()
1182 const;
1183
1184 /// Add integer attribute with raw value (packed/encoded if necessary).
1186
1187 /// This turns an alignment into the form used internally in Attribute.
1188 /// This call has no effect if Align is not set.
1190
1191 /// This turns an int alignment (which must be a power of 2) into the
1192 /// form used internally in Attribute.
1193 /// This call has no effect if Align is 0.
1194 /// Deprecated, use the version using a MaybeAlign.
1197 }
1198
1199 /// This turns a stack alignment into the form used internally in Attribute.
1200 /// This call has no effect if Align is not set.
1202
1203 /// This turns an int stack alignment (which must be a power of 2) into
1204 /// the form used internally in Attribute.
1205 /// This call has no effect if Align is 0.
1206 /// Deprecated, use the version using a MaybeAlign.
1209 }
1210
1211 /// This turns the number of dereferenceable bytes into the form used
1212 /// internally in Attribute.
1214
1215 /// This turns the number of dereferenceable_or_null bytes into the
1216 /// form used internally in Attribute.
1218
1219 /// This turns one (or two) ints into the form used internally in Attribute.
1220 AttrBuilder &addAllocSizeAttr(unsigned ElemSizeArg,
1221 const std::optional<unsigned> &NumElemsArg);
1222
1223 /// This turns two ints into the form used internally in Attribute.
1224 AttrBuilder &addVScaleRangeAttr(unsigned MinValue,
1225 std::optional<unsigned> MaxValue);
1226
1227 /// Add a type attribute with the given type.
1229
1230 /// This turns a byval type into the form used internally in Attribute.
1232
1233 /// This turns a sret type into the form used internally in Attribute.
1235
1236 /// This turns a byref type into the form used internally in Attribute.
1238
1239 /// This turns a preallocated type into the form used internally in Attribute.
1241
1242 /// This turns an inalloca type into the form used internally in Attribute.
1244
1245 /// Add an allocsize attribute, using the representation returned by
1246 /// Attribute.getIntValue().
1248
1249 /// Add a vscale_range attribute, using the representation returned by
1250 /// Attribute.getIntValue().
1252
1253 /// This turns the unwind table kind into the form used internally in
1254 /// Attribute.
1256
1257 // This turns the allocator kind into the form used internally in Attribute.
1259
1260 /// Add memory effect attribute.
1262
1263 // Add nofpclass attribute
1265
1266 /// Add a ConstantRange attribute with the given range.
1268 const ConstantRange &CR);
1269
1270 /// Add range attribute.
1272
1273 /// Add a ConstantRangeList attribute with the given ranges.
1276
1277 /// Add initializes attribute.
1279
1280 ArrayRef<Attribute> attrs() const { return Attrs; }
1281
1282 bool operator==(const AttrBuilder &B) const;
1283 bool operator!=(const AttrBuilder &B) const { return !(*this == B); }
1284};
1285
1286namespace AttributeFuncs {
1287
1292};
1293
1294/// Returns true if this is a type legal for the 'nofpclass' attribute. This
1295/// follows the same type rules as FPMathOperator.
1297
1298/// Which attributes cannot be applied to a type. The argument \p AS
1299/// is used as a hint for the attributes whose compatibility is being
1300/// checked against \p Ty. This does not mean the return will be a
1301/// subset of \p AS, just that attributes that have specific dynamic
1302/// type compatibilities (i.e `range`) will be checked against what is
1303/// contained in \p AS. The argument \p ASK indicates, if only
1304/// attributes that are known to be safely droppable are contained in
1305/// the mask; only attributes that might be unsafe to drop (e.g.,
1306/// ABI-related attributes) are in the mask; or both.
1309
1310/// Get param/return attributes which imply immediate undefined behavior if an
1311/// invalid value is passed. For example, this includes noundef (where undef
1312/// implies UB), but not nonnull (where null implies poison). It also does not
1313/// include attributes like nocapture, which constrain the function
1314/// implementation rather than the passed value.
1316
1317/// \returns Return true if the two functions have compatible target-independent
1318/// attributes for inlining purposes.
1319bool areInlineCompatible(const Function &Caller, const Function &Callee);
1320
1321
1322/// Checks if there are any incompatible function attributes between
1323/// \p A and \p B.
1324///
1325/// \param [in] A - The first function to be compared with.
1326/// \param [in] B - The second function to be compared with.
1327/// \returns true if the functions have compatible attributes.
1328bool areOutlineCompatible(const Function &A, const Function &B);
1329
1330/// Merge caller's and callee's attributes.
1331void mergeAttributesForInlining(Function &Caller, const Function &Callee);
1332
1333/// Merges the functions attributes from \p ToMerge into function \p Base.
1334///
1335/// \param [in,out] Base - The function being merged into.
1336/// \param [in] ToMerge - The function to merge attributes from.
1337void mergeAttributesForOutlining(Function &Base, const Function &ToMerge);
1338
1339/// Update min-legal-vector-width if it is in Attribute and less than Width.
1341
1342} // end namespace AttributeFuncs
1343
1344} // end namespace llvm
1345
1346#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:1163
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:1207
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)
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:1143
Type * getByRefType() const
Retrieve the byref type.
Definition: Attributes.h:1169
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:1065
uint64_t getDereferenceableBytes() const
Retrieve the number of dereferenceable bytes, if the dereferenceable attribute exists (zero is return...
Definition: Attributes.h:1149
bool hasAttributes() const
Return true if the builder has IR-level attributes.
Definition: Attributes.h:1119
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:1138
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:1172
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:1177
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:1093
uint64_t getDereferenceableOrNullBytes() const
Retrieve the number of dereferenceable_or_null bytes, if the dereferenceable_or_null attribute exists...
Definition: Attributes.h:1155
ArrayRef< Attribute > attrs() const
Definition: Attributes.h:1280
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:1195
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:1283
Type * getStructRetType() const
Retrieve the sret type.
Definition: Attributes.h:1166
AttrBuilder & addRangeAttr(const ConstantRange &CR)
Add range attribute.
AttrBuilder(LLVMContext &Ctx, const Attribute &A)
Definition: Attributes.h:1069
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:893
bool operator==(const AttributeList &RHS) const
operator==/!= - Provide equality predicates.
Definition: Attributes.h:1012
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:750
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:743
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:712
bool hasRetAttr(StringRef Kind) const
Return true if the attribute exists for the return value.
Definition: Attributes.h:849
AttributeSet getFnAttrs() const
The function attributes are returned.
index_iterator indexes() const
Use this to iterate over the valid attribute indexes.
Definition: Attributes.h:1009
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:602
iterator begin() const
bool hasParamAttrs(unsigned ArgNo) const
Return true if attributes exists for the given argument.
Definition: Attributes.h:839
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:616
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:720
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:878
AttributeList removeAttribute(LLVMContext &C, unsigned Index, StringRef Kind) const
Definition: Attributes.h:660
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute list.
Definition: Attributes.h:1016
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:736
AllocFnKind getAllocKind() const
bool isEmpty() const
Return true if there are no attributes.
Definition: Attributes.h:1021
AttributeList addFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a function attribute to the list.
Definition: Attributes.h:573
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:595
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:834
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind, StringRef Value=StringRef()) const
Add an argument attribute to the list.
Definition: Attributes.h:632
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:1013
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:888
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:728
AttributeList addFnAttribute(LLVMContext &C, StringRef Kind, StringRef Value=StringRef()) const
Add a function attribute to the list.
Definition: Attributes.h:588
bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return true if the attribute exists for the given argument.
Definition: Attributes.h:829
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:699
Attribute getRetAttr(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind for the return value.
Definition: Attributes.h:898
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:883
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:679
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:854
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:609
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:685
AttributeList removeFnAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:693
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:863
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:645
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:706
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
Definition: Attributes.h:624
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:758
AttributeList addFnAttribute(LLVMContext &C, Attribute Attr) const
Add a function attribute to the list.
Definition: Attributes.h:580
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:844
AllocFnKind getAllocKind() const
bool hasAttributes() const
Return true if attributes exists in this set.
Definition: Attributes.h:408
AttributeSet removeAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute from this set.
Definition: Attributes.cpp:933
Type * getInAllocaType() const
Type * getByValType() const
bool operator!=(const AttributeSet &O) const
Definition: Attributes.h:366
AttributeSet addAttributes(LLVMContext &C, AttributeSet AS) const
Add attributes to the attribute set.
Definition: Attributes.cpp:920
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:365
std::optional< AttributeSet > intersectWith(LLVMContext &C, AttributeSet Other) const
Try to intersect this AttributeSet with Other.
Definition: Attributes.cpp:961
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:949
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
AttributeSet()=default
AttributeSet is a trivially copyable value type.
static AttributeSet get(LLVMContext &C, const AttrBuilder &B)
Definition: Attributes.cpp:897
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:905
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:304
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:496
static bool intersectWithCustom(AttrKind Kind)
Definition: Attributes.cpp:793
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:790
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:769
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:522
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:305
FPClassTest getNoFPClass() const
Return the FPClassTest for nofpclass.
Definition: Attributes.cpp:490
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:502
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:761
static bool intersectWithAnd(AttrKind Kind)
Definition: Attributes.cpp:787
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:316
bool hasParentContext(LLVMContext &C) const
Return true if this attribute belongs to the LLVMContext.
Definition: Attributes.cpp:707
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:765
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:321
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
static bool intersectMustPreserve(AttrKind Kind)
Definition: Attributes.cpp:784
int cmpKind(Attribute A) const
Used to sort attribute by kind.
Definition: Attributes.cpp:715
bool operator<(Attribute A) const
Less-than operator. Useful for sorting the attributes list.
Definition: Attributes.cpp:725
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
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:332
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:327
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:994
static unsigned getHashValue(AttributeList AS)
Definition: Attributes.h:1044
static AttributeList getTombstoneKey()
Definition: Attributes.h:1038
static bool isEqual(AttributeList LHS, AttributeList RHS)
Definition: Attributes.h:1049
static AttributeSet getTombstoneKey()
Definition: Attributes.h:464
static bool isEqual(AttributeSet LHS, AttributeSet RHS)
Definition: Attributes.h:475
static unsigned getHashValue(AttributeSet AS)
Definition: Attributes.h:470
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