Skip to content

Commit 2d03399

Browse files
committed
Auto merge of #71200 - oli-obk:mir_bless, r=eddyb
Emit basic block info for stmts and terminators in MIR dumps only with -Zverbose r? @eddyb as per #70755 (comment)
2 parents 46ec74e + a2fdc94 commit 2d03399

File tree

141 files changed

+3004
-3067
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+3004
-3067
lines changed

src/librustc_mir/util/pretty.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,9 @@ where
305305
let indented_body = format!("{0}{0}{1:?};", INDENT, statement);
306306
writeln!(
307307
w,
308-
"{:A$} // {:?}: {}",
308+
"{:A$} // {}{}",
309309
indented_body,
310-
current_location,
310+
if tcx.sess.verbose() { format!("{:?}: ", current_location) } else { String::new() },
311311
comment(tcx, statement.source_info),
312312
A = ALIGN,
313313
)?;
@@ -326,9 +326,9 @@ where
326326
let indented_terminator = format!("{0}{0}{1:?};", INDENT, data.terminator().kind);
327327
writeln!(
328328
w,
329-
"{:A$} // {:?}: {}",
329+
"{:A$} // {}{}",
330330
indented_terminator,
331-
current_location,
331+
if tcx.sess.verbose() { format!("{:?}: ", current_location) } else { String::new() },
332332
comment(tcx, data.terminator().source_info),
333333
A = ALIGN,
334334
)?;
@@ -455,7 +455,7 @@ fn write_scope_tree(
455455
)?;
456456
}
457457

