Commit Graph

90 Commits

Author SHA1 Message Date
bors
3ffe9f843c Auto merge of #76044 - ecstatic-morse:dataflow-lattice, r=oli-obk
Support dataflow problems on arbitrary lattices

This PR implements last of the proposed extensions I mentioned in the design meeting for the original dataflow refactor. It extends the current dataflow framework to work with arbitrary lattices, not just `BitSet`s. This is a prerequisite for dataflow-enabled MIR const-propagation. Personally, I am skeptical of the usefulness of doing const-propagation pre-monomorphization, since many useful constants only become known after monomorphization (e.g. `size_of::<T>()`) and users have a natural tendency to hand-optimize the rest. It's probably worth exprimenting with, however, and others have shown interest cc `@rust-lang/wg-mir-opt.`

The `Idx` associated type is moved from `AnalysisDomain` to `GenKillAnalysis` and replaced with an associated `Domain` type that must implement `JoinSemiLattice`. Like before, each `Analysis` defines the "bottom value" for its domain, but can no longer override the dataflow join operator. Analyses that want to use set intersection must now use the `lattice::Dual` newtype. `GenKillAnalysis` impls have an additional requirement that `Self::Domain: BorrowMut<BitSet<Self::Idx>>`, which effectively means that they must use `BitSet<Self::Idx>` or `lattice::Dual<BitSet<Self::Idx>>` as their domain.

Most of these changes were mechanical. However, because a `Domain` is no longer always a powerset of some index type, we can no longer use an `IndexVec<BasicBlock, GenKillSet<A::Idx>>>` to store cached block transfer functions. Instead, we use a boxed `dyn Fn` trait object. I discuss a few alternatives to the current approach in a commit message.

