Skip to content

Clean up logic around live locals in generator analysis#71956

Merged
bors merged 9 commits into
rust-lang:masterfrom
ecstatic-morse:remove-requires-storage-analysis
May 22, 2020
Merged

Clean up logic around live locals in generator analysis#71956
bors merged 9 commits into
rust-lang:masterfrom
ecstatic-morse:remove-requires-storage-analysis

Conversation

@ecstatic-morse
Copy link
Copy Markdown
Contributor

@ecstatic-morse ecstatic-morse commented May 6, 2020

Resolves #69902. Requires #71893.

I've found it difficult to make changes in the logic around live locals in generator/transform.rs. It uses a custom dataflow analysis, MaybeRequiresStorage, that AFAICT computes whether a local is either initialized or borrowed. That analysis is using before effects, which we should try to avoid if possible because they are harder to reason about than ones only using the unprefixed effects. @pnkfelix has suggested removing "before" effects entirely to simplify the dataflow framework, which I might pursue someday.

This PR replaces MaybeRequiresStorage with a combination of the existing MaybeBorrowedLocals and a new MaybeInitializedLocals. MaybeInitializedLocals is just MaybeInitializedPlaces with a coarser resolution: it works on whole locals instead of move paths. As a result, I was able to simplify the logic in compute_storage_conflicts and locals_live_across_suspend_points.

This is not exactly equivalent to the old logic; some generators are now smaller than before. I believe this was because the old logic was too conservative, but I'm not as familiar with the constraints as the original implementers were, so I could be wrong. For example, I don't see a reason the size of the mixed_sizes future couldn't be 5K. It went from 7K to 6K in this PR.

r? @jonas-schievink @tmandry

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MaybeRequiresStorage for generators is not necessary

5 participants