Skip to content
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

Elaborate on dataflow outputs for region constraints #1969

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/compiler-debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,18 @@ $ dot -T pdf maybe_init_suffix.dot > maybe_init_suffix.pdf
$ firefox maybe_init_suffix.pdf # Or your favorite pdf viewer
```

Graphviz also comes with a preprocessor program,
[`unflatten`](https://graphviz.org/docs/cli/unflatten/), that
sometimes helps making the outputs look less oddly spread out. It reads
a dot file and outputs another dot file, so you can use it in a pipe,
e.g:
```
$ unflatten mir_dump/*.foo.-------.nll.0.regioncx.all.dot | dot -Tpdf -o foo-outlives.pdf
```

This is particularly useful for complicated region outlives graphs from
[MIR Dataflow](mir/dataflow.md#graphviz-diagrams).
amandasystems marked this conversation as resolved.
Show resolved Hide resolved

## Narrowing (Bisecting) Regressions

The [cargo-bisect-rustc][bisect] tool can be used as a quick and easy way to
Expand Down
Binary file added src/img/region-graphviz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/scc-graphviz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions src/mir/dataflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,26 @@ the example below:

![A graphviz diagram for a dataflow analysis](../img/dataflow-graphviz-example.png)

### Region Constraint Graphs and Their Strongly Connected Components

![A graph showing a small number of regions with their outlives relations](../img/region-graphviz.png)

With `-Z dump-mir-graphviz=yes`, you will also get Graphviz files for the outlives constraints
amandasystems marked this conversation as resolved.
Show resolved Hide resolved
of the MIR bodies you asked for, as well as the strongly connected components (SCCs) on them.
They are available as
`mir_dump/rs-file-name.function-name.-------.nll.0.regioncx.all.dot` and
`mir_dump/rs-file-name.function-name.-------.nll.0.regioncx.scc.dot` respectively. For both
graphs, named region variables will be shown with their external name (such as `'static`)
shown in parenthesis. For region inference variables in universes other than the root universe,
they will be shown as `/U13` (for universe 13). In the region graph, edges are labelled with
the MIR locations where the relationship holds, or `All` if it's everywhere.
amandasystems marked this conversation as resolved.
Show resolved Hide resolved

![A graph showing a small number of strongly connected components on the region-outlives-graph above](../img/scc-graphviz.png)

**Note:** There are implicit edges from `'static` to every region, but those are not rendered
in the region graph to avoid clutter. They _do_ however show up in the SCC graph. This is why there are outgoing edges from SCC(5) in the SCC graph above
that do not seem to have corresponding edges in the region outlives graph above.
amandasystems marked this conversation as resolved.
Show resolved Hide resolved

["gen-kill" problems]: https://en.wikipedia.org/wiki/Data-flow_analysis#Bit_vector_problems
[*Static Program Analysis*]: https://cs.au.dk/~amoeller/spa/
[Debugging MIR]: ./debugging.html
Expand Down