Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upMIR graphviz prettification #30602
Conversation
solson
added some commits
Dec 19, 2015
rust-highfive
assigned
nikomatsakis
Dec 29, 2015
This comment has been minimized.
This comment has been minimized.
|
@tsion Very nice! I'd have to take a closer look if any vital information is missing now that was shown before, but from a first glance I like the new output a lot better. Much more readable |
This comment has been minimized.
This comment has been minimized.
|
Looks pretty good to me (both code and output). I have a minor concern that spelling out every branch (true/false/return/unwind) might introduce too much visual clutter, but I think it is fine to leave it as is for now and wait to see if it ends up being an issue. I’d argue it still would be better to name Lvalues |
This comment has been minimized.
This comment has been minimized.
|
Ah, also, I believe
and so on. EDIT: note that it doesn’t really matter whether it is a struct or enum variant, what matters is the kind of Adt, i.e. is it struct-like ( |
This comment has been minimized.
This comment has been minimized.
|
The |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@nagisa I think I agree about For aggregates, I was planning to drop the whole |
This comment has been minimized.
This comment has been minimized.
Sure, SGTM. |
This comment has been minimized.
This comment has been minimized.
|
Maybe there should be (choosable) levels of verbosity in the output, e.g. I imagine the spans are usually not needed at all (except for closures, maybe). |
This comment has been minimized.
This comment has been minimized.
|
Ah, @huonw, that's a great idea - would be useful for types, i.e. being able to see them everywhere, like in LLVM IR, when you need that. |
This comment has been minimized.
This comment has been minimized.
|
@huonw Yeah, that's a good idea. I was mainly aiming to remove irrelevant details, e.g. between constant-old and constant-new, but we could have flags for adding spans and/or types back in. |
This comment has been minimized.
This comment has been minimized.
|
Another thought: we could show all integer constants with their type suffixes (e.g. |
This comment has been minimized.
This comment has been minimized.
|
I made the change from |
solson
referenced this pull request
Dec 30, 2015
Merged
Fix argument indices in MIR for closures. #30630
bors
added a commit
that referenced
this pull request
Dec 31, 2015
nagisa
added a commit
to nagisa/rust
that referenced
this pull request
Dec 31, 2015
nagisa
added a commit
to nagisa/rust
that referenced
this pull request
Dec 31, 2015
nagisa
added a commit
to nagisa/rust
that referenced
this pull request
Dec 31, 2015
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
pretty. :) |
solson commentedDec 29, 2015
r? @nikomatsakis
cc @eddyb @nagisa
This PR changes most of the MIR graphviz debug output, making it smaller and more consistent. Also, it changes all fonts to monospace and adds a graph label containing the type of the
fnthe MIR is for and all the values (arguments, named bindings, and compiler temporaries).I chose to re-write the graphviz output code instead of using the existing libgraphviz API because I found it much easier to prototype usage of various graphviz features when I had full control of the text output. It also makes the code simpler, I think.
Below are a bunch of example functions and links to their output images on the current nightly vs. this PR. File names starting with numbers (e.g.
80-factorial_fold-new.png) are for closures. There's still a bunch of low hanging fruit to make it even better, particularly around aggregates and references.I also imagine the textual output for MIR will be able to closely match the graphviz output. The list of statements should look identical and the terminators will be the same except that the text form will have a list of target blocks (potentially using the same edge labels as the graphviz does). I can PR a simple text output right after this PR.
This is my first large change to the compiler, so if anything should be reorganized/renamed/etc, let me know! Also, feel free to bikeshed the details of the output, though any minor changes can come in future PRs.
http://vps.solson.me/mir-graphviz/empty-new.png
http://vps.solson.me/mir-graphviz/empty-old.png
http://vps.solson.me/mir-graphviz/constant-new.png
http://vps.solson.me/mir-graphviz/constant-old.png
http://vps.solson.me/mir-graphviz/increment-new.png
http://vps.solson.me/mir-graphviz/increment-old.png
http://vps.solson.me/mir-graphviz/factorial_recursive-new.png
http://vps.solson.me/mir-graphviz/factorial_recursive-old.png
http://vps.solson.me/mir-graphviz/factorial_iterative-new.png
http://vps.solson.me/mir-graphviz/factorial_iterative-old.png
http://vps.solson.me/mir-graphviz/factorial_fold-new.png
http://vps.solson.me/mir-graphviz/factorial_fold-old.png
http://vps.solson.me/mir-graphviz/80-factorial_fold-new.png
http://vps.solson.me/mir-graphviz/80-factorial_fold-old.png
http://vps.solson.me/mir-graphviz/collatz-new.png
http://vps.solson.me/mir-graphviz/collatz-old.png
http://vps.solson.me/mir-graphviz/multi_switch-new.png
http://vps.solson.me/mir-graphviz/multi_switch-old.png