-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Several optimization improvements, mainly for begin_borrow, load and load_borrow
#86113
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
Open
eeckstein
wants to merge
13
commits into
swiftlang:main
Choose a base branch
from
eeckstein:simplify-load
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+440
−190
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
…orrow.swift and SimplifyLoadBorrow.swift
* rename `lookThroughSingleForwardingUses` -> `lookThroughOwnedConvertibaleForwardingChain` * fix the comment of `replaceGuaranteed`
When trying to remove a borrow scope by replacing all guaranteed uses with owned uses, don't bail for values which have debug_value uses. Also make sure that the debug_value instructions are located within the owned value's lifetime.
* remove borrow scopes which are borrowing an already guaranteed value * allow optimizing lexical `begin_borrows` outside the mandatory pipeline * fix: don't remove `begin_borrow [lexical]` of a `thin_to_thick_function` in the mandatory pipeline
…now covered by SimplifyBeginBorrow
…alue When taking the location from the builder's insertion point, we must make sure it's not a return location. Fixes an assertion failure. I found this during my work on simplifying borrow scopes
Replaces address casts of heap objects ``` %1 = unchecked_addr_cast %0 : $*SomeClass to $*OtherClass %2 = load [copy] %1 ``` with ref-casts of the loaded value ``` %1 = load [copy] %0 %2 = unchecked_ref_cast %1 : $SomeClass to $OtherClass ```
… with guaranteed ownership to to `tuple_extract`/`struct_extract`
By defining its own array structs, which are independent from objc interop. Also, the requires-line was wrong anyway. The test didn't run on macos either.
…hen changes are made When ownership is changed from owned to guaranteed, the enclosing values of a guaranteed value can change. Fixes a SIL verifier error.
08d411a to
516c10b
Compare
Contributor
Author
|
@swift-ci test |
Contributor
Author
|
@swift-ci apple silicon benchmark |
meg-gupta
reviewed
Dec 17, 2025
| return true | ||
| } | ||
|
|
||
| private func tryForwardStoreBorrow(_ context: SimplifyContext) { |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a unit test for store borrow forwarding?
| /// ``` | ||
| /// %1 = load [copy] %0 | ||
| /// %2 = unchecked_ref_cast %1 : $SomeClass to $OtherClass | ||
| /// ``` |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you comment why this transform is useful?
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.
debug_valueinbegin_borrowsimplificationbegin_borrowsoutside the mandatory pipelinedestructure_tuple/destructure_structwith guaranteed ownership to totuple_extract/struct_extractThe improvements for
begin_borrowsimplification allows to remove the now obsolete BorrowScope optimization from SemanticArcOpts.This PR also fixes a few small bugs which I run into while working on the optimizations:
begin_borrow [lexical]of athin_to_thick_functionin the mandatory pipelinedestroy_valueFor details see the commit messages