-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Migrate borrowck dataflow impls to new framework #68241
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
Migrate borrowck dataflow impls to new framework #68241
Conversation
|
@bors try |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Queued 31ca0fd7b109756a7c52baff29870d7831f3e723 with parent 4b172cc, future comparison URL. |
4b03211 to
067e6c7
Compare
|
Now without caching block transfer functions on acyclic MIR. @bors try |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
067e6c7 to
df42d38
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Queued b685c41b5ae4fe1476ec71023ad348b57781105c with parent 3291ae3, future comparison URL. |
|
Finished benchmarking try commit b685c41b5ae4fe1476ec71023ad348b57781105c, comparison URL. |
df42d38 to
f0e6418
Compare
|
Once more but using a @bors try |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
f0e6418 to
b1081c0
Compare
This comment has been minimized.
This comment has been minimized.
|
Okay I'm done with the review. I had some nits, but they are mostly about clarifying the commit messages or the commit history, along with a few small stylistic issues; so the fixes should be easy. r=me after fixes are made. |
86fdcdf to
5f40fe9
Compare
|
📌 Commit 5f40fe9 has been approved by |
|
@bors rollup=never |
…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. 
|
@bors p=1 |
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. 
|
☀️ Test successful - checks-azure |
…ls2, r=eddyb Use `ResultsCursor` for `elaborate_drops` Some cleanup after rust-lang#68241. The old code was using a custom cursor-like struct called `InitializationData`.
Use `ResultsCursor` for `elaborate_drops` Some cleanup after #68241. The old code was using a custom cursor-like struct called `InitializationData`.
…sleywiser Combine `HaveBeenBorrowedLocals` and `IndirectlyMutableLocals` into one dataflow analysis This PR began as an attempt to port `HaveBeenBorrowedLocals` to the new dataflow framework (see #68241 for prior art). Along the way, I noticed that it could share most of its code with `IndirectlyMutableLocals` and then found a few bugs in the two analyses: - Neither one marked locals as borrowed after an `Rvalue::AddressOf`. - `IndirectlyMutableLocals` was missing a minor fix that `HaveBeenBorrowedLocals` got in #61069. This is not a problem today since it is only used during const-checking, where custom drop glue is forbidden. However, this may change some day. I decided to combine the two analyses so that they wouldn't diverge in the future while ensuring that they remain distinct types (called `MaybeBorrowedLocals` and `MaybeMutBorrowedLocals` to be consistent with the `Maybe{Un,}InitializedPlaces` naming scheme). I fixed the bugs and switched to exhaustive matching where possible to make them less likely in the future. Finally, I added comments explaining some of the finer points of the transfer function for these analyses (see #61069 and #65006).
…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 uses #65672 to implement the dataflow analyses needed by borrowck. These include all the
InitializedPlacesanalyses as well asBorrows. Additionally, this PR contains several independent changes around the dataflow API which improve performance and make it more ergonomic.ResultsVisitorfor dataflow results that is more efficient thanResultsCursorwhen we have to visit every statement unconditionally (~0.3% I-CNT savings).into_enginemethod onAnalysisthat selects the appropriateEngineconstructor.containsmethod forResultsCursoras a shorthand for.get().contains().find_descendantshelper onMovePaththat replaceshas_any_child_ofon the oldFlowsAtLocationThese changes made porting the dataflow analyses much easier. Finally, this PR removes some now-unused code in
dataflow/at_location.rsand elsewhere.You can view the perf results for the final version of this PR here. Here's an example of the graphviz diagrams that are generated for the
MaybeInitializedPlacesanalysis.