rust/compiler
bors 0e2c1281e9 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
..
rustc
rustc_apfloat
rustc_arena
rustc_ast Rollup merge of #76274 - scottmcm:fix-76271, r=petrochenkov 2020-09-07 01:17:46 +02:00
rustc_ast_lowering
rustc_ast_passes Implementation of incompatible features error 2020-09-04 22:17:28 +08:00
rustc_ast_pretty Auto merge of #76170 - matklad:notrivia, r=petrochenkov 2020-09-02 03:19:38 +00:00
rustc_attr
rustc_builtin_macros Improve recovery on malformed format call 2020-09-02 13:18:19 +02:00
rustc_codegen_llvm Change ty.kind to a method 2020-09-04 17:47:51 +02:00
rustc_codegen_ssa Change ty.kind to a method 2020-09-04 17:47:51 +02:00
rustc_data_structures Add BREAK too, and improve the comments 2020-09-04 16:28:23 -07:00
rustc_driver Auto merge of #73996 - da-x:short-unique-paths, r=petrochenkov 2020-09-03 23:27:45 +00:00
rustc_error_codes Rollup merge of #76143 - jyn514:duplicate-builtin-macros, r=petrochenkov 2020-09-01 18:24:35 -07:00
rustc_errors rustc_{errors,session}: add delay_good_path_bug 2020-09-02 10:43:17 +03:00
rustc_expand Optimize Cursor::look_ahead 2020-09-03 23:28:22 +02:00
rustc_feature Implementation of incompatible features error 2020-09-04 22:17:28 +08:00
rustc_fs_util
rustc_graphviz
rustc_hir add track_caller to local_def_id_to_hir_id 2020-09-04 09:24:44 +02:00
rustc_hir_pretty
rustc_incremental
rustc_index
rustc_infer ty.flags -> ty.flags() 2020-09-04 18:28:20 +02:00
rustc_interface Auto merge of #73996 - da-x:short-unique-paths, r=petrochenkov 2020-09-03 23:27:45 +00:00
rustc_lexer lexer: Tiny improvement to shebang detection 2020-09-02 00:40:19 +03:00
rustc_lint Change ty.kind to a method 2020-09-04 17:47:51 +02:00
rustc_macros pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
rustc_metadata Change ty.kind to a method 2020-09-04 17:47:51 +02:00
rustc_middle Rollup merge of #76340 - jonas-schievink:rm-dupe, r=Mark-Simulacrum 2020-09-07 01:18:10 +02:00
rustc_mir Auto merge of #76044 - ecstatic-morse:dataflow-lattice, r=oli-obk 2020-09-07 21:29:43 +00:00
rustc_mir_build Rollup merge of #76318 - scottmcm:one-control-flow, r=ecstatic-morse 2020-09-07 01:18:05 +02:00
rustc_parse Optimize Cursor::look_ahead 2020-09-03 23:28:22 +02:00
rustc_parse_format
rustc_passes Auto merge of #75888 - GuillaumeGomez:trait-impl-assoc-const-doc-alias, r=ollie27 2020-09-05 09:35:17 +00:00
rustc_plugin_impl
rustc_privacy Change ty.kind to a method 2020-09-04 17:47:51 +02:00
rustc_query_system
rustc_resolve Rollup merge of #76143 - jyn514:duplicate-builtin-macros, r=petrochenkov 2020-09-01 18:24:35 -07:00
rustc_save_analysis Change ty.kind to a method 2020-09-04 17:47:51 +02:00
rustc_serialize
rustc_session Auto merge of #76004 - richkadel:llvm-coverage-map-gen-6b.5, r=tmandry 2020-09-04 01:31:07 +00:00
rustc_span
rustc_symbol_mangling Change ty.kind to a method 2020-09-04 17:47:51 +02:00
rustc_target Rollup merge of #76364 - fusion-engineering-forks:avr-no-atomic, r=jonas-schievink 2020-09-07 01:18:17 +02:00
rustc_trait_selection ty.flags -> ty.flags() 2020-09-04 18:28:20 +02:00
rustc_traits kind -> kind() 2020-09-04 19:17:57 -04:00
rustc_ty Change ty.kind to a method 2020-09-04 17:47:51 +02:00
rustc_typeck Auto merge of #75584 - RalfJung:union-no-deref, r=matthewjasper 2020-09-05 11:47:01 +00:00