Skip to content

Filling out the PrunedLiveness utility for composition with other OSSA utilities #39577

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

Merged
merged 6 commits into from
Oct 6, 2021

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Oct 4, 2021

This small collection of liveness utilities each does one only thing and makes no unnecessary assumptions about the client.

It is meant to compose cleanly with other utilities. It is flexible enough to represent any SIL lifetime or scope, characterized by a set of dominating points. It can handle a lifetime or scope with multiple SSA values just as efficiently as it handles a single SSA value.

All of the above makes it extremely useful as a building block for simple and efficient OSSA utilities.

This will also allow CanonicalOSSALifetime (CopyPropagation) to be cleaned up and extended for other purposes. It was originally meant to do only one thing, but now has logic for multiple modes embedded within it and would need callbacks for diagnostics. Instead the OSSA analysis and "copy propagation" logic need to be decoupled.

@atrick
Copy link
Contributor Author

atrick commented Oct 4, 2021

@swift-ci smoke test

@atrick atrick force-pushed the liveness-boundary branch 2 times, most recently from ab47212 to 5e4ae6a Compare October 5, 2021 16:49
@atrick
Copy link
Contributor Author

atrick commented Oct 5, 2021

@swift-ci smoke test

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

atrick added 6 commits October 6, 2021 09:23
A perfectly straightforward liveness check. Used by OSSA utilities to
check that an instruction is within a lifetime or scope.
Simple wrapper to compute the boundary of PrunedLiveness.

Pervasively useful utility for working with OSSA reference lifetimes
and borrow scopes.

This can also replace the implementation in
CanonicalOSSALifetime. This will greatly simplify that utility's
logic, preparing it to handle diagnostics (like move-only SILValue
checking) and other features.
Straighforward API to build pruned liveness from a single SSA value.

This 3-line function allows PrunedLiveness to be used anywhere
ValueLifetimeAnalysis was used in OSSA form. Aside from simplicity and
efficiency, the difference is that this composes with other utilities
that only care about PrunedLiveBlocks, PrunedLiveness, or
PrunesLivenessBounary independent of how those data structures were generated.
Given a computed ValueLifetimeBoundary, visit all the points at which
the lifetime needs to be terminated, e.g. via and end_borrow or
destroy_value.

Especially useful for creating a borrow scope over guaranteed uses.

This completely decouples the DeadBlocks analysis from the liveness
analysis.

It will allow phasing out the complex and bug-prone
ValueLifetimeAnalysis::Frontier API.
@atrick atrick force-pushed the liveness-boundary branch from 5e4ae6a to 1bb27f6 Compare October 6, 2021 16:23
@atrick
Copy link
Contributor Author

atrick commented Oct 6, 2021

@swift-ci smoke test and merge

@swift-ci swift-ci merged commit 60dc24b into swiftlang:main Oct 6, 2021
@atrick atrick deleted the liveness-boundary branch October 6, 2021 20:03
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.

3 participants