-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SILGen] Used move_value for more lexical values. #64789
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
nate-chandler
merged 16 commits into
swiftlang:main
from
nate-chandler:more-move-values
Dec 15, 2023
Merged
[SILGen] Used move_value for more lexical values. #64789
nate-chandler
merged 16 commits into
swiftlang:main
from
nate-chandler:more-move-values
Dec 15, 2023
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0f71dd2
to
53ca82e
Compare
b23cd42
to
17e2901
Compare
e87df13
to
88143d7
Compare
88143d7
to
6bce7c0
Compare
6ce0374
to
2328b36
Compare
2328b36
to
a32f2dd
Compare
8cdaf78
to
71107fb
Compare
71107fb
to
46632f2
Compare
Replace the pattern of begin_borrow [lexical] + copy_value with move_value [lexical] to avoid introducing a spurious copy to begin with.
Used the main body of the function for the "normal" path.
Instead of using begin_borrow [lexical] + copy_value.
Now that SILGen almost always represents a lexical lifetime with move_value [lexical] the fact that the checker doesn't consider such lifetimes is exposed. Fix it to look for such lifetimes.
46632f2
to
72ff0ae
Compare
@swift-ci please test |
@swift-ci please apple silicon benchmark |
@swift-ci please test source compatibility |
Let's lock in the representation change now. The forthcoming owned forwarding copy canonicalization will eliminate the few minor regressions this introduces:
|
nate-chandler
added a commit
to nate-chandler/swift
that referenced
this pull request
Dec 16, 2023
Run OSLogMandatoryOptTest.swift only in configurations with release stdlibs. swiftlang#64789 introduced a simple but widespread change to SIL. It required updating a number of tests. The updates primarily involved replacing `begin_borrow` + `copy_value` with `move_value` instructions. In particular, OSLogMandatoryOptTest.swift had to be updated as well: several new `move_value` instructions had to be FileCheck'd. These instructions all came from inlining code from the OSLogTestHelper target, a target which is built in the same configuration as the stdlib. In fact, they all came from inlining the `_osLogTestHelper(_:assertion:)` function. When building OSLogTestHelper for release, no optimization passes are run on the function because it is marked `@_optimize(none)`. `SemanticARCOpts` would have deleted these `move_value`s, but it doesn't run on the function. When building OSLogTestHelper for debug, however, `MandatoryARCOpts` (a subset of `SemanticARCOpts`) _does_ run despite the function being marked `@_optimize(none)`. That's because it's part of the `OnonePassPipeline` which is mandatory, meaning that every pass runs on each function, regardless of it being annotated `@_optimize(none)`. As a result the `move_value` instructions--which FileCheck lines were added to match--are deleted before FileCheck runs. So the new check lines fail to match the deleted instructions. Besides the absence of these new `move_value` instructions, there is no difference between the function in debug vs release. In particular, removing the newly added check lines allows the test to pass in a configuration with a debug stdlib. Rather than duplicate the test for debug configurations, just disable it in them. rdar://119744393
meg-gupta
pushed a commit
to meg-gupta/swift
that referenced
this pull request
Dec 21, 2023
Run OSLogMandatoryOptTest.swift only in configurations with release stdlibs. swiftlang#64789 introduced a simple but widespread change to SIL. It required updating a number of tests. The updates primarily involved replacing `begin_borrow` + `copy_value` with `move_value` instructions. In particular, OSLogMandatoryOptTest.swift had to be updated as well: several new `move_value` instructions had to be FileCheck'd. These instructions all came from inlining code from the OSLogTestHelper target, a target which is built in the same configuration as the stdlib. In fact, they all came from inlining the `_osLogTestHelper(_:assertion:)` function. When building OSLogTestHelper for release, no optimization passes are run on the function because it is marked `@_optimize(none)`. `SemanticARCOpts` would have deleted these `move_value`s, but it doesn't run on the function. When building OSLogTestHelper for debug, however, `MandatoryARCOpts` (a subset of `SemanticARCOpts`) _does_ run despite the function being marked `@_optimize(none)`. That's because it's part of the `OnonePassPipeline` which is mandatory, meaning that every pass runs on each function, regardless of it being annotated `@_optimize(none)`. As a result the `move_value` instructions--which FileCheck lines were added to match--are deleted before FileCheck runs. So the new check lines fail to match the deleted instructions. Besides the absence of these new `move_value` instructions, there is no difference between the function in debug vs release. In particular, removing the newly added check lines allows the test to pass in a configuration with a debug stdlib. Rather than duplicate the test for debug configurations, just disable it in them. rdar://119744393
Catfish-Man
pushed a commit
to Catfish-Man/swift
that referenced
this pull request
Jan 19, 2024
Run OSLogMandatoryOptTest.swift only in configurations with release stdlibs. swiftlang#64789 introduced a simple but widespread change to SIL. It required updating a number of tests. The updates primarily involved replacing `begin_borrow` + `copy_value` with `move_value` instructions. In particular, OSLogMandatoryOptTest.swift had to be updated as well: several new `move_value` instructions had to be FileCheck'd. These instructions all came from inlining code from the OSLogTestHelper target, a target which is built in the same configuration as the stdlib. In fact, they all came from inlining the `_osLogTestHelper(_:assertion:)` function. When building OSLogTestHelper for release, no optimization passes are run on the function because it is marked `@_optimize(none)`. `SemanticARCOpts` would have deleted these `move_value`s, but it doesn't run on the function. When building OSLogTestHelper for debug, however, `MandatoryARCOpts` (a subset of `SemanticARCOpts`) _does_ run despite the function being marked `@_optimize(none)`. That's because it's part of the `OnonePassPipeline` which is mandatory, meaning that every pass runs on each function, regardless of it being annotated `@_optimize(none)`. As a result the `move_value` instructions--which FileCheck lines were added to match--are deleted before FileCheck runs. So the new check lines fail to match the deleted instructions. Besides the absence of these new `move_value` instructions, there is no difference between the function in debug vs release. In particular, removing the newly added check lines allows the test to pass in a configuration with a debug stdlib. Rather than duplicate the test for debug configurations, just disable it in them. rdar://119744393
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use it rather than
begin_borrow [lexical]
andcopy_value
. Allows for more aggressive lifetime optimization.