about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/dataflow
AgeCommit message (Collapse)AuthorLines
2020-09-18Implement a destination propagation passJonas Schievink-1/+1
2020-09-17Don't compile regex at every function call.Hanif Bin Ariffin-1/+9
Use `SyncOnceCell` to only compile it once. I believe this still adds some kind of locking mechanism?
2020-09-17don't lazily evaulate some trivial values for Option::None replacements ↵Matthias Krüger-4/+1
(clippy::unnecessary_lazy_evaluations)
2020-09-16Rollup merge of #76794 - richkadel:graphviz-font, r=ecstatic-morseTyler Mandry-1/+2
Make graphviz font configurable Alternative to PR #76776. To change the graphviz output to use an alternative `fontname` value, add a command line option like: `rustc --graphviz-font=monospace`. r? @ecstatic-morse
2020-09-16Make graphviz font configurableRich Kadel-1/+2
Alternative to PR ##76776. To change the graphviz output to use an alternative `fontname` value, add a command line option like: `rustc --graphviz-font=monospace`.
2020-09-15Strip a single leading tab when rendering dataflow diffsDylan MacKenzie-1/+1
2020-09-15don't convert types to the same type with try_into (clippy::useless_conversion)Matthias Krüger-4/+1
2020-09-14Add `Engine::pass_name` to differentiate dataflow runsDylan MacKenzie-2/+20
2020-09-09Rollup merge of #76500 - richkadel:mir-graphviz-dark, r=tmandryTyler Mandry-1/+5
Add -Zgraphviz_dark_mode and monospace font fix Many developers use a dark theme with editors and IDEs, but this typically doesn't extend to graphviz output. When I bring up a MIR graphviz document, the white background is strikingly bright. This new option changes the colors used for graphviz output to work better in dark-themed UIs. <img width="1305" alt="Screen Shot 2020-09-09 at 3 00 31 PM" src="https://user-images.githubusercontent.com/3827298/92659478-4b9bff00-f2ad-11ea-8894-b40d3a873cb9.png"> Also fixed the monospace font for common graphviz renders (e.g., VS Code extensions), as described in https://github.com/rust-lang/rust/pull/76500#issuecomment-689837948 **Before:** <img width="943" alt="Screen Shot 2020-09-09 at 2 48 44 PM" src="https://user-images.githubusercontent.com/3827298/92658939-47231680-f2ac-11ea-97ac-96727e4dd622.png"> **Now with fix:** <img width="943" alt="Screen Shot 2020-09-09 at 2 49 02 PM" src="https://user-images.githubusercontent.com/3827298/92658959-51451500-f2ac-11ea-9aae-de982d466d6a.png">
2020-09-09Remove unused PlaceContext::NonUse(NonUseContext::Coverage)Tomasz Miąsko-1/+0
2020-09-08Add -Zgraphviz_dark_modeRich Kadel-1/+5
Many developers use a dark theme with editors and IDEs, but this typically doesn't extend to graphviz output. When I bring up a MIR graphviz document, the white background is strikingly bright. This new option changes the colors used for graphviz output to work better in dark-themed UIs.
2020-09-07Auto merge of #76044 - ecstatic-morse:dataflow-lattice, r=oli-obkbors-633/+883
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-04Change ty.kind to a methodLeSeulArtichaut-5/+7
2020-08-30Add documentation to the `Analysis` traitsDylan MacKenzie-3/+19
2020-08-30Expand documentation for the `lattice` moduleDylan MacKenzie-17/+51
2020-08-30Add `FIXME` for faster cached block transfer functionsDylan MacKenzie-0/+5
I've tried a few ways of implementing this, but each fell short. Adding an auxiliary `_Idx` associated type to `Analysis` that defaults to `!` but is overridden in the blanket impl of `Analysis` for `A: GenKillAnalysis` to `A::Idx` seems promising, but the trait solver is unable to prove equivalence between `A::Idx` and `A::_Idx` within the overridden version of `into_engine`. Without full-featured specialization, removing `into_engine` or splitting it into a different trait would have a significant ergonomic penalty. Alternatively, we could erase the index type and store a `GenKillSet<u32>` as well as a function pointer for transmuting between `&mut A::Domain` and `&mut BitSet<u32>` in the hopes that LLVM can devirtualize a simple function pointer better than the boxed closure. However, this is brittle, requires `unsafe` code, and doesn't work for index types that aren't the same size as a `u32` (e.g. `usize`) since `GenKillSet` stores a `HybridBitSet`, which may be a `Vec<I>`. Perhaps safe transmute could help here?
2020-08-30Update dataflow analyses to use new interfaceDylan MacKenzie-115/+82
2020-08-30Extend dataflow framework to support arbitrary latticesDylan MacKenzie-514/+737
2020-08-30Allow access to the underlying `Results` from a `ResultsCursor`Dylan MacKenzie-1/+6
2020-08-30mv compiler to compiler/mark-0/+6324