1 /// Attribute base class.
3 // String representation of this attribute in the IR.
8 class EnumAttr<string S> : Attr<S>;
10 /// StringBool attribute.
11 class StrBoolAttr<string S> : Attr<S>;
13 /// Target-independent enum attributes.
15 /// Alignment of parameter (5 bits) stored as log2 of alignment with +1 bias.
16 /// 0 means unaligned (different from align(1)).
17 def Alignment : EnumAttr<"align">;
20 def AlwaysInline : EnumAttr<"alwaysinline">;
22 /// Function can access memory only using pointers based on its arguments.
23 def ArgMemOnly : EnumAttr<"argmemonly">;
25 /// Callee is recognized as a builtin, despite nobuiltin attribute on its
27 def Builtin : EnumAttr<"builtin">;
29 /// Pass structure by value.
30 def ByVal : EnumAttr<"byval">;
32 /// Marks function as being in a cold path.
33 def Cold : EnumAttr<"cold">;
35 /// Can only be moved to control-equivalent blocks.
36 def Convergent : EnumAttr<"convergent">;
38 /// Pointer is known to be dereferenceable.
39 def Dereferenceable : EnumAttr<"dereferenceable">;
41 /// Pointer is either null or dereferenceable.
42 def DereferenceableOrNull : EnumAttr<"dereferenceable_or_null">;
44 /// Function may only access memory that is inaccessible from IR.
45 def InaccessibleMemOnly : EnumAttr<"inaccessiblememonly">;
47 /// Function may only access memory that is either inaccessible from the IR,
48 /// or pointed to by its pointer arguments.
49 def InaccessibleMemOrArgMemOnly : EnumAttr<"inaccessiblemem_or_argmemonly">;
51 /// Pass structure in an alloca.
52 def InAlloca : EnumAttr<"inalloca">;
54 /// Source said inlining was desirable.
55 def InlineHint : EnumAttr<"inlinehint">;
57 /// Force argument to be passed in register.
58 def InReg : EnumAttr<"inreg">;
60 /// Build jump-instruction tables and replace refs.
61 def JumpTable : EnumAttr<"jumptable">;
63 /// Function must be optimized for size first.
64 def MinSize : EnumAttr<"minsize">;
67 def Naked : EnumAttr<"naked">;
69 /// Nested function static chain.
70 def Nest : EnumAttr<"nest">;
72 /// Considered to not alias after call.
73 def NoAlias : EnumAttr<"noalias">;
75 /// Callee isn't recognized as a builtin.
76 def NoBuiltin : EnumAttr<"nobuiltin">;
78 /// Function creates no aliases of pointer.
79 def NoCapture : EnumAttr<"nocapture">;
81 /// Call cannot be duplicated.
82 def NoDuplicate : EnumAttr<"noduplicate">;
84 /// Disable implicit floating point insts.
85 def NoImplicitFloat : EnumAttr<"noimplicitfloat">;
88 def NoInline : EnumAttr<"noinline">;
90 /// Function is called early and/or often, so lazy binding isn't worthwhile.
91 def NonLazyBind : EnumAttr<"nonlazybind">;
93 /// Pointer is known to be not null.
94 def NonNull : EnumAttr<"nonnull">;
96 /// The function does not recurse.
97 def NoRecurse : EnumAttr<"norecurse">;
100 def NoRedZone : EnumAttr<"noredzone">;
102 /// Mark the function as not returning.
103 def NoReturn : EnumAttr<"noreturn">;
105 /// Function doesn't unwind stack.
106 def NoUnwind : EnumAttr<"nounwind">;
109 def OptimizeForSize : EnumAttr<"optsize">;
111 /// Function must not be optimized.
112 def OptimizeNone : EnumAttr<"optnone">;
114 /// Function does not access memory.
115 def ReadNone : EnumAttr<"readnone">;
117 /// Function only reads from memory.
118 def ReadOnly : EnumAttr<"readonly">;
120 /// Return value is always equal to this argument.
121 def Returned : EnumAttr<"returned">;
123 /// Function can return twice.
124 def ReturnsTwice : EnumAttr<"returns_twice">;
126 /// Safe Stack protection.
127 def SafeStack : EnumAttr<"safestack">;
129 /// Sign extended before/after call.
130 def SExt : EnumAttr<"signext">;
132 /// Alignment of stack for function (3 bits) stored as log2 of alignment with
133 /// +1 bias 0 means unaligned (different from alignstack=(1)).
134 def StackAlignment : EnumAttr<"alignstack">;
136 /// Stack protection.
137 def StackProtect : EnumAttr<"ssp">;
139 /// Stack protection required.
140 def StackProtectReq : EnumAttr<"sspreq">;
142 /// Strong Stack protection.
143 def StackProtectStrong : EnumAttr<"sspstrong">;
145 /// Hidden pointer to structure to return.
146 def StructRet : EnumAttr<"sret">;
148 /// AddressSanitizer is on.
149 def SanitizeAddress : EnumAttr<"sanitize_address">;
151 /// ThreadSanitizer is on.
152 def SanitizeThread : EnumAttr<"sanitize_thread">;
154 /// MemorySanitizer is on.
155 def SanitizeMemory : EnumAttr<"sanitize_memory">;
157 /// Function must be in a unwind table.
158 def UWTable : EnumAttr<"uwtable">;
160 /// Zero extended before/after call.
161 def ZExt : EnumAttr<"zeroext">;
163 /// Target-independent string attributes.
164 def LessPreciseFPMAD : StrBoolAttr<"less-precise-fpmad">;
165 def NoInfsFPMath : StrBoolAttr<"no-infs-fp-math">;
166 def NoNansFPMath : StrBoolAttr<"no-nans-fp-math">;
167 def UnsafeFPMath : StrBoolAttr<"unsafe-fp-math">;
169 class CompatRule<string F> {
170 // The name of the function called to check the attribute of the caller and
171 // callee and decide whether inlining should be allowed. The function's
172 // signature must match "bool(const Function&, const Function &)", where the
173 // first parameter is the reference to the caller and the second parameter is
174 // the reference to the callee. It must return false if the attributes of the
175 // caller and callee are incompatible, and true otherwise.
176 string CompatFunc = F;
179 def : CompatRule<"isEqual<SanitizeAddressAttr>">;
180 def : CompatRule<"isEqual<SanitizeThreadAttr>">;
181 def : CompatRule<"isEqual<SanitizeMemoryAttr>">;
183 class MergeRule<string F> {
184 // The name of the function called to merge the attributes of the caller and
185 // callee. The function's signature must match
186 // "void(Function&, const Function &)", where the first parameter is the
187 // reference to the caller and the second parameter is the reference to the
189 string MergeFunc = F;
192 def : MergeRule<"adjustCallerSSPLevel">;