Skip to content

Commit

Permalink
Rollup merge of #101428 - JakobDegen:build-tests, r=oli-obk
Browse files Browse the repository at this point in the history
Add mir building test directory

The first commit renames `mir-map.0` mir dumps to `built.after` dumps. I am happy to drop this commit if someone can explain the origin of the name.

The second commit moves a bunch of mir building tests into their own directory. I did my best to make sure that all of these tests are actually testing mir building, and not just incidentally using `built.after`

r? ``@oli-obk``
  • Loading branch information
notriddle authored Oct 31, 2022
2 parents 9911229 + 51b0363 commit 7e62406
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 `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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `droppy` 0 mir_map
// MIR for `droppy` after built

fn droppy() -> () {
let mut _0: (); // return place in scope 0 at $DIR/enum_cast.rs:+0:13: +0:13
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `foo` 0 mir_map
// MIR for `foo` after built

fn foo(_1: Foo) -> usize {
debug foo => _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,6 +1,6 @@
// EMIT_MIR enum_cast.foo.mir_map.0.mir
// EMIT_MIR enum_cast.bar.mir_map.0.mir
// EMIT_MIR enum_cast.boo.mir_map.0.mir
// EMIT_MIR enum_cast.foo.built.after.mir
// EMIT_MIR enum_cast.bar.built.after.mir
// EMIT_MIR enum_cast.boo.built.after.mir

enum Foo {
A
Expand All @@ -27,7 +27,7 @@ fn boo(boo: Boo) -> usize {
boo as usize
}

// EMIT_MIR enum_cast.droppy.mir_map.0.mir
// EMIT_MIR enum_cast.droppy.built.after.mir
enum Droppy {
A, B, C
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// EMIT_MIR issue_101867.main.mir_map.0.mir
// EMIT_MIR issue_101867.main.built.after.mir
fn main() {
let x: Option<u8> = Some(1);
let Some(y) = x else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// We must mark a variable whose initialization fails due to an
// abort statement as StorageDead.

// EMIT_MIR issue_49232.main.mir_map.0.mir
// EMIT_MIR issue_49232.main.built.after.mir
fn main() {
loop {
let beacon = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `main` 0 mir_map
// MIR for `main` after built

| User Type Annotations
| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option<u8>) }, span: $DIR/issue-101867.rs:3:12: 3:22, inferred_ty: std::option::Option<u8>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIR for `main` 0 mir_map
// MIR for `main` after built

fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/issue-49232.rs:+0:11: +0:11
Expand Down
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
}
}
Loading

0 comments on commit 7e62406

Please sign in to comment.