Skip to content

Commit bc68d51

Browse files
committed
Use the preserve_most calling convention for the increment slow path
This improves x86-64 code generation to not having any stack operations on the fast path.
1 parent 3ae6d7c commit bc68d51

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

include/swift/Runtime/Config.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,15 @@
190190

191191
#endif
192192

193+
// The runtime implementation uses the preserve_most convention to save
194+
// registers spills on the hot path.
195+
#if __has_attribute(preserve_most) && \
196+
(defined(__aarch64__) || defined(__x86_64__))
197+
#define SWIFT_CC_PreserveMost __attribute__((preserve_most))
198+
#else
199+
#define SWIFT_CC_PreserveMost
200+
#endif
201+
193202
// Generates a name of the runtime entry's implementation by
194203
// adding an underscore as a prefix and a suffix.
195204
#define SWIFT_RT_ENTRY_IMPL(Name) _##Name##_

stdlib/public/SwiftShims/RefCount.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ class RefCounts {
742742
// Out-of-line slow paths.
743743

744744
LLVM_ATTRIBUTE_NOINLINE
745-
void incrementSlow(RefCountBits oldbits, uint32_t inc);
745+
void incrementSlow(RefCountBits oldbits, uint32_t inc) SWIFT_CC(PreserveMost);
746746

747747
LLVM_ATTRIBUTE_NOINLINE
748748
void incrementNonAtomicSlow(RefCountBits oldbits, uint32_t inc);

0 commit comments

Comments
 (0)