Attributes.td revision 360784
1/// Attribute base class. 2class Attr<string S> { 3 // String representation of this attribute in the IR. 4 string AttrString = S; 5} 6 7/// Enum attribute. 8class EnumAttr<string S> : Attr<S>; 9 10/// StringBool attribute. 11class StrBoolAttr<string S> : Attr<S>; 12 13/// Target-independent enum attributes. 14 15/// Alignment of parameter (5 bits) stored as log2 of alignment with +1 bias. 16/// 0 means unaligned (different from align(1)). 17def Alignment : EnumAttr<"align">; 18 19/// The result of the function is guaranteed to point to a number of bytes that 20/// we can determine if we know the value of the function's arguments. 21def AllocSize : EnumAttr<"allocsize">; 22 23/// inline=always. 24def AlwaysInline : EnumAttr<"alwaysinline">; 25 26/// Function can access memory only using pointers based on its arguments. 27def ArgMemOnly : EnumAttr<"argmemonly">; 28 29/// Callee is recognized as a builtin, despite nobuiltin attribute on its 30/// declaration. 31def Builtin : EnumAttr<"builtin">; 32 33/// Pass structure by value. 34def ByVal : EnumAttr<"byval">; 35 36/// Marks function as being in a cold path. 37def Cold : EnumAttr<"cold">; 38 39/// Can only be moved to control-equivalent blocks. 40def Convergent : EnumAttr<"convergent">; 41 42/// Pointer is known to be dereferenceable. 43def Dereferenceable : EnumAttr<"dereferenceable">; 44 45/// Pointer is either null or dereferenceable. 46def DereferenceableOrNull : EnumAttr<"dereferenceable_or_null">; 47 48/// Function may only access memory that is inaccessible from IR. 49def InaccessibleMemOnly : EnumAttr<"inaccessiblememonly">; 50 51/// Function may only access memory that is either inaccessible from the IR, 52/// or pointed to by its pointer arguments. 53def InaccessibleMemOrArgMemOnly : EnumAttr<"inaccessiblemem_or_argmemonly">; 54 55/// Pass structure in an alloca. 56def InAlloca : EnumAttr<"inalloca">; 57 58/// Source said inlining was desirable. 59def InlineHint : EnumAttr<"inlinehint">; 60 61/// Force argument to be passed in register. 62def InReg : EnumAttr<"inreg">; 63 64/// Build jump-instruction tables and replace refs. 65def JumpTable : EnumAttr<"jumptable">; 66 67/// Function must be optimized for size first. 68def MinSize : EnumAttr<"minsize">; 69 70/// Naked function. 71def Naked : EnumAttr<"naked">; 72 73/// Nested function static chain. 74def Nest : EnumAttr<"nest">; 75 76/// Considered to not alias after call. 77def NoAlias : EnumAttr<"noalias">; 78 79/// Callee isn't recognized as a builtin. 80def NoBuiltin : EnumAttr<"nobuiltin">; 81 82/// Function creates no aliases of pointer. 83def NoCapture : EnumAttr<"nocapture">; 84 85/// Call cannot be duplicated. 86def NoDuplicate : EnumAttr<"noduplicate">; 87 88/// Function does not deallocate memory. 89def NoFree : EnumAttr<"nofree">; 90 91/// Disable implicit floating point insts. 92def NoImplicitFloat : EnumAttr<"noimplicitfloat">; 93 94/// inline=never. 95def NoInline : EnumAttr<"noinline">; 96 97/// Function is called early and/or often, so lazy binding isn't worthwhile. 98def NonLazyBind : EnumAttr<"nonlazybind">; 99 100/// Pointer is known to be not null. 101def NonNull : EnumAttr<"nonnull">; 102 103/// The function does not recurse. 104def NoRecurse : EnumAttr<"norecurse">; 105 106/// Disable redzone. 107def NoRedZone : EnumAttr<"noredzone">; 108 109/// Mark the function as not returning. 110def NoReturn : EnumAttr<"noreturn">; 111 112/// Function does not synchronize. 113def NoSync : EnumAttr<"nosync">; 114 115/// Disable Indirect Branch Tracking. 116def NoCfCheck : EnumAttr<"nocf_check">; 117 118/// Function doesn't unwind stack. 119def NoUnwind : EnumAttr<"nounwind">; 120 121/// Select optimizations for best fuzzing signal. 122def OptForFuzzing : EnumAttr<"optforfuzzing">; 123 124/// opt_size. 125def OptimizeForSize : EnumAttr<"optsize">; 126 127/// Function must not be optimized. 128def OptimizeNone : EnumAttr<"optnone">; 129 130/// Function does not access memory. 131def ReadNone : EnumAttr<"readnone">; 132 133/// Function only reads from memory. 134def ReadOnly : EnumAttr<"readonly">; 135 136/// Return value is always equal to this argument. 137def Returned : EnumAttr<"returned">; 138 139/// Parameter is required to be a trivial constant. 140def ImmArg : EnumAttr<"immarg">; 141 142/// Function can return twice. 143def ReturnsTwice : EnumAttr<"returns_twice">; 144 145/// Safe Stack protection. 146def SafeStack : EnumAttr<"safestack">; 147 148/// Shadow Call Stack protection. 149def ShadowCallStack : EnumAttr<"shadowcallstack">; 150 151/// Sign extended before/after call. 152def SExt : EnumAttr<"signext">; 153 154/// Alignment of stack for function (3 bits) stored as log2 of alignment with 155/// +1 bias 0 means unaligned (different from alignstack=(1)). 156def StackAlignment : EnumAttr<"alignstack">; 157 158/// Function can be speculated. 159def Speculatable : EnumAttr<"speculatable">; 160 161/// Stack protection. 162def StackProtect : EnumAttr<"ssp">; 163 164/// Stack protection required. 165def StackProtectReq : EnumAttr<"sspreq">; 166 167/// Strong Stack protection. 168def StackProtectStrong : EnumAttr<"sspstrong">; 169 170/// Function was called in a scope requiring strict floating point semantics. 171def StrictFP : EnumAttr<"strictfp">; 172 173/// Hidden pointer to structure to return. 174def StructRet : EnumAttr<"sret">; 175 176/// AddressSanitizer is on. 177def SanitizeAddress : EnumAttr<"sanitize_address">; 178 179/// ThreadSanitizer is on. 180def SanitizeThread : EnumAttr<"sanitize_thread">; 181 182/// MemorySanitizer is on. 183def SanitizeMemory : EnumAttr<"sanitize_memory">; 184 185/// HWAddressSanitizer is on. 186def SanitizeHWAddress : EnumAttr<"sanitize_hwaddress">; 187 188/// MemTagSanitizer is on. 189def SanitizeMemTag : EnumAttr<"sanitize_memtag">; 190 191/// Speculative Load Hardening is enabled. 192/// 193/// Note that this uses the default compatibility (always compatible during 194/// inlining) and a conservative merge strategy where inlining an attributed 195/// body will add the attribute to the caller. This ensures that code carrying 196/// this attribute will always be lowered with hardening enabled. 197def SpeculativeLoadHardening : EnumAttr<"speculative_load_hardening">; 198 199/// Argument is swift error. 200def SwiftError : EnumAttr<"swifterror">; 201 202/// Argument is swift self/context. 203def SwiftSelf : EnumAttr<"swiftself">; 204 205/// Function must be in a unwind table. 206def UWTable : EnumAttr<"uwtable">; 207 208/// Function always comes back to callsite. 209def WillReturn : EnumAttr<"willreturn">; 210 211/// Function only writes to memory. 212def WriteOnly : EnumAttr<"writeonly">; 213 214/// Zero extended before/after call. 215def ZExt : EnumAttr<"zeroext">; 216 217/// Target-independent string attributes. 218def LessPreciseFPMAD : StrBoolAttr<"less-precise-fpmad">; 219def NoInfsFPMath : StrBoolAttr<"no-infs-fp-math">; 220def NoNansFPMath : StrBoolAttr<"no-nans-fp-math">; 221def UnsafeFPMath : StrBoolAttr<"unsafe-fp-math">; 222def NoJumpTables : StrBoolAttr<"no-jump-tables">; 223def NoInlineLineTables : StrBoolAttr<"no-inline-line-tables">; 224def ProfileSampleAccurate : StrBoolAttr<"profile-sample-accurate">; 225 226class CompatRule<string F> { 227 // The name of the function called to check the attribute of the caller and 228 // callee and decide whether inlining should be allowed. The function's 229 // signature must match "bool(const Function&, const Function &)", where the 230 // first parameter is the reference to the caller and the second parameter is 231 // the reference to the callee. It must return false if the attributes of the 232 // caller and callee are incompatible, and true otherwise. 233 string CompatFunc = F; 234} 235 236def : CompatRule<"isEqual<SanitizeAddressAttr>">; 237def : CompatRule<"isEqual<SanitizeThreadAttr>">; 238def : CompatRule<"isEqual<SanitizeMemoryAttr>">; 239def : CompatRule<"isEqual<SanitizeHWAddressAttr>">; 240def : CompatRule<"isEqual<SanitizeMemTagAttr>">; 241def : CompatRule<"isEqual<SafeStackAttr>">; 242def : CompatRule<"isEqual<ShadowCallStackAttr>">; 243 244class MergeRule<string F> { 245 // The name of the function called to merge the attributes of the caller and 246 // callee. The function's signature must match 247 // "void(Function&, const Function &)", where the first parameter is the 248 // reference to the caller and the second parameter is the reference to the 249 // callee. 250 string MergeFunc = F; 251} 252 253def : MergeRule<"setAND<LessPreciseFPMADAttr>">; 254def : MergeRule<"setAND<NoInfsFPMathAttr>">; 255def : MergeRule<"setAND<NoNansFPMathAttr>">; 256def : MergeRule<"setAND<UnsafeFPMathAttr>">; 257def : MergeRule<"setOR<NoImplicitFloatAttr>">; 258def : MergeRule<"setOR<NoJumpTablesAttr>">; 259def : MergeRule<"setOR<ProfileSampleAccurateAttr>">; 260def : MergeRule<"setOR<SpeculativeLoadHardeningAttr>">; 261def : MergeRule<"adjustCallerSSPLevel">; 262def : MergeRule<"adjustCallerStackProbes">; 263def : MergeRule<"adjustCallerStackProbeSize">; 264def : MergeRule<"adjustMinLegalVectorWidth">; 265def : MergeRule<"adjustNullPointerValidAttr">; 266