Skip to content

-Z dump-mir usage instructions not clear #56558

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
vext01 opened this issue Dec 6, 2018 · 10 comments
Closed

-Z dump-mir usage instructions not clear #56558

vext01 opened this issue Dec 6, 2018 · 10 comments

Comments

@vext01
Copy link
Contributor

vext01 commented Dec 6, 2018

Hi,

I wanted to inspect the MIR of my program and found -Z dump-mir via this issue:
rust-lang/rustc-dev-guide#11

The usage for this option is:

$ rustc -Z help
...
    -Z       dump-mir=val -- dump MIR state at various points in transforms
...

What can val be here? I've managed to figure out that -Z dump-mir=all works, but what else is valid? I think the usage string should say.

Thanks

@wesleywiser
Copy link
Member

For reference, the rustc guide has additional information on this flag that could either be adapted for the help info or, at least, linked to.

@vext01
Copy link
Contributor Author

vext01 commented Dec 6, 2018

How about something like:

-Z                       dump-mir=val -- dump MIR state to file
    'val' is used to select which passes and functions to dump. For example:
     - 'all' matches all passes and functions.
     - 'foo' all passes for functions whose name contains 'foo'.
     - 'foo & CleanEndRegions' Only the 'CleanEndRegions' pass for function names containing 'foo'.
     - 'foo | bar' all passes for function names containing 'foo' or 'bar'.

Too long?

@wesleywiser
Copy link
Member

Seems like nearly all of the existing options are one-line. There's one notable exception:

    -Z                       unpretty=val -- Present the input source, unstable (and less-pretty) variants;
        valid types are any of the types for `--pretty`, as well as:
        `flowgraph=<nodeid>` (graphviz formatted flowgraph for node),
        `everybody_loops` (all function bodies replaced with `loop {}`),
        `hir` (the HIR), `hir,identified`, or
        `hir,typed` (HIR with types for each node).

So I guess there's precedent?

@vext01
Copy link
Contributor Author

vext01 commented Dec 6, 2018

Indeed. That's where I copied the indentation style from.

@vext01
Copy link
Contributor Author

vext01 commented Dec 6, 2018

(Should perhaps drop the hyphens and use backticks though)

@wesleywiser
Copy link
Member

That sounds good to me 😃

@matthewjasper
Copy link
Contributor

CleanEndRegions should be replaced with a pass that still exists. (See rustc_mir::transform for the passes that's rustc currently has)

@vext01
Copy link
Contributor Author

vext01 commented Dec 7, 2018

Great. I'll raise a PR for this shortlyish.

@vext01
Copy link
Contributor Author

vext01 commented Dec 7, 2018

PR for this is now up.

Centril added a commit to Centril/rust that referenced this issue Dec 8, 2018
Improve the usage message for `-Z dump-mir`.

Ouput now looks like this:
```
$ rustc -Z help
...
    -Z               arg-align-attributes -- emit align metadata for reference arguments
    -Z                       dump-mir=val -- dump MIR state to file.
        `val` is used to select which passes and functions to dump. For example:
        `all` matches all passes and functions,
        `foo` matches all passes for functions whose name contains 'foo',
        `foo & ConstProp` only the 'ConstProp' pass for function names containing 'foo',
        `foo | bar` all passes for function names containing 'foo' or 'bar'.
    -Z                   dump-mir-dir=val -- the directory the MIR is dumped into
...
```

Fixes rust-lang#56558
@Ryvian
Copy link

Ryvian commented Aug 6, 2019

Is there any way to dump only the ordinary MIR file (like rustc.main.003-027.PreCodegen.after.mir) without producing any promoted MIR files (like rustc.main-promoted[1].003-027.PreCodegen.after.mir)?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants