-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Prettify more MIR debug output and add a textual form. #30707
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This can be dumped for a particular `fn` with the attribute `#![rustc_mir(pretty = "filename.mir"]`.
\o/ textual MIR! |
@bors r+ nice. |
📌 Commit 080994a has been approved by |
bors
added a commit
that referenced
this pull request
Jan 5, 2016
r? @nikomatsakis Textual MIR can be dumped for a particular `fn` with `#![rustc_mir(pretty = "filename.mir")]`. Below is an example of the text output. ```rust struct Point { x: i32, y: i32, } fn example() -> Point { let mut e = Point { x: 1, y: 2 }; let num = 5; let plus_num = |x: i32| x + num; e.y = plus_num(e.x); e } ``` ```rust fn() -> Point { let mut var0: Point; // e let var1: i32; // num let var2: [[email protected]:84:20: 84:36 num:&i32]; // plus_num let mut tmp0: (); let mut tmp1: &i32; let mut tmp2: (); let mut tmp3: i32; let mut tmp4: &[[email protected]:84:20: 84:36 num:&i32]; let mut tmp5: i32; let mut tmp6: Point; bb0: { var0 = Point { x: 1, y: 2 }; var1 = 5; tmp1 = &var1; var2 = [[email protected]:84:20: 84:36] { num: tmp1 }; tmp4 = &var2; tmp5 = var0.0; tmp3 = tmp4(tmp5) -> [return: bb3, unwind: bb4]; } bb1: { return; } bb2: { diverge; } bb3: { drop var0.1; var0.1 = tmp3; drop tmp2; drop var2; drop var0; tmp6 = var0; return = tmp6; drop tmp6; goto -> bb1; } bb4: { drop var2; goto -> bb5; } bb5: { drop var0; goto -> bb2; } } ``` ```rust fn(arg0: &[[email protected]:84:20: 84:36 num:&i32], arg1: i32) -> i32 { let var0: i32; // x let mut tmp0: (); let mut tmp1: i32; let mut tmp2: i32; bb0: { var0 = arg1; tmp1 = var0; tmp2 = (*(*arg0).0); return = Add(tmp1, tmp2); goto -> bb1; } bb1: { return; } bb2: { diverge; } } ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
r? @nikomatsakis
Textual MIR can be dumped for a particular
fn
with#![rustc_mir(pretty = "filename.mir")]
. Below is an example of the text output.test.rs
example.mir
249-example.mir