LLVM 21.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);
169
170 /// For a typed attribute, return the equivalent attribute with the type
171 /// changed to \p ReplacementTy.
172 Attribute getWithNewType(LLVMContext &Context, Type *ReplacementTy) {
173 assert(isTypeAttribute() && "this requires a typed attribute");
174 return get(Context, getKindAsEnum(), ReplacementTy);
175 }
176
178
180
181 /// Return true if the provided string matches the IR name of an attribute.
182 /// example: "noalias" return true but not "NoAlias"
184
185 //===--------------------------------------------------------------------===//
186 // Attribute Accessors
187 //===--------------------------------------------------------------------===//
188
189 /// Return true if the attribute is an Attribute::AttrKind type.
190 bool isEnumAttribute() const;
191
192 /// Return true if the attribute is an integer attribute.
193 bool isIntAttribute() const;
194
195 /// Return true if the attribute is a string (target-dependent)
196 /// attribute.
197 bool isStringAttribute() const;
198
199 /// Return true if the attribute is a type attribute.
200 bool isTypeAttribute() const;
201
202 /// Return true if the attribute is a ConstantRange attribute.
203 bool isConstantRangeAttribute() const;
204
205 /// Return true if the attribute is a ConstantRangeList attribute.
206 bool isConstantRangeListAttribute() const;
207
208 /// Return true if the attribute is any kind of attribute.
209 bool isValid() const { return pImpl; }
210
211 /// Return true if the attribute is present.
212 bool hasAttribute(AttrKind Val) const;
213
214 /// Return true if the target-dependent attribute is present.
215 bool hasAttribute(StringRef Val) const;
216
217 /// Returns true if the attribute's kind can be represented as an enum (Enum,
218 /// Integer, Type, ConstantRange, or ConstantRangeList attribute).
219 bool hasKindAsEnum() const { return !isStringAttribute(); }
220
221 /// Return the attribute's kind as an enum (Attribute::AttrKind). This
222 /// requires the attribute be representable as an enum (see: `hasKindAsEnum`).
224
225 /// Return the attribute's value as an integer. This requires that the
226 /// attribute be an integer attribute.
227 uint64_t getValueAsInt() const;
228
229 /// Return the attribute's value as a boolean. This requires that the
230 /// attribute be a string attribute.
231 bool getValueAsBool() const;
232
233 /// Return the attribute's kind as a string. This requires the
234 /// attribute to be a string attribute.
236
237 /// Return the attribute's value as a string. This requires the
238 /// attribute to be a string attribute.
240
241 /// Return the attribute's value as a Type. This requires the attribute to be
242 /// a type attribute.
243 Type *getValueAsType() const;
244
245 /// Return the attribute's value as a ConstantRange. This requires the
246 /// attribute to be a ConstantRange attribute.
248
249 /// Return the attribute's value as a ConstantRange array. This requires the
250 /// attribute to be a ConstantRangeList attribute.
252
253 /// Returns the alignment field of an attribute as a byte alignment
254 /// value.
255 MaybeAlign getAlignment() const;
256
257 /// Returns the stack alignment field of an attribute as a byte
258 /// alignment value.
260
261 /// Returns the number of dereferenceable bytes from the
262 /// dereferenceable attribute.
264
265 /// Returns the number of dereferenceable_or_null bytes from the
266 /// dereferenceable_or_null attribute.
268
269 /// Returns the argument numbers for the allocsize attribute.
270 std::pair<unsigned, std::optional<unsigned>> getAllocSizeArgs() const;
271
272 /// Returns the minimum value for the vscale_range attribute.
273 unsigned getVScaleRangeMin() const;
274
275 /// Returns the maximum value for the vscale_range attribute or std::nullopt
276 /// when unknown.
277 std::optional<unsigned> getVScaleRangeMax() const;
278
279 // Returns the unwind table kind.
281
282 // Returns the allocator function kind.
284
285 /// Returns memory effects.
287
288 /// Returns information from captures attribute.
290
291 /// Return the FPClassTest for nofpclass
293
294 /// Returns the value of the range attribute.
295 const ConstantRange &getRange() const;
296
297 /// Returns the value of the initializes attribute.
299
300 /// The Attribute is converted to a string of equivalent mnemonic. This
301 /// is, presumably, for writing out the mnemonics for the assembly writer.
302 std::string getAsString(bool InAttrGrp = false) const;
303
304 /// Return true if this attribute belongs to the LLVMContext.
305 bool hasParentContext(LLVMContext &C) const;
306
307 /// Equality and non-equality operators.
308 bool operator==(Attribute A) const { return pImpl == A.pImpl; }
309 bool operator!=(Attribute A) const { return pImpl != A.pImpl; }
310
311 /// Used to sort attribute by kind.
312 int cmpKind(Attribute A) const;
313
314 /// Less-than operator. Useful for sorting the attributes list.
315 bool operator<(Attribute A) const;
316
317 void Profile(FoldingSetNodeID &ID) const;
318
319 /// Return a raw pointer that uniquely identifies this attribute.
320 void *getRawPointer() const {
321 return pImpl;
322 }
323
324 /// Get an attribute from a raw pointer created by getRawPointer.
325 static Attribute fromRawPointer(void *RawPtr) {
326 return Attribute(reinterpret_cast<AttributeImpl*>(RawPtr));
327 }
328};
329
330// Specialized opaque value conversions.
332 return reinterpret_cast<LLVMAttributeRef>(Attr.getRawPointer());
333}
334
335// Specialized opaque value conversions.
337 return Attribute::fromRawPointer(Attr);
338}
339
340//===----------------------------------------------------------------------===//
341/// \class
342/// This class holds the attributes for a particular argument, parameter,
343/// function, or return value. It is an immutable value type that is cheap to
344/// copy. Adding and removing enum attributes is intended to be fast, but adding
345/// and removing string or integer attributes involves a FoldingSet lookup.
347 friend AttributeListImpl;
348 template <typename Ty, typename Enable> friend struct DenseMapInfo;
349
350 // TODO: Extract AvailableAttrs from AttributeSetNode and store them here.
351 // This will allow an efficient implementation of addAttribute and
352 // removeAttribute for enum attrs.
353
354 /// Private implementation pointer.
355 AttributeSetNode *SetNode = nullptr;
356
357private:
358 explicit AttributeSet(AttributeSetNode *ASN) : SetNode(ASN) {}
359
360public:
361 /// AttributeSet is a trivially copyable value type.
362 AttributeSet() = default;
363 AttributeSet(const AttributeSet &) = default;
364 ~AttributeSet() = default;
365
366 static AttributeSet get(LLVMContext &C, const AttrBuilder &B);
368
369 bool operator==(const AttributeSet &O) const { return SetNode == O.SetNode; }
370 bool operator!=(const AttributeSet &O) const { return !(*this == O); }
371
372 /// Add an argument attribute. Returns a new set because attribute sets are
373 /// immutable.
374 [[nodiscard]] AttributeSet addAttribute(LLVMContext &C,
375 Attribute::AttrKind Kind) const;
376
377 /// Add a target-dependent attribute. Returns a new set because attribute sets
378 /// are immutable.
379 [[nodiscard]] AttributeSet addAttribute(LLVMContext &C, StringRef Kind,
380 StringRef Value = StringRef()) const;
381
382 /// Add attributes to the attribute set. Returns a new set because attribute
383 /// sets are immutable.
385 AttributeSet AS) const;
386
387 /// Remove the specified attribute from this set. Returns a new set because
388 /// attribute sets are immutable.
390 Attribute::AttrKind Kind) const;
391
392 /// Remove the specified attribute from this set. Returns a new set because
393 /// attribute sets are immutable.
395 StringRef Kind) const;
396
397 /// Remove the specified attributes from this set. Returns a new set because
398 /// attribute sets are immutable.
399 [[nodiscard]] AttributeSet
400 removeAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const;
401
402 /// Try to intersect this AttributeSet with Other. Returns std::nullopt if
403 /// the two lists are inherently incompatible (imply different behavior, not
404 /// just analysis).
405 [[nodiscard]] std::optional<AttributeSet>
407
408 /// Return the number of attributes in this set.
409 unsigned getNumAttributes() const;
410
411 /// Return true if attributes exists in this set.
412 bool hasAttributes() const { return SetNode != nullptr; }
413
414 /// Return true if the attribute exists in this set.
415 bool hasAttribute(Attribute::AttrKind Kind) const;
416
417 /// Return true if the attribute exists in this set.
418 bool hasAttribute(StringRef Kind) const;
419
420 /// Return the attribute object.
422
423 /// Return the target-dependent attribute object.
424 Attribute getAttribute(StringRef Kind) const;
425
426 MaybeAlign getAlignment() const;
430 Type *getByValType() const;
431 Type *getStructRetType() const;
432 Type *getByRefType() const;
433 Type *getPreallocatedType() const;
434 Type *getInAllocaType() const;
435 Type *getElementType() const;
436 std::optional<std::pair<unsigned, std::optional<unsigned>>> getAllocSizeArgs()
437 const;
438 unsigned getVScaleRangeMin() const;
439 std::optional<unsigned> getVScaleRangeMax() const;
445 std::string getAsString(bool InAttrGrp = false) const;
446
447 /// Return true if this attribute set belongs to the LLVMContext.
448 bool hasParentContext(LLVMContext &C) const;
449
450 using iterator = const Attribute *;
451
452 iterator begin() const;
453 iterator end() const;
454#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
455 void dump() const;
456#endif
457};
458
459//===----------------------------------------------------------------------===//
460/// \class
461/// Provide DenseMapInfo for AttributeSet.
462template <> struct DenseMapInfo<AttributeSet, void> {
464 auto Val = static_cast<uintptr_t>(-1);
465 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
466 return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
467 }
468
470 auto Val = static_cast<uintptr_t>(-2);
471 Val <<= PointerLikeTypeTraits<void *>::NumLowBitsAvailable;
472 return AttributeSet(reinterpret_cast<AttributeSetNode *>(Val));
473 }
474
475 static unsigned getHashValue(AttributeSet AS) {
476 return (unsigned((uintptr_t)AS.SetNode) >> 4) ^
477 (unsigned((uintptr_t)AS.SetNode) >> 9);
478 }
479
480 static bool isEqual(AttributeSet LHS, AttributeSet RHS) { return LHS == RHS; }
481};
482
483//===----------------------------------------------------------------------===//
484/// \class
485/// This class holds the attributes for a function, its return value, and
486/// its parameters. You access the attributes for each of them via an index into
487/// the AttributeList object. The function attributes are at index
488/// `AttributeList::FunctionIndex', the return value is at index
489/// `AttributeList::ReturnIndex', and the attributes for the parameters start at
490/// index `AttributeList::FirstArgIndex'.
492public:
493 enum AttrIndex : unsigned {
497 };
498
499private:
500 friend class AttrBuilder;
501 friend class AttributeListImpl;
502 friend class AttributeSet;
503 friend class AttributeSetNode;
504 template <typename Ty, typename Enable> friend struct DenseMapInfo;
505
506 /// The attributes that we are managing. This can be null to represent
507 /// the empty attributes list.
508 AttributeListImpl *pImpl = nullptr;
509
510public:
511 /// Create an AttributeList with the specified parameters in it.
513 ArrayRef<std::pair<unsigned, Attribute>> Attrs);
515 ArrayRef<std::pair<unsigned, AttributeSet>> Attrs);
516
517 /// Create an AttributeList from attribute sets for a function, its
518 /// return value, and all of its arguments.
519 static AttributeList get(LLVMContext &C, AttributeSet FnAttrs,
520 AttributeSet RetAttrs,
521 ArrayRef<AttributeSet> ArgAttrs);
522
523private:
524 explicit AttributeList(AttributeListImpl *LI) : pImpl(LI) {}
525
526 static AttributeList getImpl(LLVMContext &C, ArrayRef<AttributeSet> AttrSets);
527
528 AttributeList setAttributesAtIndex(LLVMContext &C, unsigned Index,
529 AttributeSet Attrs) const;
530
531public:
532 AttributeList() = default;
533
534 //===--------------------------------------------------------------------===//
535 // AttributeList Construction and Mutation
536 //===--------------------------------------------------------------------===//
537
538 /// Return an AttributeList with the specified parameters in it.
540 static AttributeList get(LLVMContext &C, unsigned Index,
542 static AttributeList get(LLVMContext &C, unsigned Index,
544 ArrayRef<uint64_t> Values);
545 static AttributeList get(LLVMContext &C, unsigned Index,
547 static AttributeList get(LLVMContext &C, unsigned Index,
548 AttributeSet Attrs);
549 static AttributeList get(LLVMContext &C, unsigned Index,
550 const AttrBuilder &B);
551
552 // TODO: remove non-AtIndex versions of these methods.
553 /// Add an attribute to the attribute set at the given index.
554 /// Returns a new list because attribute lists are immutable.
555 [[nodiscard]] AttributeList
557 Attribute::AttrKind Kind) const;
558
559 /// Add an attribute to the attribute set at the given index.
560 /// Returns a new list because attribute lists are immutable.
561 [[nodiscard]] AttributeList
563 StringRef Value = StringRef()) const;
564
565 /// Add an attribute to the attribute set at the given index.
566 /// Returns a new list because attribute lists are immutable.
567 [[nodiscard]] AttributeList
569
570 /// Add attributes to the attribute set at the given index.
571 /// Returns a new list because attribute lists are immutable.
573 unsigned Index,
574 const AttrBuilder &B) const;
575
576 /// Add a function attribute to the list. Returns a new list because
577 /// attribute lists are immutable.
579 Attribute::AttrKind Kind) const {
580 return addAttributeAtIndex(C, FunctionIndex, Kind);
581 }
582
583 /// Add a function attribute to the list. Returns a new list because
584 /// attribute lists are immutable.
586 Attribute Attr) const {
587 return addAttributeAtIndex(C, FunctionIndex, Attr);
588 }
589
590 /// Add a function attribute to the list. Returns a new list because
591 /// attribute lists are immutable.
592 [[nodiscard]] AttributeList
594 StringRef Value = StringRef()) const {
596 }
597
598 /// Add function attribute to the list. Returns a new list because
599 /// attribute lists are immutable.
601 const AttrBuilder &B) const {
603 }
604
605 /// Add a return value attribute to the list. Returns a new list because
606 /// attribute lists are immutable.
608 Attribute::AttrKind Kind) const {
609 return addAttributeAtIndex(C, ReturnIndex, Kind);
610 }
611
612 /// Add a return value attribute to the list. Returns a new list because
613 /// attribute lists are immutable.
615 Attribute Attr) const {
616 return addAttributeAtIndex(C, ReturnIndex, Attr);
617 }
618
619 /// Add a return value attribute to the list. Returns a new list because
620 /// attribute lists are immutable.
622 const AttrBuilder &B) const {
624 }
625
626 /// Add an argument attribute to the list. Returns a new list because
627 /// attribute lists are immutable.
628 [[nodiscard]] AttributeList
630 Attribute::AttrKind Kind) const {
631 return addAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
632 }
633
634 /// Add an argument attribute to the list. Returns a new list because
635 /// attribute lists are immutable.
636 [[nodiscard]] AttributeList
637 addParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind,
638 StringRef Value = StringRef()) const {
639 return addAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind, Value);
640 }
641
642 /// Add an attribute to the attribute list at the given arg indices. Returns a
643 /// new list because attribute lists are immutable.
645 ArrayRef<unsigned> ArgNos,
646 Attribute A) const;
647
648 /// Add an argument attribute to the list. Returns a new list because
649 /// attribute lists are immutable.
650 [[nodiscard]] AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo,
651 const AttrBuilder &B) const {
652 return addAttributesAtIndex(C, ArgNo + FirstArgIndex, B);
653 }
654
655 /// Remove the specified attribute at the specified index from this
656 /// attribute list. Returns a new list because attribute lists are immutable.
657 [[nodiscard]] AttributeList
659 Attribute::AttrKind Kind) const;
660
661 /// Remove the specified attribute at the specified index from this
662 /// attribute list. Returns a new list because attribute lists are immutable.
663 [[nodiscard]] AttributeList
664 removeAttributeAtIndex(LLVMContext &C, unsigned Index, StringRef Kind) const;
666 StringRef Kind) const {
667 return removeAttributeAtIndex(C, Index, Kind);
668 }
669
670 /// Remove the specified attributes at the specified index from this
671 /// attribute list. Returns a new list because attribute lists are immutable.
672 [[nodiscard]] AttributeList
674 const AttributeMask &AttrsToRemove) const;
675
676 /// Remove all attributes at the specified index from this
677 /// attribute list. Returns a new list because attribute lists are immutable.
679 unsigned Index) const;
680
681 /// Remove the specified attribute at the function index from this
682 /// attribute list. Returns a new list because attribute lists are immutable.
683 [[nodiscard]] AttributeList
686 }
687
688 /// Remove the specified attribute at the function index from this
689 /// attribute list. Returns a new list because attribute lists are immutable.
691 StringRef Kind) const {
693 }
694
695 /// Remove the specified attribute at the function index from this
696 /// attribute list. Returns a new list because attribute lists are immutable.
697 [[nodiscard]] AttributeList
698 removeFnAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const {
699 return removeAttributesAtIndex(C, FunctionIndex, AttrsToRemove);
700 }
701
702 /// Remove the attributes at the function index from this
703 /// attribute list. Returns a new list because attribute lists are immutable.
706 }
707
708 /// Remove the specified attribute at the return value index from this
709 /// attribute list. Returns a new list because attribute lists are immutable.
710 [[nodiscard]] AttributeList
712 return removeAttributeAtIndex(C, ReturnIndex, Kind);
713 }
714
715 /// Remove the specified attribute at the return value index from this
716 /// attribute list. Returns a new list because attribute lists are immutable.
718 StringRef Kind) const {
719 return removeAttributeAtIndex(C, ReturnIndex, Kind);
720 }
721
722 /// Remove the specified attribute at the return value index from this
723 /// attribute list. Returns a new list because attribute lists are immutable.
724 [[nodiscard]] AttributeList
726 const AttributeMask &AttrsToRemove) const {
727 return removeAttributesAtIndex(C, ReturnIndex, AttrsToRemove);
728 }
729
730 /// Remove the specified attribute at the specified arg index from this
731 /// attribute list. Returns a new list because attribute lists are immutable.
732 [[nodiscard]] AttributeList
734 Attribute::AttrKind Kind) const {
735 return removeAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
736 }
737
738 /// Remove the specified attribute at the specified arg index from this
739 /// attribute list. Returns a new list because attribute lists are immutable.
740 [[nodiscard]] AttributeList
741 removeParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind) const {
742 return removeAttributeAtIndex(C, ArgNo + FirstArgIndex, Kind);
743 }
744
745 /// Remove the specified attribute at the specified arg index from this
746 /// attribute list. Returns a new list because attribute lists are immutable.
747 [[nodiscard]] AttributeList
749 const AttributeMask &AttrsToRemove) const {
750 return removeAttributesAtIndex(C, ArgNo + FirstArgIndex, AttrsToRemove);
751 }
752
753 /// Remove all attributes at the specified arg index from this
754 /// attribute list. Returns a new list because attribute lists are immutable.
756 unsigned ArgNo) const {
757 return removeAttributesAtIndex(C, ArgNo + FirstArgIndex);
758 }
759
760 /// Replace the type contained by attribute \p AttrKind at index \p ArgNo wih
761 /// \p ReplacementTy, preserving all other attributes.
762 [[nodiscard]] AttributeList
765 Type *ReplacementTy) const {
766 Attribute Attr = getAttributeAtIndex(ArgNo, Kind);
767 auto Attrs = removeAttributeAtIndex(C, ArgNo, Kind);
768 return Attrs.addAttributeAtIndex(C, ArgNo,
769 Attr.getWithNewType(C, ReplacementTy));
770 }
771
772 /// \brief Add the dereferenceable attribute to the attribute set at the given
773 /// index. Returns a new list because attribute lists are immutable.
775 uint64_t Bytes) const;
776
777 /// \brief Add the dereferenceable attribute to the attribute set at the given
778 /// arg index. Returns a new list because attribute lists are immutable.
780 unsigned ArgNo,
781 uint64_t Bytes) const;
782
783 /// Add the dereferenceable_or_null attribute to the attribute set at
784 /// the given arg index. Returns a new list because attribute lists are
785 /// immutable.
786 [[nodiscard]] AttributeList
788 uint64_t Bytes) const;
789
790 /// Add the range attribute to the attribute set at the return value index.
791 /// Returns a new list because attribute lists are immutable.
793 const ConstantRange &CR) const;
794
795 /// Add the allocsize attribute to the attribute set at the given arg index.
796 /// Returns a new list because attribute lists are immutable.
797 [[nodiscard]] AttributeList
798 addAllocSizeParamAttr(LLVMContext &C, unsigned ArgNo, unsigned ElemSizeArg,
799 const std::optional<unsigned> &NumElemsArg) const;
800
801 /// Try to intersect this AttributeList with Other. Returns std::nullopt if
802 /// the two lists are inherently incompatible (imply different behavior, not
803 /// just analysis).
804 [[nodiscard]] std::optional<AttributeList>
806
807 //===--------------------------------------------------------------------===//
808 // AttributeList Accessors
809 //===--------------------------------------------------------------------===//
810
811 /// The attributes for the specified index are returned.
812 AttributeSet getAttributes(unsigned Index) const;
813
814 /// The attributes for the argument or parameter at the given index are
815 /// returned.
816 AttributeSet getParamAttrs(unsigned ArgNo) const;
817
818 /// The attributes for the ret value are returned.
820
821 /// The function attributes are returned.
822 AttributeSet getFnAttrs() const;
823
824 /// Return true if the attribute exists at the given index.
825 bool hasAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const;
826
827 /// Return true if the attribute exists at the given index.
828 bool hasAttributeAtIndex(unsigned Index, StringRef Kind) const;
829
830 /// Return true if attribute exists at the given index.
831 bool hasAttributesAtIndex(unsigned Index) const;
832
833 /// Return true if the attribute exists for the given argument
834 bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
835 return hasAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
836 }
837
838 /// Return true if the attribute exists for the given argument
839 bool hasParamAttr(unsigned ArgNo, StringRef Kind) const {
840 return hasAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
841 }
842
843 /// Return true if attributes exists for the given argument
844 bool hasParamAttrs(unsigned ArgNo) const {
845 return hasAttributesAtIndex(ArgNo + FirstArgIndex);
846 }
847
848 /// Return true if the attribute exists for the return value.
850 return hasAttributeAtIndex(ReturnIndex, Kind);
851 }
852
853 /// Return true if the attribute exists for the return value.
854 bool hasRetAttr(StringRef Kind) const {
855 return hasAttributeAtIndex(ReturnIndex, Kind);
856 }
857
858 /// Return true if attributes exist for the return value.
860
861 /// Return true if the attribute exists for the function.
862 bool hasFnAttr(Attribute::AttrKind Kind) const;
863
864 /// Return true if the attribute exists for the function.
865 bool hasFnAttr(StringRef Kind) const;
866
867 /// Return true the attributes exist for the function.
869
870 /// Return true if the specified attribute is set for at least one
871 /// parameter or for the return value. If Index is not nullptr, the index
872 /// of a parameter with the specified attribute is provided.
874 unsigned *Index = nullptr) const;
875
876 /// Return the attribute object that exists at the given index.
878
879 /// Return the attribute object that exists at the given index.
880 Attribute getAttributeAtIndex(unsigned Index, StringRef Kind) const;
881
882 /// Return the attribute object that exists at the arg index.
883 Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
884 return getAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
885 }
886
887 /// Return the attribute object that exists at the given index.
888 Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const {
889 return getAttributeAtIndex(ArgNo + FirstArgIndex, Kind);
890 }
891
892 /// Return the attribute object that exists for the function.
895 }
896
897 /// Return the attribute object that exists for the function.
900 }
901
902 /// Return the attribute for the given attribute kind for the return value.
904 return getAttributeAtIndex(ReturnIndex, Kind);
905 }
906
907 /// Return the alignment of the return value.
909
910 /// Return the alignment for the specified function parameter.
911 MaybeAlign getParamAlignment(unsigned ArgNo) const;
912
913 /// Return the stack alignment for the specified function parameter.
914 MaybeAlign getParamStackAlignment(unsigned ArgNo) const;
915
916 /// Return the byval type for the specified function parameter.
917 Type *getParamByValType(unsigned ArgNo) const;
918
919 /// Return the sret type for the specified function parameter.
920 Type *getParamStructRetType(unsigned ArgNo) const;
921
922 /// Return the byref type for the specified function parameter.
923 Type *getParamByRefType(unsigned ArgNo) const;
924
925 /// Return the preallocated type for the specified function parameter.
926 Type *getParamPreallocatedType(unsigned ArgNo) const;
927
928 /// Return the inalloca type for the specified function parameter.
929 Type *getParamInAllocaType(unsigned ArgNo) const;
930
931 /// Return the elementtype type for the specified function parameter.
932 Type *getParamElementType(unsigned ArgNo) const;
933
934 /// Get the stack alignment of the function.
936
937 /// Get the stack alignment of the return value.
939
940 /// Get the number of dereferenceable bytes (or zero if unknown) of the return
941 /// value.
943
944 /// Get the number of dereferenceable bytes (or zero if unknown) of an arg.
946
947 /// Get the number of dereferenceable_or_null bytes (or zero if unknown) of
948 /// the return value.
950
951 /// Get the number of dereferenceable_or_null bytes (or zero if unknown) of an
952 /// arg.
953 uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const;
954
955 /// Get range (or std::nullopt if unknown) of an arg.
956 std::optional<ConstantRange> getParamRange(unsigned ArgNo) const;
957
958 /// Get the disallowed floating-point classes of the return value.
960
961 /// Get the disallowed floating-point classes of the argument value.
962 FPClassTest getParamNoFPClass(unsigned ArgNo) const;
963
964 /// Get the unwind table kind requested for the function.
966
968
969 /// Returns memory effects of the function.
971
972 /// Return the attributes at the index as a string.
973 std::string getAsString(unsigned Index, bool InAttrGrp = false) const;
974
975 /// Return true if this attribute list belongs to the LLVMContext.
976 bool hasParentContext(LLVMContext &C) const;
977
978 //===--------------------------------------------------------------------===//
979 // AttributeList Introspection
980 //===--------------------------------------------------------------------===//
981
982 using iterator = const AttributeSet *;
983
984 iterator begin() const;
985 iterator end() const;
986
987 unsigned getNumAttrSets() const;
988
989 // Implementation of indexes(). Produces iterators that wrap an index. Mostly
990 // to hide the awkwardness of unsigned wrapping when iterating over valid
991 // indexes.
993 unsigned NumAttrSets;
995 struct int_wrapper {
996 int_wrapper(unsigned i) : i(i) {}
997 unsigned i;
998 unsigned operator*() { return i; }
999 bool operator!=(const int_wrapper &Other) { return i != Other.i; }
1001 // This is expected to undergo unsigned wrapping since FunctionIndex is
1002 // ~0 and that's where we start.
1003 ++i;
1004 return *this;
1005 }
1006 };
1007
1009
1011 };
1012
1013 /// Use this to iterate over the valid attribute indexes.
1015
1016 /// operator==/!= - Provide equality predicates.
1017 bool operator==(const AttributeList &RHS) const { return pImpl == RHS.pImpl; }
1018 bool operator!=(const AttributeList &RHS) const { return pImpl != RHS.pImpl; }
1019
1020 /// Return a raw pointer that uniquely identifies this attribute list.
1021 void *getRawPointer() const {
1022 return pImpl;
1023 }
1024
1025 /// Return true if there are no attributes.
1026 bool isEmpty() const { return pImpl == nullptr; }
1027
1028 void print(raw_ostream &O) const;
1029
1030 void dump() const;
1031};
1032
1033//===----------------------------------------------------------------------===//
1034/// \class
1035/// Provide DenseMapInfo for AttributeList.
1036template <> struct DenseMapInfo<AttributeList, void> {
1038 auto Val = static_cast<uintptr_t>(-1);
1039 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
1040 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
1041 }
1042
1044 auto Val = static_cast<uintptr_t>(-2);
1045 Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
1046 return AttributeList(reinterpret_cast<AttributeListImpl *>(Val));
1047 }
1048
1049 static unsigned getHashValue(AttributeList AS) {
1050 return (unsigned((uintptr_t)AS.pImpl) >> 4) ^
1051 (unsigned((uintptr_t)AS.pImpl) >> 9);
1052 }
1053
1055 return LHS == RHS;
1056 }
1057};
1058
1059//===----------------------------------------------------------------------===//
1060/// \class
1061/// This class is used in conjunction with the Attribute::get method to
1062/// create an Attribute object. The object itself is uniquified. The Builder's
1063/// value, however, is not. So this can be used as a quick way to test for
1064/// equality, presence of attributes, etc.
1066 LLVMContext &Ctx;
1068
1069public:
1070 AttrBuilder(LLVMContext &Ctx) : Ctx(Ctx) {}
1071 AttrBuilder(const AttrBuilder &) = delete;
1073
1074 AttrBuilder(LLVMContext &Ctx, const Attribute &A) : Ctx(Ctx) {
1075 addAttribute(A);
1076 }
1077
1079
1080 void clear();
1081
1082 /// Add an attribute to the builder.
1084
1085 /// Add the Attribute object to the builder.
1087
1088 /// Add the target-dependent attribute to the builder.
1090
1091 /// Remove an attribute from the builder.
1093
1094 /// Remove the target-dependent attribute from the builder.
1096
1097 /// Remove the target-dependent attribute from the builder.
1099 if (A.isStringAttribute())
1100 return removeAttribute(A.getKindAsString());
1101 else
1102 return removeAttribute(A.getKindAsEnum());
1103 }
1104
1105 /// Add the attributes from the builder. Attributes in the passed builder
1106 /// overwrite attributes in this builder if they have the same key.
1107 AttrBuilder &merge(const AttrBuilder &B);
1108
1109 /// Remove the attributes from the builder.
1110 AttrBuilder &remove(const AttributeMask &AM);
1111
1112 /// Return true if the builder has any attribute that's in the
1113 /// specified builder.
1114 bool overlaps(const AttributeMask &AM) const;
1115
1116 /// Return true if the builder has the specified attribute.
1117 bool contains(Attribute::AttrKind A) const;
1118
1119 /// Return true if the builder has the specified target-dependent
1120 /// attribute.
1121 bool contains(StringRef A) const;
1122
1123 /// Return true if the builder has IR-level attributes.
1124 bool hasAttributes() const { return !Attrs.empty(); }
1125
1126 /// Return Attribute with the given Kind. The returned attribute will be
1127 /// invalid if the Kind is not present in the builder.
1129
1130 /// Return Attribute with the given Kind. The returned attribute will be
1131 /// invalid if the Kind is not present in the builder.
1132 Attribute getAttribute(StringRef Kind) const;
1133
1134 /// Retrieve the range if the attribute exists (std::nullopt is returned
1135 /// otherwise).
1136 std::optional<ConstantRange> getRange() const;
1137
1138 /// Return raw (possibly packed/encoded) value of integer attribute or
1139 /// std::nullopt if not set.
1140 std::optional<uint64_t> getRawIntAttr(Attribute::AttrKind Kind) const;
1141
1142 /// Retrieve the alignment attribute, if it exists.
1144 return MaybeAlign(getRawIntAttr(Attribute::Alignment).value_or(0));
1145 }
1146
1147 /// Retrieve the stack alignment attribute, if it exists.
1149 return MaybeAlign(getRawIntAttr(Attribute::StackAlignment).value_or(0));
1150 }
1151
1152 /// Retrieve the number of dereferenceable bytes, if the
1153 /// dereferenceable attribute exists (zero is returned otherwise).
1155 return getRawIntAttr(Attribute::Dereferenceable).value_or(0);
1156 }
1157
1158 /// Retrieve the number of dereferenceable_or_null bytes, if the
1159 /// dereferenceable_or_null attribute exists (zero is returned otherwise).
1161 return getRawIntAttr(Attribute::DereferenceableOrNull).value_or(0);
1162 }
1163
1164 /// Retrieve type for the given type attribute.
1166
1167 /// Retrieve the byval type.
1168 Type *getByValType() const { return getTypeAttr(Attribute::ByVal); }
1169
1170 /// Retrieve the sret type.
1171 Type *getStructRetType() const { return getTypeAttr(Attribute::StructRet); }
1172
1173 /// Retrieve the byref type.
1174 Type *getByRefType() const { return getTypeAttr(Attribute::ByRef); }
1175
1176 /// Retrieve the preallocated type.
1178 return getTypeAttr(Attribute::Preallocated);
1179 }
1180
1181 /// Retrieve the inalloca type.
1182 Type *getInAllocaType() const { return getTypeAttr(Attribute::InAlloca); }
1183
1184 /// Retrieve the allocsize args, or std::nullopt if the attribute does not
1185 /// exist.
1186 std::optional<std::pair<unsigned, std::optional<unsigned>>> getAllocSizeArgs()
1187 const;
1188
1189 /// Add integer attribute with raw value (packed/encoded if necessary).
1191
1192 /// This turns an alignment into the form used internally in Attribute.
1193 /// This call has no effect if Align is not set.
1195
1196 /// This turns an int alignment (which must be a power of 2) into the
1197 /// form used internally in Attribute.
1198 /// This call has no effect if Align is 0.
1199 /// Deprecated, use the version using a MaybeAlign.
1202 }
1203
1204 /// This turns a stack alignment into the form used internally in Attribute.
1205 /// This call has no effect if Align is not set.
1207
1208 /// This turns an int stack alignment (which must be a power of 2) into
1209 /// the form used internally in Attribute.
1210 /// This call has no effect if Align is 0.
1211 /// Deprecated, use the version using a MaybeAlign.
1214 }
1215
1216 /// This turns the number of dereferenceable bytes into the form used
1217 /// internally in Attribute.
1219
1220 /// This turns the number of dereferenceable_or_null bytes into the
1221 /// form used internally in Attribute.
1223
1224 /// This turns one (or two) ints into the form used internally in Attribute.
1225 AttrBuilder &addAllocSizeAttr(unsigned ElemSizeArg,
1226 const std::optional<unsigned> &NumElemsArg);
1227
1228 /// This turns two ints into the form used internally in Attribute.
1229 AttrBuilder &addVScaleRangeAttr(unsigned MinValue,
1230 std::optional<unsigned> MaxValue);
1231
1232 /// Add a type attribute with the given type.
1234
1235 /// This turns a byval type into the form used internally in Attribute.
1237
1238 /// This turns a sret type into the form used internally in Attribute.
1240
1241 /// This turns a byref type into the form used internally in Attribute.
1243
1244 /// This turns a preallocated type into the form used internally in Attribute.
1246
1247 /// This turns an inalloca type into the form used internally in Attribute.
1249
1250 /// Add an allocsize attribute, using the representation returned by
1251 /// Attribute.getIntValue().
1253
1254 /// Add a vscale_range attribute, using the representation returned by
1255 /// Attribute.getIntValue().
1257
1258 /// This turns the unwind table kind into the form used internally in
1259 /// Attribute.
1261
1262 // This turns the allocator kind into the form used internally in Attribute.
1264
1265 /// Add memory effect attribute.
1267
1268 /// Add captures attribute.
1270
1271 // Add nofpclass attribute
1273
1274 /// Add a ConstantRange attribute with the given range.
1276 const ConstantRange &CR);
1277
1278 /// Add range attribute.
1280
1281 /// Add a ConstantRangeList attribute with the given ranges.
1284
1285 /// Add initializes attribute.
1287
1288 ArrayRef<Attribute> attrs() const { return Attrs; }
1289
1290 bool operator==(const AttrBuilder &B) const;
1291 bool operator!=(const AttrBuilder &B) const { return !(*this == B); }
1292};
1293
1294namespace AttributeFuncs {
1295
1300};
1301
1302/// Returns true if this is a type legal for the 'nofpclass' attribute. This
1303/// follows the same type rules as FPMathOperator.
1305
1306/// Which attributes cannot be applied to a type. The argument \p AS
1307/// is used as a hint for the attributes whose compatibility is being
1308/// checked against \p Ty. This does not mean the return will be a
1309/// subset of \p AS, just that attributes that have specific dynamic
1310/// type compatibilities (i.e `range`) will be checked against what is
1311/// contained in \p AS. The argument \p ASK indicates, if only
1312/// attributes that are known to be safely droppable are contained in
1313/// the mask; only attributes that might be unsafe to drop (e.g.,
1314/// ABI-related attributes) are in the mask; or both.
1317
1318/// Get param/return attributes which imply immediate undefined behavior if an
1319/// invalid value is passed. For example, this includes noundef (where undef
1320/// implies UB), but not nonnull (where null implies poison). It also does not
1321/// include attributes like nocapture, which constrain the function
1322/// implementation rather than the passed value.
1324
1325/// \returns Return true if the two functions have compatible target-independent
1326/// attributes for inlining purposes.
1327bool areInlineCompatible(const Function &Caller, const Function &Callee);
1328
1329
1330/// Checks if there are any incompatible function attributes between
1331/// \p A and \p B.
1332///
1333/// \param [in] A - The first function to be compared with.
1334/// \param [in] B - The second function to be compared with.
1335/// \returns true if the functions have compatible attributes.
1336bool areOutlineCompatible(const Function &A, const Function &B);
1337
1338/// Merge caller's and callee's attributes.
1339void mergeAttributesForInlining(Function &Caller, const Function &Callee);
1340
1341/// Merges the functions attributes from \p ToMerge into function \p Base.
1342///
1343/// \param [in,out] Base - The function being merged into.
1344/// \param [in] ToMerge - The function to merge attributes from.
1345void mergeAttributesForOutlining(Function &Base, const Function &ToMerge);
1346
1347/// Update min-legal-vector-width if it is in Attribute and less than Width.
1349
1350} // end namespace AttributeFuncs
1351
1352} // end namespace llvm
1353
1354#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:1168
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:1212
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:1148
Type * getByRefType() const
Retrieve the byref type.
Definition: Attributes.h:1174
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:1070
uint64_t getDereferenceableBytes() const
Retrieve the number of dereferenceable bytes, if the dereferenceable attribute exists (zero is return...
Definition: Attributes.h:1154
bool hasAttributes() const
Return true if the builder has IR-level attributes.
Definition: Attributes.h:1124
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:1143
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:1177
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:1182
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:1098
uint64_t getDereferenceableOrNullBytes() const
Retrieve the number of dereferenceable_or_null bytes, if the dereferenceable_or_null attribute exists...
Definition: Attributes.h:1160
ArrayRef< Attribute > attrs() const
Definition: Attributes.h:1288
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:1200
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:1291
Type * getStructRetType() const
Retrieve the sret type.
Definition: Attributes.h:1171
AttrBuilder & addRangeAttr(const ConstantRange &CR)
Add range attribute.
AttrBuilder(LLVMContext &Ctx, const Attribute &A)
Definition: Attributes.h:1074
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:898
bool operator==(const AttributeList &RHS) const
operator==/!= - Provide equality predicates.
Definition: Attributes.h:1017
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:755
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:748
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:717
bool hasRetAttr(StringRef Kind) const
Return true if the attribute exists for the return value.
Definition: Attributes.h:854
AttributeSet getFnAttrs() const
The function attributes are returned.
index_iterator indexes() const
Use this to iterate over the valid attribute indexes.
Definition: Attributes.h:1014
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:607
iterator begin() const
bool hasParamAttrs(unsigned ArgNo) const
Return true if attributes exists for the given argument.
Definition: Attributes.h:844
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:621
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:725
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:883
AttributeList removeAttribute(LLVMContext &C, unsigned Index, StringRef Kind) const
Definition: Attributes.h:665
void * getRawPointer() const
Return a raw pointer that uniquely identifies this attribute list.
Definition: Attributes.h:1021
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:741
AllocFnKind getAllocKind() const
bool isEmpty() const
Return true if there are no attributes.
Definition: Attributes.h:1026
AttributeList addFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a function attribute to the list.
Definition: Attributes.h:578
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:600
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:839
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind, StringRef Value=StringRef()) const
Add an argument attribute to the list.
Definition: Attributes.h:637
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:1018
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:893
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:733
AttributeList addFnAttribute(LLVMContext &C, StringRef Kind, StringRef Value=StringRef()) const
Add a function attribute to the list.
Definition: Attributes.h:593
bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return true if the attribute exists for the given argument.
Definition: Attributes.h:834
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:704
Attribute getRetAttr(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind for the return value.
Definition: Attributes.h:903
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:888
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:684
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:859
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:614
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:690
AttributeList removeFnAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:698
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:868
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:650
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:711
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
Definition: Attributes.h:629
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:763
AttributeList addFnAttribute(LLVMContext &C, Attribute Attr) const
Add a function attribute to the list.
Definition: Attributes.h:585
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:849
AllocFnKind getAllocKind() const
bool hasAttributes() const
Return true if attributes exists in this set.
Definition: Attributes.h:412
AttributeSet removeAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute from this set.
Definition: Attributes.cpp:950
Type * getInAllocaType() const
Type * getByValType() const
bool operator!=(const AttributeSet &O) const
Definition: Attributes.h:370
AttributeSet addAttributes(LLVMContext &C, AttributeSet AS) const
Add attributes to the attribute set.
Definition: Attributes.cpp:937
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:369
std::optional< AttributeSet > intersectWith(LLVMContext &C, AttributeSet Other) const
Try to intersect this AttributeSet with Other.
Definition: Attributes.cpp:978
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:966
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:914
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:922
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:352
static Attribute getWithStructRetType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:260
bool operator==(Attribute A) const
Equality and non-equality operators.
Definition: Attributes.h:308
static Attribute::AttrKind getAttrKindFromName(StringRef AttrName)
Definition: Attributes.cpp:309
bool isEnumAttribute() const
Return true if the attribute is an Attribute::AttrKind type.
Definition: Attributes.cpp:344
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:506
static bool intersectWithCustom(AttrKind Kind)
Definition: Attributes.cpp:810
bool isIntAttribute() const
Return true if the attribute is an integer attribute.
Definition: Attributes.cpp:348
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:470
uint64_t getValueAsInt() const
Return the attribute's value as an integer.
Definition: Attributes.cpp:375
unsigned getVScaleRangeMin() const
Returns the minimum value for the vscale_range attribute.
Definition: Attributes.cpp:464
AllocFnKind getAllocKind() const
Definition: Attributes.cpp:482
bool isConstantRangeAttribute() const
Return true if the attribute is a ConstantRange attribute.
Definition: Attributes.cpp:360
StringRef getKindAsString() const
Return the attribute's kind as a string.
Definition: Attributes.cpp:389
static Attribute getWithPreallocatedType(LLVMContext &Context, Type *Ty)
Definition: Attributes.cpp:268
static bool intersectWithMin(AttrKind Kind)
Definition: Attributes.cpp:807
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:786
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:532
uint64_t getDereferenceableOrNullBytes() const
Returns the number of dereferenceable_or_null bytes from the dereferenceable_or_null attribute.
Definition: Attributes.cpp:450
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:458
static Attribute getWithUWTableKind(LLVMContext &Context, UWTableKind Kind)
Definition: Attributes.cpp:276
bool operator!=(Attribute A) const
Definition: Attributes.h:309
FPClassTest getNoFPClass() const
Return the FPClassTest for nofpclass.
Definition: Attributes.cpp:500
static Attribute getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg)
Definition: Attributes.cpp:296
Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind).
Definition: Attributes.cpp:368
Attribute()=default
bool getValueAsBool() const
Return the attribute's value as a boolean.
Definition: Attributes.cpp:382
ArrayRef< ConstantRange > getInitializes() const
Returns the value of the initializes attribute.
Definition: Attributes.cpp:512
const ConstantRange & getValueAsConstantRange() const
Return the attribute's value as a ConstantRange.
Definition: Attributes.cpp:410
uint64_t getDereferenceableBytes() const
Returns the number of dereferenceable bytes from the dereferenceable attribute.
Definition: Attributes.cpp:443
static Attribute getWithVScaleRangeArgs(LLVMContext &Context, unsigned MinValue, unsigned MaxValue)
Definition: Attributes.cpp:303
MemoryEffects getMemoryEffects() const
Returns memory effects.
Definition: Attributes.cpp:488
UWTableKind getUWTableKind() const
Definition: Attributes.cpp:476
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:416
StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:396
static bool isExistingAttribute(StringRef Name)
Return true if the provided string matches the IR name of an attribute.
Definition: Attributes.cpp:332
bool hasKindAsEnum() const
Returns true if the attribute's kind can be represented as an enum (Enum, Integer,...
Definition: Attributes.h:219
static StringRef getNameFromAttrKind(Attribute::AttrKind AttrKind)
Definition: Attributes.cpp:318
static bool canUseAsFnAttr(AttrKind Kind)
Definition: Attributes.cpp:778
static bool intersectWithAnd(AttrKind Kind)
Definition: Attributes.cpp:804
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:320
bool hasParentContext(LLVMContext &C) const
Return true if this attribute belongs to the LLVMContext.
Definition: Attributes.cpp:724
bool isTypeAttribute() const
Return true if the attribute is a type attribute.
Definition: Attributes.cpp:356
static Attribute getWithCaptureInfo(LLVMContext &Context, CaptureInfo CI)
Definition: Attributes.cpp:291
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:364
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:172
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
Definition: Attributes.cpp:422
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:782
bool isValid() const
Return true if the attribute is any kind of attribute.
Definition: Attributes.h:209
MaybeAlign getStackAlignment() const
Returns the stack alignment field of an attribute as a byte alignment value.
Definition: Attributes.cpp:437
static Attribute fromRawPointer(void *RawPtr)
Get an attribute from a raw pointer created by getRawPointer.
Definition: Attributes.h:325
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:431
CaptureInfo getCaptureInfo() const
Returns information from captures attribute.
Definition: Attributes.cpp:494
static bool intersectMustPreserve(AttrKind Kind)
Definition: Attributes.cpp:801
int cmpKind(Attribute A) const
Used to sort attribute by kind.
Definition: Attributes.cpp:732
bool operator<(Attribute A) const
Less-than operator. Useful for sorting the attributes list.
Definition: Attributes.cpp:742
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:403
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:60
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:336
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:331
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:999
static unsigned getHashValue(AttributeList AS)
Definition: Attributes.h:1049
static AttributeList getTombstoneKey()
Definition: Attributes.h:1043
static bool isEqual(AttributeList LHS, AttributeList RHS)
Definition: Attributes.h:1054
static AttributeSet getTombstoneKey()
Definition: Attributes.h:469
static bool isEqual(AttributeSet LHS, AttributeSet RHS)
Definition: Attributes.h:480
static unsigned getHashValue(AttributeSet AS)
Definition: Attributes.h:475
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