Skip to content

Commit fe644eb

Browse files
authored
Rollup merge of rust-lang#144875 - scottmcm:more-mir-tests, r=cjgillot
Add some pre-codegen MIR tests for debug mode No functional changes; just some tests. I made these for rust-lang#144483, but that's going in a different direction, so I wanted to propose we just add them to help see the impact of other related changes in the future. r? mir
2 parents 7307dc0 + e1a38ec commit fe644eb

10 files changed

+403
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ compile-flags: -Copt-level=0 -Zmir-opt-level=1 -Cdebuginfo=limited
2+
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
3+
4+
#![crate_type = "lib"]
5+
6+
#[derive(PartialOrd, Ord, PartialEq, Eq)]
7+
pub struct MultiField(char, i16);
8+
9+
// EMIT_MIR derived_ord_debug.{impl#0}-partial_cmp.PreCodegen.after.mir
10+
// EMIT_MIR derived_ord_debug.{impl#1}-cmp.PreCodegen.after.mir
11+
12+
// CHECK-LABEL: partial_cmp(_1: &MultiField, _2: &MultiField) -> Option<std::cmp::Ordering>
13+
// CHECK: = <char as PartialOrd>::partial_cmp(
14+
// CHECK: = <i16 as PartialOrd>::partial_cmp(
15+
16+
// CHECK-LABEL: cmp(_1: &MultiField, _2: &MultiField) -> std::cmp::Ordering
17+
// CHECK: = <char as Ord>::cmp(
18+
// CHECK: = <i16 as Ord>::cmp(
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// MIR for `<impl at $DIR/derived_ord_debug.rs:6:10: 6:20>::partial_cmp` after PreCodegen
2+
3+
fn <impl at $DIR/derived_ord_debug.rs:6:10: 6:20>::partial_cmp(_1: &MultiField, _2: &MultiField) -> Option<std::cmp::Ordering> {
4+
debug self => _1;
5+
debug other => _2;
6+
let mut _0: std::option::Option<std::cmp::Ordering>;
7+
let _3: &char;
8+
let _4: &char;
9+
let mut _5: std::option::Option<std::cmp::Ordering>;
10+
let mut _6: isize;
11+
let mut _7: i8;
12+
let _8: &i16;
13+
let _9: &i16;
14+
scope 1 {
15+
debug cmp => _5;
16+
}
17+
18+
bb0: {
19+
_3 = &((*_1).0: char);
20+
_4 = &((*_2).0: char);
21+
_5 = <char as PartialOrd>::partial_cmp(copy _3, copy _4) -> [return: bb1, unwind unreachable];
22+
}
23+
24+
bb1: {
25+
_6 = discriminant(_5);
26+
switchInt(move _6) -> [1: bb2, 0: bb4, otherwise: bb6];
27+
}
28+
29+
bb2: {
30+
_7 = discriminant(((_5 as Some).0: std::cmp::Ordering));
31+
switchInt(move _7) -> [0: bb3, otherwise: bb4];
32+
}
33+
34+
bb3: {
35+
_8 = &((*_1).1: i16);
36+
_9 = &((*_2).1: i16);
37+
_0 = <i16 as PartialOrd>::partial_cmp(copy _8, copy _9) -> [return: bb5, unwind unreachable];
38+
}
39+
40+
bb4: {
41+
_0 = copy _5;
42+
goto -> bb5;
43+
}
44+
45+
bb5: {
46+
return;
47+
}
48+
49+
bb6: {
50+
unreachable;
51+
}
52+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// MIR for `<impl at $DIR/derived_ord_debug.rs:6:10: 6:20>::partial_cmp` after PreCodegen
2+
3+
fn <impl at $DIR/derived_ord_debug.rs:6:10: 6:20>::partial_cmp(_1: &MultiField, _2: &MultiField) -> Option<std::cmp::Ordering> {
4+
debug self => _1;
5+
debug other => _2;
6+
let mut _0: std::option::Option<std::cmp::Ordering>;
7+
let _3: &char;
8+
let _4: &char;
9+
let mut _5: std::option::Option<std::cmp::Ordering>;
10+
let mut _6: isize;
11+
let mut _7: i8;
12+
let _8: &i16;
13+
let _9: &i16;
14+
scope 1 {
15+
debug cmp => _5;
16+
}
17+
18+
bb0: {
19+
_3 = &((*_1).0: char);
20+
_4 = &((*_2).0: char);
21+
_5 = <char as PartialOrd>::partial_cmp(copy _3, copy _4) -> [return: bb1, unwind continue];
22+
}
23+
24+
bb1: {
25+
_6 = discriminant(_5);
26+
switchInt(move _6) -> [1: bb2, 0: bb4, otherwise: bb6];
27+
}
28+
29+
bb2: {
30+
_7 = discriminant(((_5 as Some).0: std::cmp::Ordering));
31+
switchInt(move _7) -> [0: bb3, otherwise: bb4];
32+
}
33+
34+
bb3: {
35+
_8 = &((*_1).1: i16);
36+
_9 = &((*_2).1: i16);
37+
_0 = <i16 as PartialOrd>::partial_cmp(copy _8, copy _9) -> [return: bb5, unwind continue];
38+
}
39+
40+
bb4: {
41+
_0 = copy _5;
42+
goto -> bb5;
43+
}
44+
45+
bb5: {
46+
return;
47+
}
48+
49+
bb6: {
50+
unreachable;
51+
}
52+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// MIR for `<impl at $DIR/derived_ord_debug.rs:6:22: 6:25>::cmp` after PreCodegen
2+
3+
fn <impl at $DIR/derived_ord_debug.rs:6:22: 6:25>::cmp(_1: &MultiField, _2: &MultiField) -> std::cmp::Ordering {
4+
debug self => _1;
5+
debug other => _2;
6+
let mut _0: std::cmp::Ordering;
7+
let _3: &char;
8+
let _4: &char;
9+
let mut _5: std::cmp::Ordering;
10+
let mut _6: i8;
11+
let _7: &i16;
12+
let _8: &i16;
13+
scope 1 {
14+
debug cmp => _5;
15+
}
16+
17+
bb0: {
18+
_3 = &((*_1).0: char);
19+
_4 = &((*_2).0: char);
20+
_5 = <char as Ord>::cmp(copy _3, copy _4) -> [return: bb1, unwind unreachable];
21+
}
22+
23+
bb1: {
24+
_6 = discriminant(_5);
25+
switchInt(move _6) -> [0: bb2, otherwise: bb3];
26+
}
27+
28+
bb2: {
29+
_7 = &((*_1).1: i16);
30+
_8 = &((*_2).1: i16);
31+
_0 = <i16 as Ord>::cmp(copy _7, copy _8) -> [return: bb4, unwind unreachable];
32+
}
33+
34+
bb3: {
35+
_0 = copy _5;
36+
goto -> bb4;
37+
}
38+
39+
bb4: {
40+
return;
41+
}
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// MIR for `<impl at $DIR/derived_ord_debug.rs:6:22: 6:25>::cmp` after PreCodegen
2+
3+
fn <impl at $DIR/derived_ord_debug.rs:6:22: 6:25>::cmp(_1: &MultiField, _2: &MultiField) -> std::cmp::Ordering {
4+
debug self => _1;
5+
debug other => _2;
6+
let mut _0: std::cmp::Ordering;
7+
let _3: &char;
8+
let _4: &char;
9+
let mut _5: std::cmp::Ordering;
10+
let mut _6: i8;
11+
let _7: &i16;
12+
let _8: &i16;
13+
scope 1 {
14+
debug cmp => _5;
15+
}
16+
17+
bb0: {
18+
_3 = &((*_1).0: char);
19+
_4 = &((*_2).0: char);
20+
_5 = <char as Ord>::cmp(copy _3, copy _4) -> [return: bb1, unwind continue];
21+
}
22+
23+
bb1: {
24+
_6 = discriminant(_5);
25+
switchInt(move _6) -> [0: bb2, otherwise: bb3];
26+
}
27+
28+
bb2: {
29+
_7 = &((*_1).1: i16);
30+
_8 = &((*_2).1: i16);
31+
_0 = <i16 as Ord>::cmp(copy _7, copy _8) -> [return: bb4, unwind continue];
32+
}
33+
34+
bb3: {
35+
_0 = copy _5;
36+
goto -> bb4;
37+
}
38+
39+
bb4: {
40+
return;
41+
}
42+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// MIR for `option_direct` after PreCodegen
2+
3+
fn option_direct(_1: Option<u32>) -> Option<u32> {
4+
debug x => _1;
5+
let mut _0: std::option::Option<u32>;
6+
let mut _2: isize;
7+
let _3: u32;
8+
let mut _4: u32;
9+
scope 1 {
10+
debug x => _3;
11+
}
12+
13+
bb0: {
14+
_2 = discriminant(_1);
15+
switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb4];
16+
}
17+
18+
bb1: {
19+
_0 = Option::<u32>::None;
20+
goto -> bb3;
21+
}
22+
23+
bb2: {
24+
_3 = copy ((_1 as Some).0: u32);
25+
_4 = Not(copy _3);
26+
_0 = Option::<u32>::Some(move _4);
27+
goto -> bb3;
28+
}
29+
30+
bb3: {
31+
return;
32+
}
33+
34+
bb4: {
35+
unreachable;
36+
}
37+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// MIR for `option_direct` after PreCodegen
2+
3+
fn option_direct(_1: Option<u32>) -> Option<u32> {
4+
debug x => _1;
5+
let mut _0: std::option::Option<u32>;
6+
let mut _2: isize;
7+
let _3: u32;
8+
let mut _4: u32;
9+
scope 1 {
10+
debug x => _3;
11+
}
12+
13+
bb0: {
14+
_2 = discriminant(_1);
15+
switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb4];
16+
}
17+
18+
bb1: {
19+
_0 = Option::<u32>::None;
20+
goto -> bb3;
21+
}
22+
23+
bb2: {
24+
_3 = copy ((_1 as Some).0: u32);
25+
_4 = Not(copy _3);
26+
_0 = Option::<u32>::Some(move _4);
27+
goto -> bb3;
28+
}
29+
30+
bb3: {
31+
return;
32+
}
33+
34+
bb4: {
35+
unreachable;
36+
}
37+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// MIR for `option_traits` after PreCodegen
2+
3+
fn option_traits(_1: Option<u32>) -> Option<u32> {
4+
debug x => _1;
5+
let mut _0: std::option::Option<u32>;
6+
let mut _2: std::ops::ControlFlow<std::option::Option<std::convert::Infallible>, u32>;
7+
let mut _3: isize;
8+
let _4: u32;
9+
let mut _5: u32;
10+
scope 1 {
11+
debug residual => const Option::<Infallible>::None;
12+
scope 2 {
13+
}
14+
}
15+
scope 3 {
16+
debug val => _4;
17+
scope 4 {
18+
}
19+
}
20+
21+
bb0: {
22+
_2 = <Option<u32> as Try>::branch(copy _1) -> [return: bb1, unwind unreachable];
23+
}
24+
25+
bb1: {
26+
_3 = discriminant(_2);
27+
switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb5];
28+
}
29+
30+
bb2: {
31+
_4 = copy ((_2 as Continue).0: u32);
32+
_5 = Not(copy _4);
33+
_0 = <Option<u32> as Try>::from_output(move _5) -> [return: bb4, unwind unreachable];
34+
}
35+
36+
bb3: {
37+
_0 = <Option<u32> as FromResidual<Option<Infallible>>>::from_residual(const Option::<Infallible>::None) -> [return: bb4, unwind unreachable];
38+
}
39+
40+
bb4: {
41+
return;
42+
}
43+
44+
bb5: {
45+
unreachable;
46+
}
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// MIR for `option_traits` after PreCodegen
2+
3+
fn option_traits(_1: Option<u32>) -> Option<u32> {
4+
debug x => _1;
5+
let mut _0: std::option::Option<u32>;
6+
let mut _2: std::ops::ControlFlow<std::option::Option<std::convert::Infallible>, u32>;
7+
let mut _3: isize;
8+
let _4: u32;
9+
let mut _5: u32;
10+
scope 1 {
11+
debug residual => const Option::<Infallible>::None;
12+
scope 2 {
13+
}
14+
}
15+
scope 3 {
16+
debug val => _4;
17+
scope 4 {
18+
}
19+
}
20+
21+
bb0: {
22+
_2 = <Option<u32> as Try>::branch(copy _1) -> [return: bb1, unwind continue];
23+
}
24+
25+
bb1: {
26+
_3 = discriminant(_2);
27+
switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb5];
28+
}
29+
30+
bb2: {
31+
_4 = copy ((_2 as Continue).0: u32);
32+
_5 = Not(copy _4);
33+
_0 = <Option<u32> as Try>::from_output(move _5) -> [return: bb4, unwind continue];
34+
}
35+
36+
bb3: {
37+
_0 = <Option<u32> as FromResidual<Option<Infallible>>>::from_residual(const Option::<Infallible>::None) -> [return: bb4, unwind continue];
38+
}
39+
40+
bb4: {
41+
return;
42+
}
43+
44+
bb5: {
45+
unreachable;
46+
}
47+
}

0 commit comments

Comments
 (0)