-
Notifications
You must be signed in to change notification settings - Fork 10.5k
runtime: return the argument from swift_retain family of functions #11986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: return the argument from swift_retain family of functions #11986
Conversation
@swift-ci Please test |
Build failed |
Can you add a little note in the commit message for 11b65c5 stating something along the lines of: We used to perform this optimization via an optimization pass. This was ripped out some time ago in commit XXXX. Now by putting this attribute on swift_retain *, we get the same optimization for free via the backend register allocator. |
693957d
to
372fd79
Compare
@swift-ci Please test |
Build failed |
Build failed |
On architectures where the calling convention uses the same argument register as return register this allows the argument register to be live through the calls. We use LLVM's 'returned' attribute on the parameter to facilitate this. We used to perform this optimization via an optimization pass. This was ripped out some time ago around commit 955e4ed. By using LLVM's 'returned' attribute on swift_*retain, we get the same optimization from the LLVM backend.
This improves x86-64 code generation to not having any stack operations on the fast path.
372fd79
to
bc68d51
Compare
@swift-ci Please test |
Build failed |
Build failed |
Yay! |
On architectures where the calling convention uses the same argument register as
return register this allows the argument register to be live through the calls. It also enables tail calls to be optimized in functions that call swift_retain as the last thing and return its argument.