@@ -245,61 +245,6 @@ class Function : public GlobalObject, public ilist_node<Function> {
245
245
setValueSubclassData ((getSubclassDataFromValue () & 0xc00f ) | (ID << 4 ));
246
246
}
247
247
248
- // / Return the attribute list for this Function.
249
- AttributeList getAttributes () const { return AttributeSets; }
250
-
251
- // / Set the attribute list for this Function.
252
- void setAttributes (AttributeList Attrs) { AttributeSets = Attrs; }
253
-
254
- // / Add return value attributes to this function.
255
- void addRetAttr (Attribute::AttrKind Kind) {
256
- addAttribute (AttributeList::ReturnIndex, Kind);
257
- }
258
-
259
- // / Add function attributes to this function.
260
- void addFnAttr (Attribute::AttrKind Kind) {
261
- addAttribute (AttributeList::FunctionIndex, Kind);
262
- }
263
-
264
- // / Add function attributes to this function.
265
- void addFnAttr (StringRef Kind, StringRef Val = StringRef()) {
266
- addAttribute (AttributeList::FunctionIndex,
267
- Attribute::get (getContext (), Kind, Val));
268
- }
269
-
270
- // / Add function attributes to this function.
271
- void addFnAttr (Attribute Attr) {
272
- addAttribute (AttributeList::FunctionIndex, Attr);
273
- }
274
-
275
- // / Add function attributes to this function.
276
- void addFnAttrs (const AttrBuilder &Attrs) {
277
- addAttributes (AttributeList::FunctionIndex, Attrs);
278
- }
279
-
280
- // / removes the attributes from the list of attributes.
281
- void removeAttributes (unsigned i, const AttrBuilder &Attrs);
282
-
283
- // / Remove function attributes from this function.
284
- void removeFnAttr (Attribute::AttrKind Kind) {
285
- setAttributes (getAttributes ().removeFnAttribute (getContext (), Kind));
286
- }
287
-
288
- // / Remove function attribute from this function.
289
- void removeFnAttr (StringRef Kind) {
290
- setAttributes (getAttributes ().removeFnAttribute (getContext (), Kind));
291
- }
292
-
293
- void removeFnAttrs (const AttrBuilder &Attrs) {
294
- setAttributes (getAttributes ().removeFnAttributes (getContext (), Attrs));
295
- }
296
-
297
- // / A function will have the "coroutine.presplit" attribute if it's
298
- // / a coroutine and has not gone through full CoroSplit pass.
299
- bool isPresplitCoroutine () const {
300
- return hasFnAttribute (" coroutine.presplit" );
301
- }
302
-
303
248
enum ProfileCountType { PCT_Invalid, PCT_Real, PCT_Synthetic };
304
249
305
250
// / Class to represent profile counts.
@@ -367,43 +312,6 @@ class Function : public GlobalObject, public ilist_node<Function> {
367
312
// / Get the section prefix for this function.
368
313
Optional<StringRef> getSectionPrefix () const ;
369
314
370
- // / Return true if the function has the attribute.
371
- bool hasFnAttribute (Attribute::AttrKind Kind) const {
372
- return AttributeSets.hasFnAttr (Kind);
373
- }
374
-
375
- // / Return true if the function has the attribute.
376
- bool hasFnAttribute (StringRef Kind) const {
377
- return AttributeSets.hasFnAttr (Kind);
378
- }
379
-
380
- // / Return the attribute for the given attribute kind.
381
- Attribute getFnAttribute (Attribute::AttrKind Kind) const {
382
- return AttributeSets.getFnAttr (Kind);
383
- }
384
-
385
- // / Return the attribute for the given attribute kind.
386
- Attribute getFnAttribute (StringRef Kind) const {
387
- return AttributeSets.getFnAttr (Kind);
388
- }
389
-
390
- // / Return the stack alignment for the function.
391
- unsigned getFnStackAlignment () const {
392
- if (!hasFnAttribute (Attribute::StackAlignment))
393
- return 0 ;
394
- if (const auto MA =
395
- AttributeSets.getStackAlignment (AttributeList::FunctionIndex))
396
- return MA->value ();
397
- return 0 ;
398
- }
399
-
400
- // / Return the stack alignment for the function.
401
- MaybeAlign getFnStackAlign () const {
402
- if (!hasFnAttribute (Attribute::StackAlignment))
403
- return None;
404
- return AttributeSets.getStackAlignment (AttributeList::FunctionIndex);
405
- }
406
-
407
315
// / hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm
408
316
// / to use during code generation.
409
317
bool hasGC () const {
@@ -413,18 +321,36 @@ class Function : public GlobalObject, public ilist_node<Function> {
413
321
void setGC (std::string Str);
414
322
void clearGC ();
415
323
416
- // / Returns true if the function has ssp, sspstrong, or sspreq fn attrs .
417
- bool hasStackProtectorFnAttr () const ;
324
+ // / Return the attribute list for this Function .
325
+ AttributeList getAttributes () const { return AttributeSets; }
418
326
419
- // / adds the attribute to the list of attributes .
420
- void addAttribute ( unsigned i, Attribute::AttrKind Kind);
327
+ // / Set the attribute list for this Function .
328
+ void setAttributes (AttributeList Attrs) { AttributeSets = Attrs; }
421
329
422
330
// / adds the attribute to the list of attributes.
423
331
void addAttribute (unsigned i, Attribute Attr);
424
332
333
+ // / adds the attribute to the list of attributes.
334
+ void addAttribute (unsigned i, Attribute::AttrKind Kind);
335
+
425
336
// / adds the attributes to the list of attributes.
426
337
void addAttributes (unsigned i, const AttrBuilder &Attrs);
427
338
339
+ // / Add function attributes to this function.
340
+ void addFnAttr (Attribute::AttrKind Kind);
341
+
342
+ // / Add function attributes to this function.
343
+ void addFnAttr (StringRef Kind, StringRef Val = StringRef());
344
+
345
+ // / Add function attributes to this function.
346
+ void addFnAttr (Attribute Attr);
347
+
348
+ // / Add function attributes to this function.
349
+ void addFnAttrs (const AttrBuilder &Attrs);
350
+
351
+ // / Add return value attributes to this function.
352
+ void addRetAttr (Attribute::AttrKind Kind);
353
+
428
354
// / adds the attribute to the list of attributes for the given arg.
429
355
void addParamAttr (unsigned ArgNo, Attribute::AttrKind Kind);
430
356
@@ -440,12 +366,21 @@ class Function : public GlobalObject, public ilist_node<Function> {
440
366
// / removes the attribute from the list of attributes.
441
367
void removeAttribute (unsigned i, StringRef Kind);
442
368
369
+ // / Remove function attributes from this function.
370
+ void removeFnAttr (Attribute::AttrKind Kind);
371
+
372
+ // / Remove function attribute from this function.
373
+ void removeFnAttr (StringRef Kind);
374
+
375
+ void removeFnAttrs (const AttrBuilder &Attrs);
376
+
443
377
// / removes the attribute from the return value list of attributes.
444
378
void removeRetAttr (Attribute::AttrKind Kind);
445
379
446
380
// / removes the attribute from the return value list of attributes.
447
381
void removeRetAttr (StringRef Kind);
448
382
383
+ // / removes the attributes from the return value list of attributes.
449
384
void removeRetAttrs (const AttrBuilder &Attrs);
450
385
451
386
// / removes the attribute from the list of attributes.
@@ -457,35 +392,57 @@ class Function : public GlobalObject, public ilist_node<Function> {
457
392
// / removes the attribute from the list of attributes.
458
393
void removeParamAttrs (unsigned ArgNo, const AttrBuilder &Attrs);
459
394
460
- // / removes noundef and other attributes that imply undefined behavior if a
461
- // / `undef` or `poison` value is passed from the list of attributes.
462
- void removeParamUndefImplyingAttrs (unsigned ArgNo);
395
+ // / Return true if the function has the attribute.
396
+ bool hasFnAttribute (Attribute::AttrKind Kind) const ;
397
+
398
+ // / Return true if the function has the attribute.
399
+ bool hasFnAttribute (StringRef Kind) const ;
400
+
401
+ // / check if an attribute is in the list of attributes for the return value.
402
+ bool hasRetAttribute (Attribute::AttrKind Kind) const ;
463
403
464
404
// / check if an attributes is in the list of attributes.
465
- bool hasParamAttribute (unsigned ArgNo, Attribute::AttrKind Kind) const {
466
- return getAttributes ().hasParamAttr (ArgNo, Kind);
467
- }
405
+ bool hasParamAttribute (unsigned ArgNo, Attribute::AttrKind Kind) const ;
406
+
407
+ // / gets the attribute from the list of attributes.
408
+ Attribute getAttribute (unsigned i, Attribute::AttrKind Kind) const ;
409
+
410
+ // / gets the attribute from the list of attributes.
411
+ Attribute getAttribute (unsigned i, StringRef Kind) const ;
412
+
413
+ // / Return the attribute for the given attribute kind.
414
+ Attribute getFnAttribute (Attribute::AttrKind Kind) const ;
415
+
416
+ // / Return the attribute for the given attribute kind.
417
+ Attribute getFnAttribute (StringRef Kind) const ;
468
418
469
419
// / gets the specified attribute from the list of attributes.
470
- Attribute getParamAttribute (unsigned ArgNo, Attribute::AttrKind Kind) const {
471
- return getAttributes ().getParamAttr (ArgNo, Kind);
472
- }
420
+ Attribute getParamAttribute (unsigned ArgNo, Attribute::AttrKind Kind) const ;
473
421
474
- // / check if an attribute is in the list of attributes for the return value.
475
- bool hasRetAttribute (Attribute::AttrKind Kind) const {
476
- return getAttributes ().hasRetAttr (Kind);
477
- }
422
+ // / removes noundef and other attributes that imply undefined behavior if a
423
+ // / `undef` or `poison` value is passed from the list of attributes.
424
+ void removeParamUndefImplyingAttrs (unsigned ArgNo);
478
425
479
- // / gets the attribute from the list of attributes.
480
- Attribute getAttribute (unsigned i, Attribute::AttrKind Kind) const {
481
- return AttributeSets.getAttribute (i, Kind);
426
+ // / Return the stack alignment for the function.
427
+ unsigned getFnStackAlignment () const {
428
+ if (!hasFnAttribute (Attribute::StackAlignment))
429
+ return 0 ;
430
+ if (const auto MA =
431
+ AttributeSets.getStackAlignment (AttributeList::FunctionIndex))
432
+ return MA->value ();
433
+ return 0 ;
482
434
}
483
435
484
- // / gets the attribute from the list of attributes.
485
- Attribute getAttribute (unsigned i, StringRef Kind) const {
486
- return AttributeSets.getAttribute (i, Kind);
436
+ // / Return the stack alignment for the function.
437
+ MaybeAlign getFnStackAlign () const {
438
+ if (!hasFnAttribute (Attribute::StackAlignment))
439
+ return None;
440
+ return AttributeSets.getStackAlignment (AttributeList::FunctionIndex);
487
441
}
488
442
443
+ // / Returns true if the function has ssp, sspstrong, or sspreq fn attrs.
444
+ bool hasStackProtectorFnAttr () const ;
445
+
489
446
// / adds the dereferenceable attribute to the list of attributes for
490
447
// / the given arg.
491
448
void addDereferenceableParamAttr (unsigned ArgNo, uint64_t Bytes);
@@ -558,6 +515,12 @@ class Function : public GlobalObject, public ilist_node<Function> {
558
515
return AttributeSets.getParamDereferenceableOrNullBytes (ArgNo);
559
516
}
560
517
518
+ // / A function will have the "coroutine.presplit" attribute if it's
519
+ // / a coroutine and has not gone through full CoroSplit pass.
520
+ bool isPresplitCoroutine () const {
521
+ return hasFnAttribute (" coroutine.presplit" );
522
+ }
523
+
561
524
// / Determine if the function does not access memory.
562
525
bool doesNotAccessMemory () const {
563
526
return hasFnAttribute (Attribute::ReadNone);
@@ -715,9 +678,7 @@ class Function : public GlobalObject, public ilist_node<Function> {
715
678
bool returnDoesNotAlias () const {
716
679
return AttributeSets.hasRetAttr (Attribute::NoAlias);
717
680
}
718
- void setReturnDoesNotAlias () {
719
- addAttribute (AttributeList::ReturnIndex, Attribute::NoAlias);
720
- }
681
+ void setReturnDoesNotAlias () { addRetAttr (Attribute::NoAlias); }
721
682
722
683
// / Do not optimize this function (-O0).
723
684
bool hasOptNone () const { return hasFnAttribute (Attribute::OptimizeNone); }
0 commit comments