The majority of new lines of code are to preserve existing Graphviz diagrams for those unlucky enough to have to debug dataflow analyses. I find these diagrams incredibly useful when things are going wrong and considered regressing them unacceptable, especially the pretty-printing of `MovePathIndex`s, which are used in many dataflow analyses. This required a parallel `fmt` trait used only for printing dataflow domains, as well as a refactoring of the `graphviz` module now that we cannot expect the domain to be a `BitSet`. Some features did have to be removed, such as the gen/kill display mode (which I didn't use but existed to mirror the output of the old dataflow framework) and line wrapping. Since I had to rewrite much of it anyway, I took the opportunity to switch to a `Visitor` for printing dataflow state diffs instead of using cursors, which are error prone for code that must be generic over both forward and backward analyses. As a side-effect of this change, we no longer have quadratic behavior when writing graphviz diagrams for backward dataflow analyses.

r? `@pnkfelix`
2020-09-07 21:29:43 +00:00
LeSeulArtichaut
28f9b84042 ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00
Dylan MacKenzie
1c5b0fbe53 Update dataflow analyses to use new interface 2020-08-30 11:15:25 -07:00
flip1995
d164ab65f7 Merge commit 'da5a6fb1b65ec6581a67e942a3850f6bc15a552c' into clippyup 2020-07-26 21:07:07 +02:00
Eduard-Mihai Burtescu
30c046ede4 Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
Dylan MacKenzie
41fe5c1ca7 Update clippy lint 2020-05-03 11:41:03 -07:00
Philipp Hansch
0a49935270
cargo dev fmt 2020-04-26 13:44:08 +02:00
Philipp Hansch
0480ff861a
More diagnostic items
In particular for:

* `VecDeque`
* `String`
* `Mutex`
* `HashMap`
* `HashSet`

cc https://github.com/rust-lang/rust/pull/71414 https://github.com/rust-lang/rust-clippy/issues/5393
2020-04-26 13:44:08 +02:00
lzutao
3f6f392730 predecessors_for will be removed soon
Co-Authored-By: ecstatic-morse <ecstaticmorse@gmail.com>
2020-04-23 09:09:09 +07:00
Lzu Tao
9ef9b7946f Rustup "Remove BodyAndCache" 2020-04-23 08:39:35 +07:00
Philipp Hansch
870ae36f85
Cleanup: Rename 'db' variable to 'diag' 2020-04-17 08:08:00 +02:00
Rabi Guha
ab3946d7e9 Fixes #5405: redundant clone false positive with arrays
Check whether slice elements implement Copy before suggesting to drop
the clone method
2020-04-13 11:43:42 +05:30
Matthias Krüger
4352c8555b rustup https://github.com/rust-lang/rust/pull/70986 2020-04-11 10:01:23 +02:00
flip1995
3142ee3f7a
Rustup to rust-lang/rust#70627 2020-04-01 19:42:15 +02:00
Matthias Krüger
aff57e0f43 rustup https://github.com/rust-lang/rust/pull/70536 2020-03-30 11:17:58 +02:00
Philipp Hansch
68ed6ccf04
Rustup to https://github.com/rust-lang/rust/pull/70449 2020-03-30 07:34:19 +02:00
Matthias Krüger
6b1bad54ef rustup https://github.com/rust-lang/rust/pull/69644 2020-03-27 20:41:51 +01:00
Philipp Hansch
cec1e8f74e
Remove dependency on matches crate
The std equivalent works exactly the same.
2020-03-25 07:50:08 +01:00
Shotaro Yamada
d9ad33852c Use visit_place 2020-03-13 02:06:47 +09:00
Shotaro Yamada
aca64b8df7 Check for mutation 2020-03-13 01:25:18 +09:00
Shotaro Yamada
a377378528 Only fires on temporaries
`let y = x.clone()` cannot be turned into `let y = x` without moving x,
regardless of whether `y` is consumed or not.
2020-03-13 00:54:40 +09:00
Shotaro Yamada
9de642190e Extend redundant_clone to the case that cloned value is not consumed 2020-03-13 00:31:09 +09:00
Shotaro Yamada
a3d9355bef Fix ICE with trivial_bounds feature 2020-03-10 13:17:35 +09:00
flip1995
8472ecda0f
Fix fallout 2020-02-21 11:14:18 +01:00
Shotaro Yamada
9d254545f3 Migrate to generic dataflow 2020-02-20 03:21:18 +09:00
Shotaro Yamada
1c5c054e4c Rename for clarity 2020-02-20 03:21:18 +09:00
Yuki Okushi
66524c5be0 Rustup to rust-lang/rust#68512 2020-01-29 17:15:56 +09:00
Yuki Okushi
ce1c6b285d Rustup to rust-lang/rust#68045 2020-01-13 21:55:57 +09:00
Yuki Okushi
2f4b105863 Remove references 2020-01-12 05:20:18 +09:00
Yuki Okushi
8a3a0ea2ea Rustup to rust-lang/rust#67000 2020-01-12 03:41:54 +09:00
Yuki Okushi
39947992b5 Rustup to rust-lang/rust#67806 2020-01-11 21:50:00 +09:00
Yuki Okushi
e58cfac458 Rustup to rust-lang/rust#67979 2020-01-09 16:43:51 +09:00
Shotaro Yamada
99eec3f54f Fix redundant_clone 2020-01-08 14:18:00 +09:00
Yuki Okushi
2f2eaf8b7e Rustup to rust-lang/rust#67886 2020-01-07 01:46:33 +09:00
Philipp Hansch
c5178e82b4
Rustup to https://github.com/rust-lang/rust/pull/67853
Specifically caused by https://github.com/rust-lang/rust/pull/67786
2020-01-04 11:30:03 +01:00
Yuki Okushi
a4c201e6b4 Rustup to rust-lang/rust#66942 2019-12-30 13:02:10 +09:00
flip1995
9632e27487
Add <'_> where necessary 2019-12-22 15:42:41 +01:00
Emma
5a6b00ce50
Fix 'redudant' spelling in redundant_clone docs
The word 'redundant' is spelled incorrectly in the **What it does** section of the redundant_clone documentation.
2019-12-20 01:07:42 +01:00
Matthias Krüger
98e433d70d
Rustup to rust-lang/rust#66878 2019-12-04 01:34:01 +01:00
flip1995
286b39d2e5
Rustup to rust-lang/rust#64736 2019-12-02 20:39:40 +01:00
Philipp Hansch
474e9a131d
Use assert_crate_local for a more explicit error
`assert_crate_local` does the same as the previous `if let` but with a
more explicit error message if it's not a `ClearCrossCrate::Set`.
2019-12-02 12:09:38 +01:00
Philipp Hansch
6669c2c6ce
Rustup to https://github.com/rust-lang/rust/pull/66789 2019-12-02 09:51:35 +01:00
Shotaro Yamada
4cded6d901 extern rustc_index 2019-10-03 08:27:47 +09:00
Shotaro Yamada
866729f5db Add comments 2019-10-03 08:10:29 +09:00
Shotaro Yamada
1cee3fe00e Resolve reviews 2019-10-03 08:10:29 +09:00
Shotaro Yamada
a3f403aa50 Apply suggestion
Co-Authored-By: ecstatic-morse <ecstaticmorse@gmail.com>
2019-10-03 08:10:29 +09:00
Shotaro Yamada
667223c35d Add run-rustfix 2019-10-03 08:10:29 +09:00
Shotaro Yamada
301ef6bb2a Fix false-positive of redundant_clone and move to clippy::perf 2019-10-03 08:10:29 +09:00
Lzu Tao
a7b7e19f49 Rustup https://github.com/rust-lang/rust/pull/64513 2019-09-26 16:03:36 +07:00
Jason Olson
80822b430d
Convert to Place's new boxed slice projection
Fixes breaking change from rust-lang PR https://github.com/rust-lang/rust/pull/63420/
2019-09-13 18:49:11 -07:00