Skip to content

Fix LoadableByAddress to use @in_guaranteed for unowned values and enable SIL verification for on-stack partial_apply ownership #67907

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

Merged
merged 2 commits into from
Aug 13, 2023

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Aug 12, 2023

LoadableByAddress was accidentally changing ownership of
direct_unowned values to @in (owned). This generates unsupported SIL
for on-stack partial applies, which now breaks SIL verification.

This also resulted in extra copies of values inside of closure
contexts. Before calling the original function, the value would need to
be copied onto the stack and the context would be destroyed. Now, we
simply pass a pointer directly from the closure context. See
IRGen/indirect_argument.sil+huge_partial_application.

I'm pretty sure fixing this has no effect on the mangling of public symbols.

@atrick atrick force-pushed the verify-onstack-capture branch from 3e391a3 to 9300c95 Compare August 12, 2023 19:40
@atrick
Copy link
Contributor Author

atrick commented Aug 12, 2023

@swift-ci test

@atrick
Copy link
Contributor Author

atrick commented Aug 12, 2023

@swift-ci benchmark

@atrick
Copy link
Contributor Author

atrick commented Aug 12, 2023

@swift-ci test source compatibility

Copy link
Contributor

@nate-chandler nate-chandler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@atrick
Copy link
Contributor Author

atrick commented Aug 12, 2023

I'm waiting for the source compat test to finish before committing the fix for AutoDiff/IRGen/loadable_by_address.swift. Unfortunately, that test was disabled on arm64.

@atrick
Copy link
Contributor Author

atrick commented Aug 12, 2023

This PR has no significant effect on existing benchmarks. I did not attempt to create a benchmark for the improvement that eliminates copies from the closure context.

atrick added 2 commits August 12, 2023 21:21
LoadableByAddress was accidentally changing ownership of
direct_unowned values to @in (owned). This generates unsupported SIL
for on-stack partial applies, which now breaks SIL verification.

This also resulted in extra copies of values inside of closure
contexts. Before calling the original function, the value would need to
be copied onto the stack and the context would be destroyed. Now, we
simply pass a pointer directly from the closure context.  See
IRGen/indirect_argument.sil+huge_partial_application.

I'm pretty sure fixing this has no effect on the mangling of public symbols.
@atrick atrick force-pushed the verify-onstack-capture branch from 9300c95 to f2287b9 Compare August 13, 2023 04:21
@atrick
Copy link
Contributor Author

atrick commented Aug 13, 2023

@swift-ci test

@atrick atrick merged commit 3113e83 into swiftlang:main Aug 13, 2023
@atrick atrick deleted the verify-onstack-capture branch August 13, 2023 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants