-
Notifications
You must be signed in to change notification settings - Fork 10.5k
SIL optimizer: remove unbalanced retains/releases from immortal objects #38973
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 |
6e06be5
to
b5d32b9
Compare
@swift-ci test |
Build failed |
Build failed |
return isNotReferenceCounted(value: urc.operand, context: context) | ||
case is GlobalValueInst: | ||
// Since Swift 5.1, statically allocated objects have "immortal" reference | ||
// counts. Therefore we can savely eliminate unbalaced retains and |
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.
// counts. Therefore we can savely eliminate unbalaced retains and | |
// counts. Therefore we can safely eliminate unbalaced retains and |
And add `UnaryInstruction` which adds a property `operand` to all unary instructions. This replaces the existing single-operand properties, which simplifies the code.
* unify FunctionPassContext and InstructionPassContext * add a modification API: PassContext.setOperand * automatic invalidation notifications when the SIL is modified
ARC operations don't have an effect on immortal objects, like the empty array singleton or statically allocated arrays. Therefore we can freely remove and retain/release instructions on such objects, even if there is no paired balanced ARC operation. This optimization can only be done with a minimum deployment target of Swift 5.1, because in that version we added immortal ref count bits. The optimization is implemented in libswift. Additionally, the remaining logic of simplifying strong_retain and strong_release is also ported to libswift. rdar://81482156
b5d32b9
to
8be0ca0
Compare
@swift-ci test |
@swift-ci benchmark |
Performance (x86_64): -O
Code size: -OPerformance (x86_64): -Osize
Code size: -OsizePerformance (x86_64): -Onone
Code size: -swiftlibsHow to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
Build failed |
@swift-ci test macOS |
ARC operations don't have an effect on immortal objects, like the empty array singleton or statically allocated arrays.
Therefore we can freely remove and retain/release instructions on such objects, even if there is no paired balanced ARC operation.
This optimization can only be done with a minimum deployment target of Swift 5.1, because in that version we added immortal ref count bits.
The optimization is implemented in libswift. Additionally, the remaining logic of simplifying strong_retain and strong_release is also ported to libswift.
This PR also includes some infrastructure improvements in libswift. For details see the commit list.
rdar://81482156