Skip to content

Commit

Permalink
Replace mir_map.0 dump with built phase change dump
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobDegen committed Oct 27, 2022
1 parent 36285c5 commit c4c4c56
Show file tree
Hide file tree
Showing 52 changed files with 136 additions and 112 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ fn mir_const<'tcx>(

let mut body = tcx.mir_built(def).steal();

rustc_middle::mir::dump_mir(tcx, None, "mir_map", &0, &body, |_, _| Ok(()));
pass_manager::dump_mir_for_phase_change(tcx, &body);

pm::run_passes(
tcx,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ pub fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> Body<'_> {
span,
);

rustc_middle::mir::dump_mir(tcx, None, "mir_map", &0, &body, |_, _| Ok(()));
crate::pass_manager::dump_mir_for_phase_change(tcx, &body);

body
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `full_tested_match` after PromoteTemps
// MIR for `full_tested_match` after built

fn full_tested_match() -> () {
let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:+0:28: +0:28
Expand All @@ -12,7 +12,6 @@ fn full_tested_match() -> () {
let mut _8: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:35: +2:36
let _9: i32; // in scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15
let mut _10: i32; // in scope 0 at $DIR/match_false_edges.rs:+3:24: +3:25
let mut _11: &std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
scope 1 {
}
scope 2 {
Expand All @@ -34,15 +33,15 @@ fn full_tested_match() -> () {

bb1: {
_1 = (const 3_i32, const 3_i32); // scope 0 at $DIR/match_false_edges.rs:+4:17: +4:23
goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+4:17: +4:23
goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+4:17: +4:23
}

bb2: {
falseEdge -> [real: bb5, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+2:9: +2:16
}

bb3: {
falseEdge -> [real: bb9, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:16
falseEdge -> [real: bb10, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:16
}

bb4: {
Expand All @@ -51,14 +50,10 @@ fn full_tested_match() -> () {

bb5: {
StorageLive(_6); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
_11 = const _; // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
// mir::Constant
// + span: $DIR/match_false_edges.rs:14:14: 14:15
// + literal: Const { ty: &Option<i32>, val: Unevaluated(full_tested_match, [], Some(promoted[0])) }
_6 = &(((*_11) as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
_6 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
_4 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
_7 = guard() -> [return: bb6, unwind: bb11]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
_7 = guard() -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
// mir::Constant
// + span: $DIR/match_false_edges.rs:14:20: 14:25
// + literal: Const { ty: fn() -> bool {guard}, val: Value(<ZST>) }
Expand All @@ -80,34 +75,38 @@ fn full_tested_match() -> () {
StorageDead(_8); // scope 2 at $DIR/match_false_edges.rs:+2:36: +2:37
StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
}

bb8: {
goto -> bb9; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
}

bb9: {
StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27
StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
goto -> bb3; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
}

bb9: {
bb10: {
StorageLive(_9); // scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15
_9 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15
StorageLive(_10); // scope 3 at $DIR/match_false_edges.rs:+3:24: +3:25
_10 = _9; // scope 3 at $DIR/match_false_edges.rs:+3:24: +3:25
_1 = (const 2_i32, move _10); // scope 3 at $DIR/match_false_edges.rs:+3:20: +3:26
StorageDead(_10); // scope 3 at $DIR/match_false_edges.rs:+3:25: +3:26
StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:+3:25: +3:26
goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+3:25: +3:26
goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+3:25: +3:26
}

bb10: {
bb11: {
StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
_0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:28: +6:2
return; // scope 0 at $DIR/match_false_edges.rs:+6:2: +6:2
}

bb11 (cleanup): {
bb12 (cleanup): {
resume; // scope 0 at $DIR/match_false_edges.rs:+0:1: +6:2
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `full_tested_match2` before PromoteTemps
// MIR for `full_tested_match2` after built

fn full_tested_match2() -> () {
let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:+0:29: +0:29
Expand Down Expand Up @@ -32,7 +32,7 @@ fn full_tested_match2() -> () {
}

bb1: {
falseEdge -> [real: bb9, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:13
falseEdge -> [real: bb10, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:13
}

bb2: {
Expand All @@ -47,7 +47,7 @@ fn full_tested_match2() -> () {
_1 = (const 2_i32, move _10); // scope 3 at $DIR/match_false_edges.rs:+4:20: +4:26
StorageDead(_10); // scope 3 at $DIR/match_false_edges.rs:+4:25: +4:26
StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:+4:25: +4:26
goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+4:25: +4:26
goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+4:25: +4:26
}

bb4: {
Expand All @@ -59,7 +59,7 @@ fn full_tested_match2() -> () {
_6 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
_4 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
_7 = guard() -> [return: bb6, unwind: bb11]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
_7 = guard() -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
// mir::Constant
// + span: $DIR/match_false_edges.rs:25:20: 25:25
// + literal: Const { ty: fn() -> bool {guard}, val: Value(<ZST>) }
Expand All @@ -81,28 +81,32 @@ fn full_tested_match2() -> () {
StorageDead(_8); // scope 2 at $DIR/match_false_edges.rs:+2:36: +2:37
StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
}

bb8: {
goto -> bb9; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
}

bb9: {
StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27
StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
falseEdge -> [real: bb3, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
}

bb9: {
bb10: {
_1 = (const 3_i32, const 3_i32); // scope 0 at $DIR/match_false_edges.rs:+3:17: +3:23
goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+3:17: +3:23
goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+3:17: +3:23
}

bb10: {
bb11: {
StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
_0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:29: +6:2
return; // scope 0 at $DIR/match_false_edges.rs:+6:2: +6:2
}

bb11 (cleanup): {
bb12 (cleanup): {
resume; // scope 0 at $DIR/match_false_edges.rs:+0:1: +6:2
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `main` before PromoteTemps
// MIR for `main` after built

fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:+0:11: +0:11
Expand Down Expand Up @@ -43,41 +43,54 @@ fn main() -> () {
}

bb1: {
falseEdge -> [real: bb9, imaginary: bb4]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11
falseEdge -> [real: bb13, imaginary: bb6]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11
}

bb2: {
falseEdge -> [real: bb5, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:9: +2:17
falseEdge -> [real: bb8, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:9: +2:17
}

bb3: {
goto -> bb1; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:26
}

bb4: {
_3 = discriminant(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26
switchInt(move _3) -> [1_isize: bb6, otherwise: bb5]; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:26
}

bb5: {
StorageLive(_14); // scope 0 at $DIR/match_false_edges.rs:+5:9: +5:11
_14 = _2; // scope 0 at $DIR/match_false_edges.rs:+5:9: +5:11
_1 = const 4_i32; // scope 5 at $DIR/match_false_edges.rs:+5:15: +5:16
StorageDead(_14); // scope 0 at $DIR/match_false_edges.rs:+5:15: +5:16
goto -> bb14; // scope 0 at $DIR/match_false_edges.rs:+5:15: +5:16
goto -> bb19; // scope 0 at $DIR/match_false_edges.rs:+5:15: +5:16
}

bb4: {
falseEdge -> [real: bb10, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+4:9: +4:16
bb6: {
falseEdge -> [real: bb14, imaginary: bb5]; // scope 0 at $DIR/match_false_edges.rs:+4:9: +4:16
}

bb5: {
bb7: {
goto -> bb5; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:26
}

bb8: {
StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16
_7 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16
_5 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26
StorageLive(_8); // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28
_8 = guard() -> [return: bb6, unwind: bb15]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28
_8 = guard() -> [return: bb9, unwind: bb20]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28
// mir::Constant
// + span: $DIR/match_false_edges.rs:34:21: 34:26
// + literal: Const { ty: fn() -> bool {guard}, val: Value(<ZST>) }
}

bb6: {
switchInt(move _8) -> [false: bb8, otherwise: bb7]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28
bb9: {
switchInt(move _8) -> [false: bb11, otherwise: bb10]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28
}

bb7: {
bb10: {
StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28
FakeRead(ForMatchGuard, _5); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28
FakeRead(ForGuardBinding, _7); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28
Expand All @@ -86,41 +99,45 @@ fn main() -> () {
_1 = const 1_i32; // scope 2 at $DIR/match_false_edges.rs:+2:32: +2:33
StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33
StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33
goto -> bb14; // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33
goto -> bb19; // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33
}

bb8: {
bb11: {
goto -> bb12; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28
}

bb12: {
StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28
StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33
falseEdge -> [real: bb1, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28
falseEdge -> [real: bb3, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28
}

bb9: {
bb13: {
StorageLive(_9); // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11
_9 = _2; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11
_1 = const 2_i32; // scope 3 at $DIR/match_false_edges.rs:+3:15: +3:16
StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:+3:15: +3:16
goto -> bb14; // scope 0 at $DIR/match_false_edges.rs:+3:15: +3:16
goto -> bb19; // scope 0 at $DIR/match_false_edges.rs:+3:15: +3:16
}

bb10: {
bb14: {
StorageLive(_11); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15
_11 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15
_5 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26
StorageLive(_12); // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29
StorageLive(_13); // scope 0 at $DIR/match_false_edges.rs:+4:27: +4:28
_13 = (*_11); // scope 0 at $DIR/match_false_edges.rs:+4:27: +4:28
_12 = guard2(move _13) -> [return: bb11, unwind: bb15]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29
_12 = guard2(move _13) -> [return: bb15, unwind: bb20]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29
// mir::Constant
// + span: $DIR/match_false_edges.rs:36:20: 36:26
// + literal: Const { ty: fn(i32) -> bool {guard2}, val: Value(<ZST>) }
}

bb11: {
switchInt(move _12) -> [false: bb13, otherwise: bb12]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29
bb15: {
switchInt(move _12) -> [false: bb17, otherwise: bb16]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29
}

bb12: {
bb16: {
StorageDead(_13); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29
StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29
FakeRead(ForMatchGuard, _5); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29
Expand All @@ -130,24 +147,28 @@ fn main() -> () {
_1 = const 3_i32; // scope 4 at $DIR/match_false_edges.rs:+4:33: +4:34
StorageDead(_10); // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34
StorageDead(_11); // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34
goto -> bb14; // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34
goto -> bb19; // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34
}

bb13: {
bb17: {
goto -> bb18; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29
}

bb18: {
StorageDead(_13); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29
StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29
StorageDead(_11); // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34
falseEdge -> [real: bb3, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29
falseEdge -> [real: bb7, imaginary: bb5]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29
}

bb14: {
bb19: {
StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+6:6: +6:7
StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+6:6: +6:7
_0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:11: +7:2
return; // scope 0 at $DIR/match_false_edges.rs:+7:2: +7:2
}

bb15 (cleanup): {
bb20 (cleanup): {
resume; // scope 0 at $DIR/match_false_edges.rs:+0:1: +7:2
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn guard2(_: i32) -> bool {

// no_mangle to make sure this gets instantiated even in an executable.
#[no_mangle]
// EMIT_MIR match_false_edges.full_tested_match.PromoteTemps.after.mir
// EMIT_MIR match_false_edges.full_tested_match.built.after.mir
pub fn full_tested_match() {
let _ = match Some(42) {
Some(x) if guard() => (1, x),
Expand All @@ -19,7 +19,7 @@ pub fn full_tested_match() {

// no_mangle to make sure this gets instantiated even in an executable.
#[no_mangle]
// EMIT_MIR match_false_edges.full_tested_match2.PromoteTemps.before.mir
// EMIT_MIR match_false_edges.full_tested_match2.built.after.mir
pub fn full_tested_match2() {
let _ = match Some(42) {
Some(x) if guard() => (1, x),
Expand All @@ -28,7 +28,7 @@ pub fn full_tested_match2() {
};
}

// EMIT_MIR match_false_edges.main.PromoteTemps.before.mir
// EMIT_MIR match_false_edges.main.built.after.mir
fn main() {
let _ = match Some(1) {
Some(_w) if guard() => 1,
Expand Down
2 changes: 1 addition & 1 deletion src/test/mir-opt/const-promotion-extern-static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static mut BAR: *const &i32 = [&Y].as_ptr();
// EMIT_MIR const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir
static mut FOO: *const &i32 = [unsafe { &X }].as_ptr();

// EMIT_MIR const_promotion_extern_static.BOP.mir_map.0.mir
// EMIT_MIR const_promotion_extern_static.BOP.built.after.mir
static BOP: &i32 = &13;

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `BOP` 0 mir_map
// MIR for `BOP` after built

static BOP: &i32 = {
let mut _0: &i32; // return place in scope 0 at $DIR/const-promotion-extern-static.rs:+0:13: +0:17
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `bar` 0 mir_map
// MIR for `bar` after built

fn bar(_1: Bar) -> usize {
debug bar => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `boo` 0 mir_map
// MIR for `boo` after built

fn boo(_1: Boo) -> usize {
debug boo => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11
Expand Down
Loading

0 comments on commit c4c4c56

Please sign in to comment.