-
Notifications
You must be signed in to change notification settings - Fork 10.5k
OSSA utility incremental redesign and SILCombine fixes #39740
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 |
@swift-ci test source compatibility |
@swift-ci benchmark |
Performance (x86_64): -O
Code size: -O
Performance (x86_64): -Osize
Code size: -Osize
Performance (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
|
@swift-ci test |
@swift-ci test source compatibility |
Build failed |
@swift-ci test source compatibility |
This passed SCK with OME running before Mem2Reg |
Preparation for rewriting non-trivial terminators and generalizing support for guaranteed phis. Add guaranteedUsePoints to the RAUW context. This will replace ALL existing context book-keeping once the old code is deleted. Introduce a borrowCopyOverScope entry point to handle extending lifetime over a BorrowedValue. This simply uses the BorrowedLifetimeExtender. Introduce higher-level APIs: - borrowOverValue to extened over a guaranteedValue - borrowOverSingleUse to extened over a single guaranteed use These replace both createPlusZeroBorrow and createPlusOneBorrow. Update RAUW-ctor, RAUW::handleUnowned, and replaceAddressUses to use the new API. Restructure RAUW::canFixUpOwnershipForRAUW. Simply use findInnerTransitiveGuaranteedUses. Replace RAUW::handleGuaranteed and rewriteReborrows with OLE::borrowOverValue. Use the BorrowedLifetimeExtender utility to handle all situations correctly. TODO: createPlusOneBorrow can be completely removed, and a massive amount of confusing/incomplete code can be deleted in a follow-up commit.
Required to fix SILCombine. Divide the logic into smaller pieces. This allows passes to check for replaceability before generating the replacement value. Preparation for simplifying OSSA utilities into smaller logical components making them flexibile and allowing improvements to be staged in.
Avoid generating useless empty copies and borrow scopes. Bypass all the use-checking logic when there are no uses to avoid special cases and bugs.
These SILCombine patterns produce new instructions that use the the original value after it is updated for OSSA. The RAUW utility needs to copy/borrow the original value before SILCombine can generate the new replacement. Then SILCombine can pass that replacement back to RAUW to perform the final replaceAllUsesWith. 1. PointerToAddress and RawPointerToRef Fixes bugs where RAUW inserts borrows in the wrong place. 2. UncheckedBitwiseCast The OSSA RAUW helper is incorrect here for producing a new UncheckedRefCast. Simply don't use it. Since a bitwise cast is an "Unowned" pointer escape, simply convert the unchecked_bitwise_cast opcode to unchecked_ref_cast with Unowned forwarding ownership. 3. ConvertFunction Make sure RAUW is never called with a replacement value that has different ownership than the original.
@swift-ci smoke test |
This PR significantly affects functionality. These commits are functionally interdependent. Improving the utilities exposes SILCombine bugs, and utility needs to be updated to fix SILCombine.
The main functional change is:
Migrate to OwnershipLifetimeExtender API: borrowCopyOverScope, etc.
Preparation for rewriting non-trivial terminators and generalizing
support for guaranteed phis.
Add guaranteedUsePoints to the RAUW context. This will replace ALL
existing context book-keeping once the old code is deleted.
Introduce a borrowCopyOverScope entry point to handle extending
lifetime over a BorrowedValue. This simply uses the
BorrowedLifetimeExtender.
Introduce higher-level APIs:
These replace both createPlusZeroBorrow and createPlusOneBorrow.
Update RAUW-ctor, RAUW::handleUnowned, and replaceAddressUses to use
the new API.
Restructure RAUW::canFixUpOwnershipForRAUW. Simply use
findInnerTransitiveGuaranteedUses.
Replace RAUW::handleGuaranteed and rewriteReborrows with
OLE::borrowOverValue.
Use the BorrowedLifetimeExtender utility to handle all situations
correctly.
This exposes SILCombine issues.
In order to fix SILCombine, make the RAUW interface more flexible.
Divide the RAUW logic into smaller pieces. This allows passes to check for
replaceability before generating the replacement value.