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