Skip to content

Commit 253b727

Browse files
committed
Auto merge of #110713 - cjgillot:track-mir-opt, r=scottmcm
Add mir-opt tests to track MIR quality. cc `@scottmcm` `@saethlin` If you have other ideas, please say so.
2 parents b72460f + 332b7f5 commit 253b727

File tree

34 files changed

+757
-170
lines changed

34 files changed

+757
-170
lines changed

tests/mir-opt/instcombine_duplicate_switch_targets_e2e.ub_if_b.PreCodegen.after.mir

Lines changed: 0 additions & 27 deletions
This file was deleted.

tests/mir-opt/lower_intrinsics_e2e.f_u64.PreCodegen.after.mir

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/mir-opt/lower_intrinsics_e2e.f_unit.PreCodegen.after.mir

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/mir-opt/pre-codegen/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The goal of this directory is to track the quality of MIR that is given to codegen in a standard `-O` condiguration.
2+
3+
As such, feel free to `--bless` whatever changes you get here, so long as doing so doesn't add substantially more MIR.

tests/mir-opt/instcombine_duplicate_switch_targets_e2e.rs renamed to tests/mir-opt/pre-codegen/duplicate_switch_targets.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
// compile-flags: -Zmir-opt-level=2 -Zinline-mir
1+
// compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=0
22
// ignore-debug: standard library debug assertions add a panic that breaks this optimization
3+
34
#![crate_type = "lib"]
45

56
pub enum Thing {
67
A,
78
B,
89
}
910

10-
// EMIT_MIR instcombine_duplicate_switch_targets_e2e.ub_if_b.PreCodegen.after.mir
11+
// EMIT_MIR duplicate_switch_targets.ub_if_b.PreCodegen.after.mir
1112
pub unsafe fn ub_if_b(t: Thing) -> Thing {
1213
match t {
1314
Thing::A => t,
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// MIR for `ub_if_b` after PreCodegen
2+
3+
fn ub_if_b(_1: Thing) -> Thing {
4+
debug t => _1; // in scope 0 at $DIR/duplicate_switch_targets.rs:+0:23: +0:24
5+
let mut _0: Thing; // return place in scope 0 at $DIR/duplicate_switch_targets.rs:+0:36: +0:41
6+
let mut _2: isize; // in scope 0 at $DIR/duplicate_switch_targets.rs:+2:9: +2:17
7+
scope 1 (inlined unreachable_unchecked) { // at $DIR/duplicate_switch_targets.rs:15:21: 15:55
8+
scope 2 {
9+
scope 3 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL
10+
}
11+
}
12+
}
13+
14+
bb0: {
15+
_2 = discriminant(_1); // scope 0 at $DIR/duplicate_switch_targets.rs:+1:11: +1:12
16+
switchInt(move _2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/duplicate_switch_targets.rs:+1:5: +1:12
17+
}
18+
19+
bb1: {
20+
unreachable; // scope 2 at $SRC_DIR/core/src/intrinsics.rs:LL:COL
21+
}
22+
23+
bb2: {
24+
_0 = move _1; // scope 0 at $DIR/duplicate_switch_targets.rs:+2:21: +2:22
25+
return; // scope 0 at $DIR/duplicate_switch_targets.rs:+5:2: +5:2
26+
}
27+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// MIR for `f_u64` after PreCodegen
2+
3+
fn f_u64() -> () {
4+
let mut _0: (); // return place in scope 0 at $DIR/intrinsics.rs:+0:16: +0:16
5+
let mut _1: u64; // in scope 0 at $DIR/intrinsics.rs:+1:5: +1:21
6+
scope 1 (inlined f_dispatch::<u64>) { // at $DIR/intrinsics.rs:19:5: 19:21
7+
debug t => const 0_u64; // in scope 1 at $DIR/intrinsics.rs:23:22: 23:23
8+
let _2: (); // in scope 1 at $DIR/intrinsics.rs:27:9: 27:21
9+
scope 2 (inlined std::mem::size_of::<u64>) { // at $DIR/intrinsics.rs:24:8: 24:32
10+
}
11+
}
12+
13+
bb0: {
14+
StorageLive(_1); // scope 0 at $DIR/intrinsics.rs:+1:5: +1:21
15+
_1 = const 0_u64; // scope 0 at $DIR/intrinsics.rs:+1:5: +1:21
16+
_2 = f_non_zst::<u64>(move _1) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/intrinsics.rs:27:9: 27:21
17+
// mir::Constant
18+
// + span: $DIR/intrinsics.rs:27:9: 27:18
19+
// + literal: Const { ty: fn(u64) {f_non_zst::<u64>}, val: Value(<ZST>) }
20+
}
21+
22+
bb1: {
23+
StorageDead(_1); // scope 0 at $DIR/intrinsics.rs:+1:5: +1:21
24+
return; // scope 0 at $DIR/intrinsics.rs:+2:2: +2:2
25+
}
26+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// MIR for `f_unit` after PreCodegen
2+
3+
fn f_unit() -> () {
4+
let mut _0: (); // return place in scope 0 at $DIR/intrinsics.rs:+0:17: +0:17
5+
scope 1 (inlined f_dispatch::<()>) { // at $DIR/intrinsics.rs:13:5: 13:19
6+
debug t => const (); // in scope 1 at $DIR/intrinsics.rs:23:22: 23:23
7+
let _1: (); // in scope 1 at $DIR/intrinsics.rs:25:9: 25:17
8+
scope 2 (inlined std::mem::size_of::<()>) { // at $DIR/intrinsics.rs:24:8: 24:32
9+
}
10+
}
11+
12+
bb0: {
13+
_1 = f_zst::<()>(const ()) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/intrinsics.rs:25:9: 25:17
14+
// mir::Constant
15+
// + span: $DIR/intrinsics.rs:25:9: 25:14
16+
// + literal: Const { ty: fn(()) {f_zst::<()>}, val: Value(<ZST>) }
17+
}
18+
19+
bb1: {
20+
return; // scope 0 at $DIR/intrinsics.rs:+2:2: +2:2
21+
}
22+
}

tests/mir-opt/lower_intrinsics_e2e.rs renamed to tests/mir-opt/pre-codegen/intrinsics.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1+
// compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2
2+
// only-64bit
3+
// ignore-debug
4+
15
// Checks that we do not have any branches in the MIR for the two tested functions.
26

37
// compile-flags: -Cpanic=abort
48
#![feature(core_intrinsics)]
59
#![crate_type = "lib"]
610

7-
// EMIT_MIR lower_intrinsics_e2e.f_unit.PreCodegen.after.mir
11+
// EMIT_MIR intrinsics.f_unit.PreCodegen.after.mir
812
pub fn f_unit() {
913
f_dispatch(());
1014
}
1115

1216

13-
// EMIT_MIR lower_intrinsics_e2e.f_u64.PreCodegen.after.mir
17+
// EMIT_MIR intrinsics.f_u64.PreCodegen.after.mir
1418
pub fn f_u64() {
1519
f_dispatch(0u64);
1620
}

0 commit comments

Comments
 (0)