-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SILOptimizer] Add deinit-barrier side-effect. #61495
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
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
95a441b
to
33f71f7
Compare
33f71f7
to
2c90ce5
Compare
4dc3dcf
to
6cb48bc
Compare
@swift-ci please test |
eeckstein
requested changes
Oct 17, 2022
SwiftCompilerSources/Sources/Optimizer/Analysis/CalleeAnalysis.swift
Outdated
Show resolved
Hide resolved
SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ComputeSideEffects.swift
Outdated
Show resolved
Hide resolved
e1ec516
to
9fbd4cb
Compare
@swift-ci please test |
eeckstein
approved these changes
Oct 18, 2022
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.
nice!
lgtm
ccf9a6b
to
21bca72
Compare
Added new C++-to-Swift callback for isDeinitBarrier. And pass it CalleeAnalysis so it can depend on function effects. For now, the argument is ignored. And, all callers just pass nullptr. Promoted to API the mayAccessPointer component predicate of isDeinitBarrier which needs to remain in C++. That predicate will also depends on function effects. For that reason, it too is now passed a BasicCalleeAnalysis and is moved into SILOptimizer. Also, added more conservative versions of isDeinitBarrier and maySynchronize which will never consider side-effects.
Functions "are deinit barriers" (more pedantically, applies of functions are deinit barriers) if any of their instructions are deinit barriers. During side-effect analysis, when walking a function's instructions for other global effects, also check for the deinit-barrier effect. If an instruction is found to be a deinit barrier, mark the function's global effects accordingly. Add SILFunction::isDeinitBarrier to conveniently access the effects computed during ComputeSideEffects. Update the isBarrierApply predicate to iterate over the list of callees, if complete, to check whether any is a deinit barrier. If none is, then the apply is not a deinit barrier.
Checked that applies of empty functions, or their callees, or their callees' callees, are not deinit barriers. Checked that applies of unknown functions, or their callees, or their callees' calles, are deinit barriers.
Pass a BasicCalleeAnalysis instance to isDeinitBarrier. This will enable SSADestroyHoisting to hoist destroy_addrs over applies of functions that are not themselves deinit barriers.
Pass a BasicCalleeAnalysis instance to isDeinitBarrier. This will allow ShrinkBorrowScope to hoist end_borrows over applies of functions which are not deinit barriers.
Pass a BasicCalleeAnalysis instance to isDeinitBarrier. This enables LexicalDestroyHoisting to hoist destroys over applies of functions which are not deinit barriers.
21bca72
to
4b85d0a
Compare
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please benchmark |
@swift-ci please clean test macOS platform |
1 similar comment
@swift-ci please clean test macOS platform |
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.
Computed whether a function counts as a deinit barrier during ComputeSideEffects. Hoisted
destroy_addr
s of lexical addresses,destroy_value
s of owned lexical values, andend_borrow
s of lexicalbegin_borrow
s over applies of functions which are not deinit barriers.