Skip to content

Commit c29c42f

Browse files
authored
Merge pull request #31560 from compnerd/un-inlined-inlining
runtime: replace `LLVM_ATTRIBUTE_ALWAYS_INLINE` with `SWIFT_INLINE` (…
2 parents 87aa339 + 61ddd09 commit c29c42f

File tree

4 files changed

+122
-121
lines changed

4 files changed

+122
-121
lines changed

stdlib/public/SwiftShims/RefCount.h

Lines changed: 69 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -373,21 +373,17 @@ class RefCountBitsT {
373373
// to improve performance of debug builds.
374374

375375
private:
376-
LLVM_ATTRIBUTE_ALWAYS_INLINE
377-
bool getUseSlowRC() const {
378-
return bool(getField(UseSlowRC));
379-
}
376+
SWIFT_ALWAYS_INLINE
377+
bool getUseSlowRC() const { return bool(getField(UseSlowRC)); }
380378

381-
LLVM_ATTRIBUTE_ALWAYS_INLINE
382-
void setUseSlowRC(bool value) {
383-
setField(UseSlowRC, value);
384-
}
379+
SWIFT_ALWAYS_INLINE
380+
void setUseSlowRC(bool value) { setField(UseSlowRC, value); }
385381

386382
public:
387383

388384
enum Immortal_t { Immortal };
389385

390-
LLVM_ATTRIBUTE_ALWAYS_INLINE
386+
SWIFT_ALWAYS_INLINE
391387
bool isImmortal(bool checkSlowRCBit) const {
392388
if (checkSlowRCBit) {
393389
return (getField(IsImmortal) == Offsets::IsImmortalMask) &&
@@ -396,51 +392,51 @@ class RefCountBitsT {
396392
return (getField(IsImmortal) == Offsets::IsImmortalMask);
397393
}
398394
}
399-
400-
LLVM_ATTRIBUTE_ALWAYS_INLINE
395+
396+
SWIFT_ALWAYS_INLINE
401397
bool isOverflowingUnownedRefCount(uint32_t oldValue, uint32_t inc) const {
402398
auto newValue = getUnownedRefCount();
403399
return newValue != oldValue + inc ||
404400
newValue == Offsets::UnownedRefCountMask;
405401
}
406-
407-
LLVM_ATTRIBUTE_ALWAYS_INLINE
402+
403+
SWIFT_ALWAYS_INLINE
408404
void setIsImmortal(bool value) {
409405
assert(value);
410406
setField(IsImmortal, Offsets::IsImmortalMask);
411407
setField(UseSlowRC, value);
412408
}
413-
414-
LLVM_ATTRIBUTE_ALWAYS_INLINE
409+
410+
SWIFT_ALWAYS_INLINE
415411
bool pureSwiftDeallocation() const {
416412
return bool(getField(PureSwiftDealloc)) && !bool(getField(UseSlowRC));
417413
}
418-
419-
LLVM_ATTRIBUTE_ALWAYS_INLINE
414+
415+
SWIFT_ALWAYS_INLINE
420416
void setPureSwiftDeallocation(bool value) {
421417
setField(PureSwiftDealloc, value);
422418
}
423-
424-
LLVM_ATTRIBUTE_ALWAYS_INLINE
419+
420+
SWIFT_ALWAYS_INLINE
425421
RefCountBitsT() = default;
426422

427-
LLVM_ATTRIBUTE_ALWAYS_INLINE
423+
SWIFT_ALWAYS_INLINE
428424
constexpr
429425
RefCountBitsT(uint32_t strongExtraCount, uint32_t unownedCount)
430426
: bits((BitsType(strongExtraCount) << Offsets::StrongExtraRefCountShift) |
431427
(BitsType(1) << Offsets::PureSwiftDeallocShift) |
432428
(BitsType(unownedCount) << Offsets::UnownedRefCountShift))
433429
{ }
434-
435-
LLVM_ATTRIBUTE_ALWAYS_INLINE
430+
431+
SWIFT_ALWAYS_INLINE
436432
constexpr
437433
RefCountBitsT(Immortal_t immortal)
438434
: bits((BitsType(2) << Offsets::StrongExtraRefCountShift) |
439435
(BitsType(Offsets::IsImmortalMask)) |
440436
(BitsType(1) << Offsets::UseSlowRCShift))
441437
{ }
442438

443-
LLVM_ATTRIBUTE_ALWAYS_INLINE
439+
SWIFT_ALWAYS_INLINE
444440
RefCountBitsT(HeapObjectSideTableEntry* side)
445441
: bits((reinterpret_cast<BitsType>(side) >> Offsets::SideTableUnusedLowBits)
446442
| (BitsType(1) << Offsets::UseSlowRCShift)
@@ -449,7 +445,7 @@ class RefCountBitsT {
449445
assert(refcountIsInline);
450446
}
451447

452-
LLVM_ATTRIBUTE_ALWAYS_INLINE
448+
SWIFT_ALWAYS_INLINE
453449
RefCountBitsT(const RefCountBitsT<RefCountIsInline> *newbitsPtr) {
454450
bits = 0;
455451

@@ -472,8 +468,8 @@ class RefCountBitsT {
472468
copyFieldFrom(newbits, UseSlowRC);
473469
}
474470
}
475-
476-
LLVM_ATTRIBUTE_ALWAYS_INLINE
471+
472+
SWIFT_ALWAYS_INLINE
477473
bool hasSideTable() const {
478474
bool hasSide = getUseSlowRC() && !isImmortal(false);
479475

@@ -484,7 +480,7 @@ class RefCountBitsT {
484480
return hasSide;
485481
}
486482

487-
LLVM_ATTRIBUTE_ALWAYS_INLINE
483+
SWIFT_ALWAYS_INLINE
488484
HeapObjectSideTableEntry *getSideTable() const {
489485
assert(hasSideTable());
490486

@@ -493,32 +489,31 @@ class RefCountBitsT {
493489
(uintptr_t(getField(SideTable)) << Offsets::SideTableUnusedLowBits);
494490
}
495491

496-
LLVM_ATTRIBUTE_ALWAYS_INLINE
492+
SWIFT_ALWAYS_INLINE
497493
uint32_t getUnownedRefCount() const {
498494
assert(!hasSideTable());
499495
return uint32_t(getField(UnownedRefCount));
500496
}
501497

502-
LLVM_ATTRIBUTE_ALWAYS_INLINE
498+
SWIFT_ALWAYS_INLINE
503499
bool getIsDeiniting() const {
504500
assert(!hasSideTable());
505501
return bool(getField(IsDeiniting));
506502
}
507503

508-
LLVM_ATTRIBUTE_ALWAYS_INLINE
504+
SWIFT_ALWAYS_INLINE
509505
uint32_t getStrongExtraRefCount() const {
510506
assert(!hasSideTable());
511507
return uint32_t(getField(StrongExtraRefCount));
512508
}
513509

514-
515-
LLVM_ATTRIBUTE_ALWAYS_INLINE
510+
SWIFT_ALWAYS_INLINE
516511
void setHasSideTable(bool value) {
517512
bits = 0;
518513
setUseSlowRC(value);
519514
}
520515

521-
LLVM_ATTRIBUTE_ALWAYS_INLINE
516+
SWIFT_ALWAYS_INLINE
522517
void setSideTable(HeapObjectSideTableEntry *side) {
523518
assert(hasSideTable());
524519
// Stored value is a shifted pointer.
@@ -529,19 +524,19 @@ class RefCountBitsT {
529524
setField(SideTableMark, 1);
530525
}
531526

532-
LLVM_ATTRIBUTE_ALWAYS_INLINE
527+
SWIFT_ALWAYS_INLINE
533528
void setUnownedRefCount(uint32_t value) {
534529
assert(!hasSideTable());
535530
setField(UnownedRefCount, value);
536531
}
537532

538-
LLVM_ATTRIBUTE_ALWAYS_INLINE
533+
SWIFT_ALWAYS_INLINE
539534
void setIsDeiniting(bool value) {
540535
assert(!hasSideTable());
541536
setField(IsDeiniting, value);
542537
}
543538

544-
LLVM_ATTRIBUTE_ALWAYS_INLINE
539+
SWIFT_ALWAYS_INLINE
545540
void setStrongExtraRefCount(uint32_t value) {
546541
assert(!hasSideTable());
547542
setField(StrongExtraRefCount, value);
@@ -551,8 +546,8 @@ class RefCountBitsT {
551546
// Returns true if the increment is a fast-path result.
552547
// Returns false if the increment should fall back to some slow path
553548
// (for example, because UseSlowRC is set or because the refcount overflowed).
554-
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE
555-
bool incrementStrongExtraRefCount(uint32_t inc) {
549+
LLVM_NODISCARD SWIFT_ALWAYS_INLINE bool
550+
incrementStrongExtraRefCount(uint32_t inc) {
556551
// This deliberately overflows into the UseSlowRC field.
557552
bits += BitsType(inc) << Offsets::StrongExtraRefCountShift;
558553
return (SignedBitsType(bits) >= 0);
@@ -562,8 +557,8 @@ class RefCountBitsT {
562557
// Returns false if the decrement should fall back to some slow path
563558
// (for example, because UseSlowRC is set
564559
// or because the refcount is now zero and should deinit).
565-
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE
566-
bool decrementStrongExtraRefCount(uint32_t dec) {
560+
LLVM_NODISCARD SWIFT_ALWAYS_INLINE bool
561+
decrementStrongExtraRefCount(uint32_t dec) {
567562
#ifndef NDEBUG
568563
if (!hasSideTable() && !isImmortal(false)) {
569564
// Can't check these assertions with side table present.
@@ -583,19 +578,19 @@ class RefCountBitsT {
583578
}
584579

585580
// Returns the old reference count before the increment.
586-
LLVM_ATTRIBUTE_ALWAYS_INLINE
581+
SWIFT_ALWAYS_INLINE
587582
uint32_t incrementUnownedRefCount(uint32_t inc) {
588583
uint32_t old = getUnownedRefCount();
589584
setUnownedRefCount(old + inc);
590585
return old;
591586
}
592587

593-
LLVM_ATTRIBUTE_ALWAYS_INLINE
588+
SWIFT_ALWAYS_INLINE
594589
void decrementUnownedRefCount(uint32_t dec) {
595590
setUnownedRefCount(getUnownedRefCount() - dec);
596591
}
597592

598-
LLVM_ATTRIBUTE_ALWAYS_INLINE
593+
SWIFT_ALWAYS_INLINE
599594
bool isUniquelyReferenced() {
600595
static_assert(Offsets::UnownedRefCountBitCount +
601596
Offsets::IsDeinitingBitCount +
@@ -614,7 +609,7 @@ class RefCountBitsT {
614609
!getUseSlowRC() && !getIsDeiniting() && getStrongExtraRefCount() == 0;
615610
}
616611

617-
LLVM_ATTRIBUTE_ALWAYS_INLINE
612+
SWIFT_ALWAYS_INLINE
618613
BitsType getBitsValue() {
619614
return bits;
620615
}
@@ -636,45 +631,41 @@ class alignas(sizeof(void*) * 2) SideTableRefCountBits : public RefCountBitsT<Re
636631
uint32_t weakBits;
637632

638633
public:
639-
LLVM_ATTRIBUTE_ALWAYS_INLINE
640-
SideTableRefCountBits() = default;
634+
SWIFT_ALWAYS_INLINE
635+
SideTableRefCountBits() = default;
641636

642-
LLVM_ATTRIBUTE_ALWAYS_INLINE
643-
constexpr
644-
SideTableRefCountBits(uint32_t strongExtraCount, uint32_t unownedCount)
645-
: RefCountBitsT<RefCountNotInline>(strongExtraCount, unownedCount)
646-
// weak refcount starts at 1 on behalf of the unowned count
647-
, weakBits(1)
648-
{ }
637+
SWIFT_ALWAYS_INLINE
638+
constexpr SideTableRefCountBits(uint32_t strongExtraCount,
639+
uint32_t unownedCount)
640+
: RefCountBitsT<RefCountNotInline>(strongExtraCount, unownedCount)
641+
// weak refcount starts at 1 on behalf of the unowned count
642+
,
643+
weakBits(1) {}
649644

650-
LLVM_ATTRIBUTE_ALWAYS_INLINE
651-
SideTableRefCountBits(HeapObjectSideTableEntry* side) = delete;
645+
SWIFT_ALWAYS_INLINE
646+
SideTableRefCountBits(HeapObjectSideTableEntry *side) = delete;
652647

653-
LLVM_ATTRIBUTE_ALWAYS_INLINE
654-
SideTableRefCountBits(InlineRefCountBits newbits)
655-
: RefCountBitsT<RefCountNotInline>(&newbits), weakBits(1)
656-
{ }
648+
SWIFT_ALWAYS_INLINE
649+
SideTableRefCountBits(InlineRefCountBits newbits)
650+
: RefCountBitsT<RefCountNotInline>(&newbits), weakBits(1) {}
657651

658-
659-
LLVM_ATTRIBUTE_ALWAYS_INLINE
660-
void incrementWeakRefCount() {
661-
weakBits++;
662-
}
652+
SWIFT_ALWAYS_INLINE
653+
void incrementWeakRefCount() { weakBits++; }
663654

664-
LLVM_ATTRIBUTE_ALWAYS_INLINE
665-
bool decrementWeakRefCount() {
666-
assert(weakBits > 0);
667-
weakBits--;
668-
return weakBits == 0;
655+
SWIFT_ALWAYS_INLINE
656+
bool decrementWeakRefCount() {
657+
assert(weakBits > 0);
658+
weakBits--;
659+
return weakBits == 0;
669660
}
670661

671-
LLVM_ATTRIBUTE_ALWAYS_INLINE
662+
SWIFT_ALWAYS_INLINE
672663
uint32_t getWeakRefCount() {
673664
return weakBits;
674665
}
675666

676667
// Side table ref count never has a side table of its own.
677-
LLVM_ATTRIBUTE_ALWAYS_INLINE
668+
SWIFT_ALWAYS_INLINE
678669
bool hasSideTable() {
679670
return false;
680671
}
@@ -882,22 +873,22 @@ class RefCounts {
882873

883874
// Decrement the reference count.
884875
// Return true if the caller should now deinit the object.
885-
LLVM_ATTRIBUTE_ALWAYS_INLINE
876+
SWIFT_ALWAYS_INLINE
886877
bool decrementShouldDeinit(uint32_t dec) {
887878
return doDecrement<DontPerformDeinit>(dec);
888879
}
889880

890-
LLVM_ATTRIBUTE_ALWAYS_INLINE
881+
SWIFT_ALWAYS_INLINE
891882
bool decrementShouldDeinitNonAtomic(uint32_t dec) {
892883
return doDecrementNonAtomic<DontPerformDeinit>(dec);
893884
}
894885

895-
LLVM_ATTRIBUTE_ALWAYS_INLINE
886+
SWIFT_ALWAYS_INLINE
896887
void decrementAndMaybeDeinit(uint32_t dec) {
897888
doDecrement<DoPerformDeinit>(dec);
898889
}
899890

900-
LLVM_ATTRIBUTE_ALWAYS_INLINE
891+
SWIFT_ALWAYS_INLINE
901892
void decrementAndMaybeDeinitNonAtomic(uint32_t dec) {
902893
doDecrementNonAtomic<DoPerformDeinit>(dec);
903894
}
@@ -1472,9 +1463,9 @@ class HeapObjectSideTableEntry {
14721463
// This version can actually be non-atomic.
14731464
template <>
14741465
template <PerformDeinit performDeinit>
1475-
LLVM_ATTRIBUTE_ALWAYS_INLINE
1476-
inline bool RefCounts<InlineRefCountBits>::doDecrementNonAtomic(uint32_t dec) {
1477-
1466+
SWIFT_ALWAYS_INLINE inline bool
1467+
RefCounts<InlineRefCountBits>::doDecrementNonAtomic(uint32_t dec) {
1468+
14781469
// We can get away without atomicity here.
14791470
// The caller claims that there are no other threads with strong references
14801471
// to this object.

stdlib/public/runtime/AnyHashableSupport.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "swift/Runtime/Config.h"
13+
#include "../SwiftShims/Visibility.h"
14+
#include "Private.h"
15+
#include "SwiftHashableSupport.h"
16+
#include "SwiftValue.h"
1417
#include "swift/Basic/Lazy.h"
18+
#include "swift/Runtime/Casting.h"
1519
#include "swift/Runtime/Concurrent.h"
20+
#include "swift/Runtime/Config.h"
1621
#include "swift/Runtime/Debug.h"
1722
#include "swift/Runtime/HeapObject.h"
18-
#include "swift/Runtime/Casting.h"
19-
#include "Private.h"
20-
#include "SwiftValue.h"
21-
#include "SwiftHashableSupport.h"
2223

2324
using namespace swift;
2425
using namespace swift::hashable_support;
@@ -72,9 +73,9 @@ struct HashableConformanceEntry {
7273
static ConcurrentMap<HashableConformanceEntry, /*Destructor*/ false>
7374
HashableConformances;
7475

75-
template<bool KnownToConformToHashable>
76-
LLVM_ATTRIBUTE_ALWAYS_INLINE
77-
static const Metadata *findHashableBaseTypeImpl(const Metadata *type) {
76+
template <bool KnownToConformToHashable>
77+
SWIFT_ALWAYS_INLINE static const Metadata *
78+
findHashableBaseTypeImpl(const Metadata *type) {
7879
// Check the cache first.
7980
if (HashableConformanceEntry *entry =
8081
HashableConformances.find(HashableConformanceKey{type})) {

0 commit comments

Comments
 (0)