Skip to content

[SSADestroyHoisting] Fold into sequences. #41841

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

nate-chandler
Copy link
Contributor

Make loads and copy_addrs of casts of the underlying storage barriers to folding. Destroying the target address may not be equivalent to destroying the source address: for example, if the target address is a generic and the source address is AnyObject, specialization may turn the generic into a trivial type; the destruction of that trivial type fails to destroy the original stored AnyObject, resulting in a leak.

[SSADestroyHoisting] Fold into sequences.

Previously, destroy_addrs were folded into copy_addrs and load [copy]s to produce copy_addr [take]s and load [take]s respectively, but only if the source of the load/copy was exactly the address being destroyed.

Generalize that to a single-block sequence of copy_addrs and load [copy]s of projections of the address being destroyed.

Only respect deinit barriers when lexical lifetimes are enabled.  If
they aren't, hoist destroy_addrs of all addresses aggressively
regardless of whether doing so involves hoisting over deinit barriers.
Previously, destroy_addrs were folded into copy_addrs and load [copy]s
to produce copy_addr [take]s and load [take]s respectively, but only if
the source of the load/copy was exactly the address being destroyed.

Generalize that to a single-block sequence of copy_addrs and load
[copy]s of projections of the address being destroyed.
Make loads and copy_addrs of casts of the underlying storage barriers to
folding.  Destroying the target address may not be equivalent to
destroying the source address: for example, if the target address is a
generic and the source address is AnyObject, specialization may turn the
generic into a trivial type; the destruction of that trivial type fails
to destroy the original stored AnyObject, resulting in a leak.
@nate-chandler nate-chandler requested a review from atrick March 16, 2022 19:01
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler
Copy link
Contributor Author

@swift-ci please test linux platform

@nate-chandler
Copy link
Contributor Author

@swift-ci please test source compatibility

@nate-chandler
Copy link
Contributor Author

@swift-ci please test source compatibility debug

@nate-chandler
Copy link
Contributor Author

@swift-ci please test linux

@nate-chandler
Copy link
Contributor Author

Source compatibility failures are spurious:

sandbox-exec: <internal init prelude>:456:12: unable to open system.sb: not found
        (apply error x)

Merging.

@nate-chandler nate-chandler merged commit a6199cf into swiftlang:main Mar 17, 2022
@nate-chandler nate-chandler deleted the lexical_lifetimes/ssa-destroy-hoisting/fold-sequences branch March 17, 2022 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant