Skip to content

Commit

Permalink
Clean up dump mechanism and add an all option (#24)
Browse files Browse the repository at this point in the history
This changes the way dumping is done. It now uses a single `--dump`
command line argument that can be specified multiple times and a
`DFPP_DUMP` environment argument. Both may also be supplied with a comma
separated list of artifacts to dump. Using a single options makes typos
much less likely when specifying them via environment arg, because the
arguments themselves are checked whereas the env var name is not.

This cleans up the presentation for the CLI significantly, from this

```
Debugging and Testing:
        --dump-call-only-flow
            Dumps a dot graph representation of the dataflow between function calls calculated for
            each controller to <name of controller>.call-only-flow.gv
            
            [env: DUMP_CALL_ONLY_FLOW=]

        --dump-callee-mir
            Dump the MIR (`.mir`) of each called function (irrespective of whether they are a
            controller)
            
            [env: DUMP_CALLEE_MIR=]

        --dump-ctrl-mir
            For each controller dump a dot representation for each [`mir::Body`] as provided by
            rustc
            
            [env: DUMP_CTRL_MIR=]

        --dump-dataflow-analysis-result
            Dump a `.df` file for each called function describing the dataflow matrices calculated
            by the flowistry-style dataflow analysis
            
            [env: DUMP_DATAFLOW_ANALYSIS_RESULT=]

        --dump-flowistry-matrix
            Dumps a table representing retrieved Flowistry matrices to stdout
            
            [env: DUMP_FLOWISTRY_MATRIX=]

        --dump-global-equations
            Dump the equations after inlining (`.global.eqs`)
            
            [env: DUMP_GLOBAL_EQUATIONS=]

        --dump-inlined-function-flow
            Dumps a dot graph representation of the finely granular, inlined flow of each
            controller. Unlike `dump_call_only_flow` this contains also statements and non-call
            terminators. It is also created differently (using dependency resolution) and has not
            been tested in a while and shouldn't be relied upon
            
            [env: DUMP_INLINED_FUNCTION_FLOW=]

        --dump-inlined-graph
            Dump a `.inlined.gv` PDG after inlining called functions, but before pruning
            
            [env: DUMP_INLINED_GRAPH=]

        --dump-inlined-pruned-graph
            Dump a `.inlined-pruned.gv` PDG for each called function describing the flow graph after
            pruning with the place algebra (only useful without `--no-pruning`)
            
            [env: DUMP_INLINED_PRUNED_GRAPH=]

        --dump-local-equations
            Dump the equations before inlining (`.local.eqs`)
            
            [env: DUMP_LOCAL_EQUATIONS=]

        --dump-locals-graph
            [env: DUMP_LOCALS_GRAPH=]

        --dump-non-transitive-graph
            Deprecated alias for `dump_call_only_flow`
            
            [env: DUMP_NON_TRANSITIVE_GRAPH=]

        --dump-pre-inline-graph
            Dump the flow PDG before inlining the called functions
            
            [env: DUMP_PRE_INLINE_GRAPH=]

        --dump-regal-ir
            Dump a representation of the "regal" IR for each function (`.regal`)
            
            [env: DUMP_REGAL_IR=]

        --dump-serialized-flow-graph
            Dump a complete `crate::desc::ProgramDescription` in serialized (json) format to
            "flow-graph.json". Used for testing
            
            [env: DUMP_SERIALIZED_FLOW_GRAPH=]

        --dump-serialized-non-transitive-graph
            For each controller dumps the calculated dataflow graphs as well as information about
            the MIR to <name of controller>.ntgb.json. Can be deserialized with
            `crate::dbg::read_non_transitive_graph_and_body`
            
            [env: DUMP_SERIALIZED_NON_TRANSITIVE_GRAPH=]
```

to this

```
      --dump <DUMP>
          Generate intermediate of various formats and at various stages of compilation. A short description of each value is provided here, for a more comprehensive explanation refer to the [notion page on dumping](https://www.notion.so/justus-adam/Dumping-Intermediate-Representations-4bd66ec11f8f4c459888a8d8cfb10e93).
          
          Can also be supplied as a comma-separated list (no spaces) and be set with the `DFPP_DUMP` variable.

          Possible values:
          - ctrl-mir:                        For each controller dump a dot representation for each [`mir::Body`] as provided by rustc
          - serialized-non-transitive-graph: For each controller dumps the calculated dataflow graphs as well as information about the MIR to <name of controller>.ntgb.json. Can be deserialized with `crate::dbg::read_non_transitive_graph_and_body`
          - call-only-flow:                  Dumps a dot graph representation of the dataflow between function calls calculated for each controller to <name of controller>.call-only-flow.gv
          - serialized-flow-graph:           Dump a complete `crate::desc::ProgramDescription` in serialized (json) format to "flow-graph.json". Used for testing
          - dataflow-analysis-result:        Dump a `.df` file for each called function describing the dataflow matrices calculated by the flowistry-style dataflow analysis
          - inlined-pruned-graph:            Dump a `.inlined-pruned.gv` PDG for each called function describing the flow graph after pruning with the place algebra (only useful without `--no-pruning`)
          - inlined-graph:                   Dump a `.inlined.gv` PDG after inlining called functions, but before pruning
          - callee-mir:                      Dump the MIR (`.mir`) of each called function (irrespective of whether they are a controller)
          - pre-inline-graph:                Dump the flow PDG before inlining the called functions
          - regal-ir:                        Dump a representation of the "regal" IR for each function (`.regal`)
          - local-equations:                 Dump the equations before inlining (`.local.eqs`)
          - global-equations:                Dump the equations after inlining (`.global.eqs`)
          - locals-graph
          - non-transitive-graph:            Deprecated alias for `dump_call_only_flow`
          - all:                             Dump everything we know of
```
It also adds an `all` option that simply enables all dumps.

Changes the test cases to use the new arguments
  • Loading branch information
JustusAdam committed Jul 29, 2023
1 parent 31b5991 commit 1ac01f4
Show file tree
Hide file tree
Showing 7 changed files with 373 additions and 182 deletions.
186 changes: 111 additions & 75 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ flowistry = { git = "https://github.com/brownsys/flowistry", rev = "f3b27bb1e06a
rustc_utils = "=0.6.0-nightly-2023-04-12"
rustc_plugin = "=0.6.0-nightly-2023-04-12"

clap = { version = "3", features = ["derive", "cargo", "env"] }
clap = { version = "4", features = ["derive", "cargo", "env"] }
serde = { version = "1", features = ["derive"] }
lazy_static = "1"
ordermap = "0.3"
Expand All @@ -30,7 +30,8 @@ nom = "7"
log = "0.4"
simple_logger = "2"
petgraph = "0.6"

num-derive = "0.4"
num-traits = "0.2"

humantime = "2"
indicatif = "0.17"
Expand Down
6 changes: 3 additions & 3 deletions src/ana/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::{
body_name_pls, dump_file_pls, time, write_sep, DisplayViaDebug, IntoDefId, IntoLocalDefId,
Print, RecursionBreakingCache, TinyBitSet,
},
AnalysisCtrl, DbgArgs, Either, HashMap, HashSet, Symbol, TyCtxt,
AnalysisCtrl, DumpArgs, Either, HashMap, HashSet, Symbol, TyCtxt,
};

use super::df::MarkerCarryingOracle;
Expand Down Expand Up @@ -487,7 +487,7 @@ pub struct Inliner<'tcx, 'g, 's> {
tcx: TyCtxt<'tcx>,
gli: GLI<'g>,
ana_ctrl: &'static AnalysisCtrl,
dbg_ctrl: &'static DbgArgs,
dbg_ctrl: &'static DumpArgs,
marker_carrying: MarkerCarryingOracle<'tcx, 's>,
}

Expand Down Expand Up @@ -653,7 +653,7 @@ impl<'tcx, 'g, 's> Inliner<'tcx, 'g, 's> {
gli: GLI<'g>,
recurse_selector: &'s (dyn Oracle + 's),
ana_ctrl: &'static AnalysisCtrl,
dbg_ctrl: &'static DbgArgs,
dbg_ctrl: &'static DumpArgs,
) -> Self {
Self {
tcx,
Expand Down
Loading

0 comments on commit 1ac01f4

Please sign in to comment.