-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
A single framework for gen-kill and generic dataflow problems #65672
A single framework for gen-kill and generic dataflow problems #65672
Conversation
☔ The latest upstream changes (presumably #65869) made this pull request unmergeable. Please resolve the merge conflicts. |
Ping from triage: |
Pinging from triage: |
e7116e1
to
97b88dd
Compare
This was discussed in the design meeting on Nov. 8 (rust-lang/compiler-team#202). The consensus was to move forward on a design similar to the prototype. I'll be actively working to finish this, hopefully with some input from the compiler team. |
d6c3959
to
df0d51b
Compare
9ce9240
to
75775ba
Compare
@bors try @rust-timer queue |
Awaiting bors try build completion |
[WIP] A single framework for gen-kill and generic dataflow problems This is the prototype implementation discussed in rust-lang/compiler-team#202. You can read a high-level description of it in [the proposal](https://hackmd.io/@39Qr_z9cQhasi25sGjmFnA/Skvd9rztS) for that design meeting. This would eventually supersede the existing `BitDenotation` interface. r? @ghost cc @rust-lang/compiler (esp. @eddyb and @pnkfelix)
☀️ Try build successful - checks-azure |
Queued 1e0b457 with parent 3f07f1c, future comparison URL. |
Finished benchmarking try commit 1e0b457, comparison URL. |
Okay, this now converts a commonly used dataflow analysis, I've triggered a perf run and the results look okay except for a slight regression in r? @pnkfelix cc @rust-lang/compiler (feel free to reassign) Here are the unresolved "details" questions from the design meeting that are pertinent to this PR along with my thoughts on each. We should resolve these questions before merging.
|
75775ba
to
c4cda32
Compare
@bors try @rust-timer queue |
Awaiting bors try build completion |
[WIP] A single framework for gen-kill and generic dataflow problems This is the prototype implementation discussed in rust-lang/compiler-team#202. You can read a high-level description of it in [the proposal](https://hackmd.io/@39Qr_z9cQhasi25sGjmFnA/Skvd9rztS) for that design meeting. This would eventually supersede the existing `BitDenotation` interface. r? @ghost cc @rust-lang/compiler (esp. @eddyb and @pnkfelix)
☀️ Try build successful - checks-azure |
I migrated the analyses used during borrow checking/drop elaboration to the new framework and perf seems good. I'm gonna try a few small optimizations I mentioned during the design meeting over on that PR as well. While doing the conversion, it became apparent that code would much be nicer if we continued the "builder" style all the way back to let flow_inits = MaybeInitializedPlaces::new(tcx, &body, &mdpe);
let mut flow_inits = dataflow::generic::Engine::new_gen_kill(tcx, &body, def_id, flow_inits)
.iterate_to_fixpoint()
.into_cursor(&body); could instead be written like this: let mut flow_inits = MaybeInitializedPlaces::new(tcx, &body, &mdpe)
.into_engine(tcx, &body, def_id)
.iterate_to_fixpoint()
.into_cursor(&body); Another idea was to add I think it will take a few revisions to find the optimal API, and this PR has been sitting in the queue for a while, so I think we should not block it on making a decision re: the aforementioned changes. For now I'm focused on resolving any outstanding concerns of @pnkfelix. |
1b8a726
to
d7a521d
Compare
d7a521d
to
7b4dca2
Compare
@pnkfelix I addressed the motivation for the |
Thanks @ecstatic-morse ! |
@bors r+ |
📌 Commit 7b4dca2 has been approved by |
A single framework for gen-kill and generic dataflow problems This is the prototype implementation discussed in rust-lang/compiler-team#202. You can read a high-level description of it in [the proposal](https://hackmd.io/@39Qr_z9cQhasi25sGjmFnA/Skvd9rztS) for that design meeting. This would eventually supersede the existing `BitDenotation` interface. r? @ghost cc @rust-lang/compiler (esp. @eddyb and @pnkfelix)
☀️ Test successful - checks-azure |
…ls, r=pnkfelix Migrate borrowck dataflow impls to new framework This uses rust-lang#65672 to implement the dataflow analyses needed by borrowck. These include all the `InitializedPlaces` analyses as well as `Borrows`. Additionally, this PR contains several independent changes around the dataflow API which improve performance and make it more ergonomic. * An optimization that inhibits the caching of block transfer functions for acyclic MIR (~0.3% I-CNT savings). * A `ResultsVisitor` for dataflow results that is more efficient than `ResultsCursor` when we have to visit every statement unconditionally (~0.3% I-CNT savings). * An `into_engine` method on `Analysis` that selects the appropriate `Engine` constructor. * A `contains` method for `ResultsCursor` as a shorthand for `.get().contains()`. * A `find_descendants` helper on `MovePath` that replaces `has_any_child_of` on the old `FlowsAtLocation` These changes made porting the dataflow analyses much easier. Finally, this PR removes some now-unused code in `dataflow/at_location.rs` and elsewhere. You can view the perf results for the final version of this PR [here](https://perf.rust-lang.org/compare.html?start=29b854fb741809c29764e33fc17c32ba9c6523ba&end=6e516c1410c18cfe4eb6d030a39fdb73c8d8a4fe). Here's an example of the graphviz diagrams that are generated for the `MaybeInitializedPlaces` analysis. ![image](https://user-images.githubusercontent.com/29463364/72846117-c3e97d80-3c54-11ea-8171-3d48981c9ddd.png)
Migrate borrowck dataflow impls to new framework This uses #65672 to implement the dataflow analyses needed by borrowck. These include all the `InitializedPlaces` analyses as well as `Borrows`. Additionally, this PR contains several independent changes around the dataflow API which improve performance and make it more ergonomic. * An optimization that inhibits the caching of block transfer functions for acyclic MIR (~0.3% I-CNT savings). * A `ResultsVisitor` for dataflow results that is more efficient than `ResultsCursor` when we have to visit every statement unconditionally (~0.3% I-CNT savings). * An `into_engine` method on `Analysis` that selects the appropriate `Engine` constructor. * A `contains` method for `ResultsCursor` as a shorthand for `.get().contains()`. * A `find_descendants` helper on `MovePath` that replaces `has_any_child_of` on the old `FlowsAtLocation` These changes made porting the dataflow analyses much easier. Finally, this PR removes some now-unused code in `dataflow/at_location.rs` and elsewhere. You can view the perf results for the final version of this PR [here](https://perf.rust-lang.org/compare.html?start=29b854fb741809c29764e33fc17c32ba9c6523ba&end=6e516c1410c18cfe4eb6d030a39fdb73c8d8a4fe). Here's an example of the graphviz diagrams that are generated for the `MaybeInitializedPlaces` analysis. ![image](https://user-images.githubusercontent.com/29463364/72846117-c3e97d80-3c54-11ea-8171-3d48981c9ddd.png)
redundant_clone: Migrate to new dataflow framework Migration to [the new dataflow framework](rust-lang/rust#65672) is ongoing in rustc. This PR updates the dataflow impl in `redundant_clone` lint. --- changelog: none
…tmandry Use new dataflow framework for generators #65672 introduced a new dataflow framework that can handle arbitrarily complex transfer functions as well as ones expressed as a series of gen/kill operations. This PR ports the analyses used to implement generators to the new framework so that we can remove the old one. See #68241 for a prior example of this. The new framework has some superficial API changes, but this shouldn't alter the generator passes in any way. r? @tmandry
This is the prototype implementation discussed in rust-lang/compiler-team#202. You can read a high-level description of it in the proposal for that design meeting. This would eventually supersede the existing
BitDenotation
interface.r? @ghost
cc @rust-lang/compiler (esp. @eddyb and @pnkfelix)