1#ifdef GET_ATTR_NAMES
2#undef GET_ATTR_NAMES
3#ifndef ATTRIBUTE_ALL
4#define ATTRIBUTE_ALL(FIRST, SECOND)
5#endif
6
7#ifndef ATTRIBUTE_ENUM
8#define ATTRIBUTE_ENUM(FIRST, SECOND) ATTRIBUTE_ALL(FIRST, SECOND)
9#endif
10
11ATTRIBUTE_ENUM(AllocAlign,allocalign)
12ATTRIBUTE_ENUM(AllocatedPointer,allocptr)
13ATTRIBUTE_ENUM(AlwaysInline,alwaysinline)
14ATTRIBUTE_ENUM(Builtin,builtin)
15ATTRIBUTE_ENUM(Cold,cold)
16ATTRIBUTE_ENUM(Convergent,convergent)
17ATTRIBUTE_ENUM(CoroDestroyOnlyWhenComplete,coro_only_destroy_when_complete)
18ATTRIBUTE_ENUM(DeadOnUnwind,dead_on_unwind)
19ATTRIBUTE_ENUM(DisableSanitizerInstrumentation,disable_sanitizer_instrumentation)
20ATTRIBUTE_ENUM(FnRetThunkExtern,fn_ret_thunk_extern)
21ATTRIBUTE_ENUM(Hot,hot)
22ATTRIBUTE_ENUM(HybridPatchable,hybrid_patchable)
23ATTRIBUTE_ENUM(ImmArg,immarg)
24ATTRIBUTE_ENUM(InReg,inreg)
25ATTRIBUTE_ENUM(InlineHint,inlinehint)
26ATTRIBUTE_ENUM(JumpTable,jumptable)
27ATTRIBUTE_ENUM(MinSize,minsize)
28ATTRIBUTE_ENUM(MustProgress,mustprogress)
29ATTRIBUTE_ENUM(Naked,naked)
30ATTRIBUTE_ENUM(Nest,nest)
31ATTRIBUTE_ENUM(NoAlias,noalias)
32ATTRIBUTE_ENUM(NoBuiltin,nobuiltin)
33ATTRIBUTE_ENUM(NoCallback,nocallback)
34ATTRIBUTE_ENUM(NoCapture,nocapture)
35ATTRIBUTE_ENUM(NoCfCheck,nocf_check)
36ATTRIBUTE_ENUM(NoDuplicate,noduplicate)
37ATTRIBUTE_ENUM(NoFree,nofree)
38ATTRIBUTE_ENUM(NoImplicitFloat,noimplicitfloat)
39ATTRIBUTE_ENUM(NoInline,noinline)
40ATTRIBUTE_ENUM(NoMerge,nomerge)
41ATTRIBUTE_ENUM(NoProfile,noprofile)
42ATTRIBUTE_ENUM(NoRecurse,norecurse)
43ATTRIBUTE_ENUM(NoRedZone,noredzone)
44ATTRIBUTE_ENUM(NoReturn,noreturn)
45ATTRIBUTE_ENUM(NoSanitizeBounds,nosanitize_bounds)
46ATTRIBUTE_ENUM(NoSanitizeCoverage,nosanitize_coverage)
47ATTRIBUTE_ENUM(NoSync,nosync)
48ATTRIBUTE_ENUM(NoUndef,noundef)
49ATTRIBUTE_ENUM(NoUnwind,nounwind)
50ATTRIBUTE_ENUM(NonLazyBind,nonlazybind)
51ATTRIBUTE_ENUM(NonNull,nonnull)
52ATTRIBUTE_ENUM(NullPointerIsValid,null_pointer_is_valid)
53ATTRIBUTE_ENUM(OptForFuzzing,optforfuzzing)
54ATTRIBUTE_ENUM(OptimizeForDebugging,optdebug)
55ATTRIBUTE_ENUM(OptimizeForSize,optsize)
56ATTRIBUTE_ENUM(OptimizeNone,optnone)
57ATTRIBUTE_ENUM(PresplitCoroutine,presplitcoroutine)
58ATTRIBUTE_ENUM(ReadNone,readnone)
59ATTRIBUTE_ENUM(ReadOnly,readonly)
60ATTRIBUTE_ENUM(Returned,returned)
61ATTRIBUTE_ENUM(ReturnsTwice,returns_twice)
62ATTRIBUTE_ENUM(SExt,signext)
63ATTRIBUTE_ENUM(SafeStack,safestack)
64ATTRIBUTE_ENUM(SanitizeAddress,sanitize_address)
65ATTRIBUTE_ENUM(SanitizeHWAddress,sanitize_hwaddress)
66ATTRIBUTE_ENUM(SanitizeMemTag,sanitize_memtag)
67ATTRIBUTE_ENUM(SanitizeMemory,sanitize_memory)
68ATTRIBUTE_ENUM(SanitizeNumericalStability,sanitize_numerical_stability)
69ATTRIBUTE_ENUM(SanitizeThread,sanitize_thread)
70ATTRIBUTE_ENUM(ShadowCallStack,shadowcallstack)
71ATTRIBUTE_ENUM(SkipProfile,skipprofile)
72ATTRIBUTE_ENUM(Speculatable,speculatable)
73ATTRIBUTE_ENUM(SpeculativeLoadHardening,speculative_load_hardening)
74ATTRIBUTE_ENUM(StackProtect,ssp)
75ATTRIBUTE_ENUM(StackProtectReq,sspreq)
76ATTRIBUTE_ENUM(StackProtectStrong,sspstrong)
77ATTRIBUTE_ENUM(StrictFP,strictfp)
78ATTRIBUTE_ENUM(SwiftAsync,swiftasync)
79ATTRIBUTE_ENUM(SwiftError,swifterror)
80ATTRIBUTE_ENUM(SwiftSelf,swiftself)
81ATTRIBUTE_ENUM(WillReturn,willreturn)
82ATTRIBUTE_ENUM(Writable,writable)
83ATTRIBUTE_ENUM(WriteOnly,writeonly)
84ATTRIBUTE_ENUM(ZExt,zeroext)
85ATTRIBUTE_ENUM(ByRef,byref)
86ATTRIBUTE_ENUM(ByVal,byval)
87ATTRIBUTE_ENUM(ElementType,elementtype)
88ATTRIBUTE_ENUM(InAlloca,inalloca)
89ATTRIBUTE_ENUM(Preallocated,preallocated)
90ATTRIBUTE_ENUM(StructRet,sret)
91ATTRIBUTE_ENUM(Alignment,align)
92ATTRIBUTE_ENUM(AllocKind,allockind)
93ATTRIBUTE_ENUM(AllocSize,allocsize)
94ATTRIBUTE_ENUM(Dereferenceable,dereferenceable)
95ATTRIBUTE_ENUM(DereferenceableOrNull,dereferenceable_or_null)
96ATTRIBUTE_ENUM(Memory,memory)
97ATTRIBUTE_ENUM(NoFPClass,nofpclass)
98ATTRIBUTE_ENUM(StackAlignment,alignstack)
99ATTRIBUTE_ENUM(UWTable,uwtable)
100ATTRIBUTE_ENUM(VScaleRange,vscale_range)
101ATTRIBUTE_ENUM(Range,range)
102ATTRIBUTE_ENUM(Initializes,initializes)
103#undef ATTRIBUTE_ENUM
104
105#ifndef ATTRIBUTE_STRBOOL
106#define ATTRIBUTE_STRBOOL(FIRST, SECOND) ATTRIBUTE_ALL(FIRST, SECOND)
107#endif
108
109ATTRIBUTE_STRBOOL(ApproxFuncFPMath,approx-func-fp-math)
110ATTRIBUTE_STRBOOL(LessPreciseFPMAD,less-precise-fpmad)
111ATTRIBUTE_STRBOOL(NoInfsFPMath,no-infs-fp-math)
112ATTRIBUTE_STRBOOL(NoInlineLineTables,no-inline-line-tables)
113ATTRIBUTE_STRBOOL(NoJumpTables,no-jump-tables)
114ATTRIBUTE_STRBOOL(NoNansFPMath,no-nans-fp-math)
115ATTRIBUTE_STRBOOL(NoSignedZerosFPMath,no-signed-zeros-fp-math)
116ATTRIBUTE_STRBOOL(ProfileSampleAccurate,profile-sample-accurate)
117ATTRIBUTE_STRBOOL(UnsafeFPMath,unsafe-fp-math)
118ATTRIBUTE_STRBOOL(UseSampleProfile,use-sample-profile)
119#undef ATTRIBUTE_STRBOOL
120
121#ifndef ATTRIBUTE_COMPLEXSTR
122#define ATTRIBUTE_COMPLEXSTR(FIRST, SECOND) ATTRIBUTE_ALL(FIRST, SECOND)
123#endif
124
125ATTRIBUTE_COMPLEXSTR(DenormalFPMath,denormal-fp-math)
126ATTRIBUTE_COMPLEXSTR(DenormalFPMathF32,denormal-fp-math-f32)
127#undef ATTRIBUTE_COMPLEXSTR
128
129#undef ATTRIBUTE_ALL
130#endif
131
132#ifdef GET_ATTR_ENUM
133#undef GET_ATTR_ENUM
134FirstEnumAttr = 1,
135AllocAlign = 1,
136AllocatedPointer = 2,
137AlwaysInline = 3,
138Builtin = 4,
139Cold = 5,
140Convergent = 6,
141CoroDestroyOnlyWhenComplete = 7,
142DeadOnUnwind = 8,
143DisableSanitizerInstrumentation = 9,
144FnRetThunkExtern = 10,
145Hot = 11,
146HybridPatchable = 12,
147ImmArg = 13,
148InReg = 14,
149InlineHint = 15,
150JumpTable = 16,
151MinSize = 17,
152MustProgress = 18,
153Naked = 19,
154Nest = 20,
155NoAlias = 21,
156NoBuiltin = 22,
157NoCallback = 23,
158NoCapture = 24,
159NoCfCheck = 25,
160NoDuplicate = 26,
161NoFree = 27,
162NoImplicitFloat = 28,
163NoInline = 29,
164NoMerge = 30,
165NoProfile = 31,
166NoRecurse = 32,
167NoRedZone = 33,
168NoReturn = 34,
169NoSanitizeBounds = 35,
170NoSanitizeCoverage = 36,
171NoSync = 37,
172NoUndef = 38,
173NoUnwind = 39,
174NonLazyBind = 40,
175NonNull = 41,
176NullPointerIsValid = 42,
177OptForFuzzing = 43,
178OptimizeForDebugging = 44,
179OptimizeForSize = 45,
180OptimizeNone = 46,
181PresplitCoroutine = 47,
182ReadNone = 48,
183ReadOnly = 49,
184Returned = 50,
185ReturnsTwice = 51,
186SExt = 52,
187SafeStack = 53,
188SanitizeAddress = 54,
189SanitizeHWAddress = 55,
190SanitizeMemTag = 56,
191SanitizeMemory = 57,
192SanitizeNumericalStability = 58,
193SanitizeThread = 59,
194ShadowCallStack = 60,
195SkipProfile = 61,
196Speculatable = 62,
197SpeculativeLoadHardening = 63,
198StackProtect = 64,
199StackProtectReq = 65,
200StackProtectStrong = 66,
201StrictFP = 67,
202SwiftAsync = 68,
203SwiftError = 69,
204SwiftSelf = 70,
205WillReturn = 71,
206Writable = 72,
207WriteOnly = 73,
208ZExt = 74,
209LastEnumAttr = 74,
210FirstTypeAttr = 75,
211ByRef = 75,
212ByVal = 76,
213ElementType = 77,
214InAlloca = 78,
215Preallocated = 79,
216StructRet = 80,
217LastTypeAttr = 80,
218FirstIntAttr = 81,
219Alignment = 81,
220AllocKind = 82,
221AllocSize = 83,
222Dereferenceable = 84,
223DereferenceableOrNull = 85,
224Memory = 86,
225NoFPClass = 87,
226StackAlignment = 88,
227UWTable = 89,
228VScaleRange = 90,
229LastIntAttr = 90,
230FirstConstantRangeAttr = 91,
231Range = 91,
232LastConstantRangeAttr = 91,
233FirstConstantRangeListAttr = 92,
234Initializes = 92,
235LastConstantRangeListAttr = 92,
236#endif
237
238#ifdef GET_ATTR_COMPAT_FUNC
239#undef GET_ATTR_COMPAT_FUNC
240static inline bool hasCompatibleFnAttrs(const Function &Caller,
241 const Function &Callee) {
242 bool Ret = true;
243
244 Ret &= isEqual<SanitizeAddressAttr>(Caller, Callee);
245 Ret &= isEqual<SanitizeThreadAttr>(Caller, Callee);
246 Ret &= isEqual<SanitizeMemoryAttr>(Caller, Callee);
247 Ret &= isEqual<SanitizeHWAddressAttr>(Caller, Callee);
248 Ret &= isEqual<SanitizeMemTagAttr>(Caller, Callee);
249 Ret &= isEqual<SanitizeNumericalStabilityAttr>(Caller, Callee);
250 Ret &= isEqual<SafeStackAttr>(Caller, Callee);
251 Ret &= isEqual<ShadowCallStackAttr>(Caller, Callee);
252 Ret &= isEqual<UseSampleProfileAttr>(Caller, Callee);
253 Ret &= isEqual<NoProfileAttr>(Caller, Callee);
254 Ret &= checkDenormMode(Caller, Callee);
255 Ret &= checkStrictFP(Caller, Callee);
256 Ret &= isEqual(Caller, Callee, "sign-return-address");
257 Ret &= isEqual(Caller, Callee, "sign-return-address-key");
258 Ret &= isEqual(Caller, Callee, "branch-protection-pauth-lr");
259
260 return Ret;
261}
262
263static inline void mergeFnAttrs(Function &Caller,
264 const Function &Callee) {
265 setAND<LessPreciseFPMADAttr>(Caller, Callee);
266 setAND<NoInfsFPMathAttr>(Caller, Callee);
267 setAND<NoNansFPMathAttr>(Caller, Callee);
268 setAND<ApproxFuncFPMathAttr>(Caller, Callee);
269 setAND<NoSignedZerosFPMathAttr>(Caller, Callee);
270 setAND<UnsafeFPMathAttr>(Caller, Callee);
271 setOR<NoImplicitFloatAttr>(Caller, Callee);
272 setOR<NoJumpTablesAttr>(Caller, Callee);
273 setOR<ProfileSampleAccurateAttr>(Caller, Callee);
274 setOR<SpeculativeLoadHardeningAttr>(Caller, Callee);
275 adjustCallerSSPLevel(Caller, Callee);
276 adjustCallerStackProbes(Caller, Callee);
277 adjustCallerStackProbeSize(Caller, Callee);
278 adjustMinLegalVectorWidth(Caller, Callee);
279 adjustNullPointerValidAttr(Caller, Callee);
280 setAND<MustProgressAttr>(Caller, Callee);
281}
282
283#endif
284#ifdef GET_ATTR_PROP_TABLE
285#undef GET_ATTR_PROP_TABLE
286static const uint8_t AttrPropTable[] = {
2870 | AttributeProperty::ParamAttr,
2880 | AttributeProperty::ParamAttr,
2890 | AttributeProperty::FnAttr,
2900 | AttributeProperty::FnAttr,
2910 | AttributeProperty::FnAttr,
2920 | AttributeProperty::FnAttr,
2930 | AttributeProperty::FnAttr,
2940 | AttributeProperty::ParamAttr,
2950 | AttributeProperty::FnAttr,
2960 | AttributeProperty::FnAttr,
2970 | AttributeProperty::FnAttr,
2980 | AttributeProperty::FnAttr,
2990 | AttributeProperty::ParamAttr,
3000 | AttributeProperty::ParamAttr | AttributeProperty::RetAttr,
3010 | AttributeProperty::FnAttr,
3020 | AttributeProperty::FnAttr,
3030 | AttributeProperty::FnAttr,
3040 | AttributeProperty::FnAttr,
3050 | AttributeProperty::FnAttr,
3060 | AttributeProperty::ParamAttr,
3070 | AttributeProperty::ParamAttr | AttributeProperty::RetAttr,
3080 | AttributeProperty::FnAttr,
3090 | AttributeProperty::FnAttr,
3100 | AttributeProperty::ParamAttr,
3110 | AttributeProperty::FnAttr,
3120 | AttributeProperty::FnAttr,
3130 | AttributeProperty::FnAttr | AttributeProperty::ParamAttr,
3140 | AttributeProperty::FnAttr,
3150 | AttributeProperty::FnAttr,
3160 | AttributeProperty::FnAttr,
3170 | AttributeProperty::FnAttr,
3180 | AttributeProperty::FnAttr,
3190 | AttributeProperty::FnAttr,
3200 | AttributeProperty::FnAttr,
3210 | AttributeProperty::FnAttr,
3220 | AttributeProperty::FnAttr,
3230 | AttributeProperty::FnAttr,
3240 | AttributeProperty::ParamAttr | AttributeProperty::RetAttr,
3250 | AttributeProperty::FnAttr,
3260 | AttributeProperty::FnAttr,
3270 | AttributeProperty::ParamAttr | AttributeProperty::RetAttr,
3280 | AttributeProperty::FnAttr,
3290 | AttributeProperty::FnAttr,
3300 | AttributeProperty::FnAttr,
3310 | AttributeProperty::FnAttr,
3320 | AttributeProperty::FnAttr,
3330 | AttributeProperty::FnAttr,
3340 | AttributeProperty::ParamAttr,
3350 | AttributeProperty::ParamAttr,
3360 | AttributeProperty::ParamAttr,
3370 | AttributeProperty::FnAttr,
3380 | AttributeProperty::ParamAttr | AttributeProperty::RetAttr,
3390 | AttributeProperty::FnAttr,
3400 | AttributeProperty::FnAttr,
3410 | AttributeProperty::FnAttr,
3420 | AttributeProperty::FnAttr,
3430 | AttributeProperty::FnAttr,
3440 | AttributeProperty::FnAttr,
3450 | AttributeProperty::FnAttr,
3460 | AttributeProperty::FnAttr,
3470 | AttributeProperty::FnAttr,
3480 | AttributeProperty::FnAttr,
3490 | AttributeProperty::FnAttr,
3500 | AttributeProperty::FnAttr,
3510 | AttributeProperty::FnAttr,
3520 | AttributeProperty::FnAttr,
3530 | AttributeProperty::FnAttr,
3540 | AttributeProperty::ParamAttr,
3550 | AttributeProperty::ParamAttr,
3560 | AttributeProperty::ParamAttr,
3570 | AttributeProperty::FnAttr,
3580 | AttributeProperty::ParamAttr,
3590 | AttributeProperty::ParamAttr,
3600 | AttributeProperty::ParamAttr | AttributeProperty::RetAttr,
3610 | AttributeProperty::ParamAttr,
3620 | AttributeProperty::ParamAttr,
3630 | AttributeProperty::ParamAttr,
3640 | AttributeProperty::ParamAttr,
3650 | AttributeProperty::FnAttr | AttributeProperty::ParamAttr,
3660 | AttributeProperty::ParamAttr,
3670 | AttributeProperty::ParamAttr | AttributeProperty::RetAttr,
3680 | AttributeProperty::FnAttr,
3690 | AttributeProperty::FnAttr,
3700 | AttributeProperty::ParamAttr | AttributeProperty::RetAttr,
3710 | AttributeProperty::ParamAttr | AttributeProperty::RetAttr,
3720 | AttributeProperty::FnAttr,
3730 | AttributeProperty::ParamAttr | AttributeProperty::RetAttr,
3740 | AttributeProperty::FnAttr | AttributeProperty::ParamAttr,
3750 | AttributeProperty::FnAttr,
3760 | AttributeProperty::FnAttr,
3770 | AttributeProperty::ParamAttr | AttributeProperty::RetAttr,
3780 | AttributeProperty::ParamAttr,
379};
380#endif
381