-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[5.9][move-only] Fix SIL representation and SILOptimizer to preserve value deinits. #66357
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
Conversation
@swift-ci test |
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.
optimizer changes LGTM
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.
I think I found a potential problem inSILCombine's isTrivial
function
rdar://109863801 ([move-only] DCE removes drop_deinit, so user-defined deinitializers call themselves recursively at -O) (cherry picked from commit af49f62)
(cherry picked from commit cc0c44c)
drop_deinit ultimately only affects the semantics of its destroy_value. Avoid generating releases for destroys in which the deinit has been dropped. Instead, individually release the members. (cherry picked from commit a6f65f0)
drop_deinit only exists in ownership SIL. Remove IRGen support. A drop_deinit can only ever be destroyed or destructured. A destructure of a struct-with-deinit requires a drop_deinit operand. (cherry picked from commit 3efd122)
to MoveOnlyDeinitDevirtualization (cherry picked from commit 9855edd)
It is not needed for correctness and hides most of the deinit related optimizer bugs. (cherry picked from commit 84bee24)
Many basic SIL passes were silently deleting the struct deinit: - SROA - Mem2Reg - RLE - DSE - FunctionSignatureOpts - LowerAggregates Fixes rdar://109849028 ([move-only] LowerAggregateInstrs eliminates struct deinitialization) (cherry picked from commit 4a37b00)
(cherry picked from commit 1dcc240)
30fe52e
to
e2a6e00
Compare
@swift-ci test |
@swift-ci test |
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.
lgtm!
@swift-ci clean test macOS |
@swift-ci test |
Multiple code motion and ARC related passes were removing struct/enum deinits. Passes fixed include: - SILCombine - EarlyCodeMotion - ReleaseHoisting - *many* passes that rely on ARC analysis (RCIndentity) (cherry picked from commit 6756ed7)
Fix a special case in visitReleaseValueInst for enum-with-deinit. (cherry picked from commit 58f96a9)
MoveOnlyLoadableStruct should only lower to memberwise destroys if it has no deinit. (cherry picked from commit 986cd42)
(cherry picked from commit 14f5917)
The -Onone passes fail to remove struct_extract, so the CHECK lines will fail. (cherry picked from commit d55ca8a)
ca051cb
to
0fa4d98
Compare
@swift-ci test |
--- CCC ---
Explanation:
Many basic SIL passes were silently deleting the struct and enum deinits:
Major Changes:
Scope of Issue: In some cases, deinitialization would run recursively, hanging the system. In other cases, a struct's deinit would silently fail to run when the struct was a member within another type. In the most trivial cases, with no type composition, and earlier MoveOnlyDeinitInsertion pass was hiding the problem.
Risk: Low risk to regular copyable code. And non-copyable was already broken.
PR to main: [move-only] Fix SIL representation and SILOptimizer to preserve value deinits #66314
#66314
Reviewed By: Erik Eckstein and Joe Groff
Resolves:
rdar://109849028 ([move-only] LowerAggregateInstrs eliminates struct deinitialization)
rdar://109863801 ([move-only] DCE removes drop_deinit, so user-defined deinitializers call themselves recursively at -O)
rdar://110079028 ([move-only] Finish SIL support for drop_deinit)