458-
// Local variable types (including the user's name in a comment).
458+
// Local variable types.
459459
for (local, local_decl) in body.local_decls.iter_enumerated() {
460460
if (1..body.arg_count + 1).contains(&local.index()) {
461461
// Skip over argument locals, they're printed in the signature.

src/test/mir-opt/address-of/rustc.address_of_reborrow.SimplifyCfg-initial.after.mir

+178-178
Large diffs are not rendered by default.

src/test/mir-opt/address-of/rustc.borrow_and_cast.SimplifyCfg-initial.after.mir

+23-23
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,34 @@ fn borrow_and_cast(_1: i32) -> () {
2020
}
2121

2222
bb0: {
23-
StorageLive(_2); // bb0[0]: scope 0 at $DIR/address-of.rs:42:9: 42:10
24-
StorageLive(_3); // bb0[1]: scope 0 at $DIR/address-of.rs:42:13: 42:15
25-
_3 = &_1; // bb0[2]: scope 0 at $DIR/address-of.rs:42:13: 42:15
26-
_2 = &raw const (*_3); // bb0[3]: scope 0 at $DIR/address-of.rs:42:13: 42:15
27-
FakeRead(ForLet, _2); // bb0[4]: scope 0 at $DIR/address-of.rs:42:9: 42:10
28-
StorageDead(_3); // bb0[5]: scope 0 at $DIR/address-of.rs:42:29: 42:30
29-
StorageLive(_4); // bb0[6]: scope 1 at $DIR/address-of.rs:43:9: 43:10
30-
StorageLive(_5); // bb0[7]: scope 1 at $DIR/address-of.rs:43:13: 43:19
31-
_5 = &mut _1; // bb0[8]: scope 1 at $DIR/address-of.rs:43:13: 43:19
32-
_4 = &raw const (*_5); // bb0[9]: scope 1 at $DIR/address-of.rs:43:13: 43:19
33-
FakeRead(ForLet, _4); // bb0[10]: scope 1 at $DIR/address-of.rs:43:9: 43:10
34-
StorageDead(_5); // bb0[11]: scope 1 at $DIR/address-of.rs:43:33: 43:34
35-
StorageLive(_6); // bb0[12]: scope 2 at $DIR/address-of.rs:44:9: 44:10
36-
StorageLive(_7); // bb0[13]: scope 2 at $DIR/address-of.rs:44:13: 44:19
37-
_7 = &mut _1; // bb0[14]: scope 2 at $DIR/address-of.rs:44:13: 44:19
38-
_6 = &raw mut (*_7); // bb0[15]: scope 2 at $DIR/address-of.rs:44:13: 44:19
39-
FakeRead(ForLet, _6); // bb0[16]: scope 2 at $DIR/address-of.rs:44:9: 44:10
40-
StorageDead(_7); // bb0[17]: scope 2 at $DIR/address-of.rs:44:31: 44:32
41-
_0 = const (); // bb0[18]: scope 0 at $DIR/address-of.rs:41:32: 45:2
23+
StorageLive(_2); // scope 0 at $DIR/address-of.rs:42:9: 42:10
24+
StorageLive(_3); // scope 0 at $DIR/address-of.rs:42:13: 42:15
25+
_3 = &_1; // scope 0 at $DIR/address-of.rs:42:13: 42:15
26+
_2 = &raw const (*_3); // scope 0 at $DIR/address-of.rs:42:13: 42:15
27+
FakeRead(ForLet, _2); // scope 0 at $DIR/address-of.rs:42:9: 42:10
28+
StorageDead(_3); // scope 0 at $DIR/address-of.rs:42:29: 42:30
29+
StorageLive(_4); // scope 1 at $DIR/address-of.rs:43:9: 43:10
30+
StorageLive(_5); // scope 1 at $DIR/address-of.rs:43:13: 43:19
31+
_5 = &mut _1; // scope 1 at $DIR/address-of.rs:43:13: 43:19
32+
_4 = &raw const (*_5); // scope 1 at $DIR/address-of.rs:43:13: 43:19
33+
FakeRead(ForLet, _4); // scope 1 at $DIR/address-of.rs:43:9: 43:10
34+
StorageDead(_5); // scope 1 at $DIR/address-of.rs:43:33: 43:34
35+
StorageLive(_6); // scope 2 at $DIR/address-of.rs:44:9: 44:10
36+
StorageLive(_7); // scope 2 at $DIR/address-of.rs:44:13: 44:19
37+
_7 = &mut _1; // scope 2 at $DIR/address-of.rs:44:13: 44:19
38+
_6 = &raw mut (*_7); // scope 2 at $DIR/address-of.rs:44:13: 44:19
39+
FakeRead(ForLet, _6); // scope 2 at $DIR/address-of.rs:44:9: 44:10
40+
StorageDead(_7); // scope 2 at $DIR/address-of.rs:44:31: 44:32
41+
_0 = const (); // scope 0 at $DIR/address-of.rs:41:32: 45:2
4242
// ty::Const
4343
// + ty: ()
4444
// + val: Value(Scalar(<ZST>))
4545
// mir::Constant
4646
// + span: $DIR/address-of.rs:41:32: 45:2
4747
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
48-
StorageDead(_6); // bb0[19]: scope 2 at $DIR/address-of.rs:45:1: 45:2
49-
StorageDead(_4); // bb0[20]: scope 1 at $DIR/address-of.rs:45:1: 45:2
50-
StorageDead(_2); // bb0[21]: scope 0 at $DIR/address-of.rs:45:1: 45:2
51-
return; // bb0[22]: scope 0 at $DIR/address-of.rs:45:2: 45:2
48+
StorageDead(_6); // scope 2 at $DIR/address-of.rs:45:1: 45:2
49+
StorageDead(_4); // scope 1 at $DIR/address-of.rs:45:1: 45:2
50+
StorageDead(_2); // scope 0 at $DIR/address-of.rs:45:1: 45:2
51+
return; // scope 0 at $DIR/address-of.rs:45:2: 45:2
5252
}
5353
}

src/test/mir-opt/array-index-is-temporary/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir

+27-27
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ fn main() -> () {
2424
}
2525

2626
bb0: {
27-
StorageLive(_1); // bb0[0]: scope 0 at $DIR/array-index-is-temporary.rs:13:9: 13:14
28-
_1 = [const 42u32, const 43u32, const 44u32]; // bb0[1]: scope 0 at $DIR/array-index-is-temporary.rs:13:17: 13:29
27+
StorageLive(_1); // scope 0 at $DIR/array-index-is-temporary.rs:13:9: 13:14
28+
_1 = [const 42u32, const 43u32, const 44u32]; // scope 0 at $DIR/array-index-is-temporary.rs:13:17: 13:29
2929
// ty::Const
3030
// + ty: u32
3131
// + val: Value(Scalar(0x0000002a))
@@ -44,23 +44,23 @@ fn main() -> () {
4444
// mir::Constant
4545
// + span: $DIR/array-index-is-temporary.rs:13:26: 13:28
4646
// + literal: Const { ty: u32, val: Value(Scalar(0x0000002c)) }
47-
StorageLive(_2); // bb0[2]: scope 1 at $DIR/array-index-is-temporary.rs:14:9: 14:14
48-
_2 = const 1usize; // bb0[3]: scope 1 at $DIR/array-index-is-temporary.rs:14:17: 14:18
47+
StorageLive(_2); // scope 1 at $DIR/array-index-is-temporary.rs:14:9: 14:14
48+
_2 = const 1usize; // scope 1 at $DIR/array-index-is-temporary.rs:14:17: 14:18
4949
// ty::Const
5050
// + ty: usize
5151
// + val: Value(Scalar(0x00000001))
5252
// mir::Constant
5353
// + span: $DIR/array-index-is-temporary.rs:14:17: 14:18
5454
// + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) }
55-
StorageLive(_3); // bb0[4]: scope 2 at $DIR/array-index-is-temporary.rs:15:9: 15:10
56-
StorageLive(_4); // bb0[5]: scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31
57-
_4 = &mut _2; // bb0[6]: scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31
58-
_3 = &raw mut (*_4); // bb0[7]: scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31
59-
StorageDead(_4); // bb0[8]: scope 2 at $DIR/array-index-is-temporary.rs:15:31: 15:32
60-
StorageLive(_5); // bb0[9]: scope 3 at $DIR/array-index-is-temporary.rs:16:12: 16:29
61-
StorageLive(_6); // bb0[10]: scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
62-
_6 = _3; // bb0[11]: scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
63-
_5 = const foo(move _6) -> bb1; // bb0[12]: scope 4 at $DIR/array-index-is-temporary.rs:16:21: 16:27
55+
StorageLive(_3); // scope 2 at $DIR/array-index-is-temporary.rs:15:9: 15:10
56+
StorageLive(_4); // scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31
57+
_4 = &mut _2; // scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31
58+
_3 = &raw mut (*_4); // scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31
59+
StorageDead(_4); // scope 2 at $DIR/array-index-is-temporary.rs:15:31: 15:32
60+
StorageLive(_5); // scope 3 at $DIR/array-index-is-temporary.rs:16:12: 16:29
61+
StorageLive(_6); // scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
62+
_6 = _3; // scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
63+
_5 = const foo(move _6) -> bb1; // scope 4 at $DIR/array-index-is-temporary.rs:16:21: 16:27
6464
// ty::Const
6565
// + ty: unsafe fn(*mut usize) -> u32 {foo}
6666
// + val: Value(Scalar(<ZST>))
@@ -70,28 +70,28 @@ fn main() -> () {
7070
}
7171

7272
bb1: {
73-
StorageDead(_6); // bb1[0]: scope 4 at $DIR/array-index-is-temporary.rs:16:26: 16:27
74-
StorageLive(_7); // bb1[1]: scope 3 at $DIR/array-index-is-temporary.rs:16:7: 16:8
75-
_7 = _2; // bb1[2]: scope 3 at $DIR/array-index-is-temporary.rs:16:7: 16:8
76-
_8 = Len(_1); // bb1[3]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9
77-
_9 = Lt(_7, _8); // bb1[4]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9
78-
assert(move _9, "index out of bounds: the len is {} but the index is {}", move _8, _7) -> bb2; // bb1[5]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9
73+
StorageDead(_6); // scope 4 at $DIR/array-index-is-temporary.rs:16:26: 16:27
74+
StorageLive(_7); // scope 3 at $DIR/array-index-is-temporary.rs:16:7: 16:8
75+
_7 = _2; // scope 3 at $DIR/array-index-is-temporary.rs:16:7: 16:8
76+
_8 = Len(_1); // scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9
77+
_9 = Lt(_7, _8); // scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9
78+
assert(move _9, "index out of bounds: the len is {} but the index is {}", move _8, _7) -> bb2; // scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9
7979
}
8080

8181
bb2: {
82-
_1[_7] = move _5; // bb2[0]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:29
83-
StorageDead(_5); // bb2[1]: scope 3 at $DIR/array-index-is-temporary.rs:16:28: 16:29
84-
StorageDead(_7); // bb2[2]: scope 3 at $DIR/array-index-is-temporary.rs:16:29: 16:30
85-
_0 = const (); // bb2[3]: scope 0 at $DIR/array-index-is-temporary.rs:12:11: 17:2
82+
_1[_7] = move _5; // scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:29
83+
StorageDead(_5); // scope 3 at $DIR/array-index-is-temporary.rs:16:28: 16:29
84+
StorageDead(_7); // scope 3 at $DIR/array-index-is-temporary.rs:16:29: 16:30
85+
_0 = const (); // scope 0 at $DIR/array-index-is-temporary.rs:12:11: 17:2
8686
// ty::Const
8787
// + ty: ()
8888
// + val: Value(Scalar(<ZST>))
8989
// mir::Constant
9090
// + span: $DIR/array-index-is-temporary.rs:12:11: 17:2
9191
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
92-
StorageDead(_3); // bb2[4]: scope 2 at $DIR/array-index-is-temporary.rs:17:1: 17:2
93-
StorageDead(_2); // bb2[5]: scope 1 at $DIR/array-index-is-temporary.rs:17:1: 17:2
94-
StorageDead(_1); // bb2[6]: scope 0 at $DIR/array-index-is-temporary.rs:17:1: 17:2
95-
return; // bb2[7]: scope 0 at $DIR/array-index-is-temporary.rs:17:2: 17:2
92+
StorageDead(_3); // scope 2 at $DIR/array-index-is-temporary.rs:17:1: 17:2
93+
StorageDead(_2); // scope 1 at $DIR/array-index-is-temporary.rs:17:1: 17:2
94+
StorageDead(_1); // scope 0 at $DIR/array-index-is-temporary.rs:17:1: 17:2
95+
return; // scope 0 at $DIR/array-index-is-temporary.rs:17:2: 17:2
9696
}
9797
}

0 commit comments

Comments
 (0)