-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix store_borrow generation and improve its verification #60467
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
fcec851
to
45b2a18
Compare
TODO: A utility to insert end_borrows for store_borrows |
@swift-ci test |
@swift-ci source compatibility test |
45b2a18
to
f65817e
Compare
@swift-ci test source compatibility |
f65817e
to
fd2e0b1
Compare
@swift-ci smoke test |
ebc16ba
to
5b500b1
Compare
@swift-ci test |
@swift-ci benchmark |
@swift-ci test source compatibility |
5b500b1
to
f160e32
Compare
@swift-ci test |
f160e32
to
da05282
Compare
A couple things to follow up on Add the verifier tests cases. Make sure we have one for nested scopes: store borrow within load borrow within store borrow TODO: GenericCloner should insert end_borrows at the function exit points The ScopedAddressOperand/ScopedAddressValue utilities can be merged into a single ScopedAddress utility Probably no longer need the Don't need some new "use-specific" utilities |
d3ea0f2
to
56f1c55
Compare
This change ensures all store_borrows are ended with an end_borrow, and uses of the store_borrow destination are all in the enclosing store_borrow scope and via the store_borrow return address. Fix tests to reflect new store_borrow pattern
Add ScopedAddressOperand and ScopedAddressValue abstraction utilities Introduce verification for store_borrow to validate its uses are correctly enclosed in their scope. Include end_borrow/end_access as implicit uses while validating a borrow introducer Add flow sensitive verifier rule for store_borrow/end_borrow pair Make sure store_borrow is always to an alloc_stack Make sure uses to store borrow location are via its return address only
…rship Map store_borrow return_address with the destination, so that while cloning a store_borrow into a function w/o ownership, users of store_borrow return address can be mapped with the lowered store's destination.
…be trivially deleted
Update the store_borrow pattern to correctly propagate Varied
56f1c55
to
be6be7f
Compare
@swift-ci test |
be6be7f
to
f374f2b
Compare
@swift-ci test and merge |
@meg-gupta It seems that https://github.com/apple/swift/blob/main/docs/SIL.rst#store-borrow should be modified as well to outline the semantics of returned value of |
Apparently #60467 changed the semantics of store_borrow as it started to produce a value. This change was not documented in SIL spec and not all places were updated to new semantics. Now the adjoint of store_borrow should be generated for the value of instruction itself, not the destination address
This change makes SILGen, SILOptimizer and SILVerifier changes to ensure all store_borrows are ended with an end_borrow, and uses of the store_borrow destination are all in the enclosing store_borrow scope and are via the store_borrow return address.