-
Notifications
You must be signed in to change notification settings - Fork 14k
Separate dataflow analysis and results #140234
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
Separate dataflow analysis and results #140234
Conversation
Every `Results` contains an `Analysis`, but these methods only need the `Analysis`. No point passing them more data than they need.
`Results` contains and `Analysis` and an `EntryStates`. The unfortunate thing about this is that the analysis needs to be mutable everywhere (`&mut Analysis`) which forces the `Results` to be mutable everywhere, even though `EntryStates` is immutable everywhere. To fix this, this commit renames `Results` as `AnalysisAndResults`, renames `EntryStates` as `Results`, and separates the analysis and results as much as possible. (`AnalysisAndResults` doesn't get much use, it's mostly there to facilitate method chaining of `iterate_to_fixpoint`.) `Results` is immutable everywhere, which: - is a bit clearer on how the data is used, - avoids an unnecessary clone of entry states in `locals_live_across_suspend_points`, and - moves the results outside the `RefCell` in Formatter. The commit also reformulates `ResultsHandle` as the generic `CowMut`, which is simpler than `ResultsHandle` because it doesn't need the `'tcx` lifetime and the trait bounds. It also which sits nicely alongside the new use of `Cow` in `ResultsCursor`.
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt The rustc-dev-guide subtree was changed. If this PR only touches the dev guide consider submitting a PR directly to rust-lang/rustc-dev-guide otherwise thank you for updating the dev guide with your changes. |
|
@Jarcho: I hope this doesn't interfere with the uncommitted clippy analyses that you have. From our previous conversation, they required |
|
This doesn't look like it will interfere with anything I have. |
|
@bors r+ Apologies for the delay in getting to this |
…llaumeGomez Rollup of 8 pull requests Successful merges: - rust-lang#140234 (Separate dataflow analysis and results) - rust-lang#140614 (Correct warning message in restricted visibility) - rust-lang#140671 (Parser: Recover error from named params while parse_path) - rust-lang#140700 (Don't crash on error codes passed to `--explain` which exceed our internal limit of 9999 ) - rust-lang#140706 ([rustdoc] Ensure that temporary doctest folder is correctly removed even if doctests failed) - rust-lang#140734 (Fix regression from rust-lang#140393 for espidf / horizon / nuttx / vita) - rust-lang#140741 (add armv5te-unknown-linux-gnueabi target maintainer) - rust-lang#140745 (run-make-support: set rustc dylib path for cargo wrapper) r? `@ghost` `@rustbot` modify labels: rollup
…llaumeGomez Rollup of 8 pull requests Successful merges: - rust-lang#140234 (Separate dataflow analysis and results) - rust-lang#140614 (Correct warning message in restricted visibility) - rust-lang#140671 (Parser: Recover error from named params while parse_path) - rust-lang#140700 (Don't crash on error codes passed to `--explain` which exceed our internal limit of 9999 ) - rust-lang#140706 ([rustdoc] Ensure that temporary doctest folder is correctly removed even if doctests failed) - rust-lang#140734 (Fix regression from rust-lang#140393 for espidf / horizon / nuttx / vita) - rust-lang#140741 (add armv5te-unknown-linux-gnueabi target maintainer) - rust-lang#140745 (run-make-support: set rustc dylib path for cargo wrapper) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#140234 - nnethercote:separate-Analysis-and-Results, r=davidtwco Separate dataflow analysis and results `Analysis` gets put into `Results` with `EntryStates`, by `iterate_to_fixpoint`. This has two problems: - `Results` is passed various places where only `Analysis` is needed. - `EntryStates` is passed around mutably everywhere even though it is immutable. This commit mostly separates `Analysis` from `Results` and fixes these two problems. r? `@davidtwco`
`Results` used to contain an `Analysis`, but it was removed in rust-lang#140234. That change made sense because the analysis was mutable but the entry states were immutable and it was good to separate them so the mutability of the different pieces was clear. Now that analyses are immutable there is no need for the separation, lots of analysis+results pairs can be combined, and the names are going back to what they were before: - `Results` -> `EntryStates` - `AnalysisAndResults` -> `Results`
Analysisgets put intoResultswithEntryStates, byiterate_to_fixpoint. This has two problems:Resultsis passed various places where onlyAnalysisis needed.EntryStatesis passed around mutably everywhere even though it is immutable.This commit mostly separates
AnalysisfromResultsand fixes these two problems.r? @davidtwco