Skip to content

Commit 744c664

Browse files
committed
Add a MIR pre-codegen test for derived PartialOrd
1 parent 548e14b commit 744c664

File tree

2 files changed

+168
-0
lines changed

2 files changed

+168
-0
lines changed

Diff for: tests/mir-opt/pre-codegen/derived_ord.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// skip-filecheck
2+
//@ compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=0
3+
4+
#![crate_type = "lib"]
5+
6+
#[derive(PartialOrd, PartialEq)]
7+
pub struct MultiField(char, i16);
8+
9+
// EMIT_MIR derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
// MIR for `<impl at $DIR/derived_ord.rs:6:10: 6:20>::partial_cmp` after PreCodegen
2+
3+
fn <impl at $DIR/derived_ord.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 mut _3: &char;
8+
let mut _4: &char;
9+
let mut _10: std::option::Option<std::cmp::Ordering>;
10+
let mut _11: &i16;
11+
let mut _12: &i16;
12+
let _18: std::option::Option<std::cmp::Ordering>;
13+
scope 1 {
14+
debug cmp => _18;
15+
}
16+
scope 2 (inlined std::cmp::impls::<impl PartialOrd for char>::partial_cmp) {
17+
debug self => _3;
18+
debug other => _4;
19+
let mut _9: std::cmp::Ordering;
20+
scope 3 (inlined std::cmp::impls::<impl Ord for char>::cmp) {
21+
debug self => _3;
22+
debug other => _4;
23+
let mut _5: char;
24+
let mut _6: char;
25+
let mut _7: bool;
26+
let mut _8: bool;
27+
}
28+
}
29+
scope 4 (inlined std::cmp::impls::<impl PartialOrd for i16>::partial_cmp) {
30+
debug self => _11;
31+
debug other => _12;
32+
let mut _17: std::cmp::Ordering;
33+
scope 5 (inlined std::cmp::impls::<impl Ord for i16>::cmp) {
34+
debug self => _11;
35+
debug other => _12;
36+
let mut _13: i16;
37+
let mut _14: i16;
38+
let mut _15: bool;
39+
let mut _16: bool;
40+
}
41+
}
42+
43+
bb0: {
44+
StorageLive(_3);
45+
_3 = &((*_1).0: char);
46+
StorageLive(_4);
47+
_4 = &((*_2).0: char);
48+
StorageLive(_9);
49+
StorageLive(_5);
50+
StorageLive(_6);
51+
StorageLive(_7);
52+
_5 = ((*_1).0: char);
53+
_6 = ((*_2).0: char);
54+
_7 = Lt(_5, _6);
55+
switchInt(move _7) -> [0: bb1, otherwise: bb10];
56+
}
57+
58+
bb1: {
59+
StorageLive(_8);
60+
_8 = Eq(_5, _6);
61+
switchInt(move _8) -> [0: bb2, otherwise: bb3];
62+
}
63+
64+
bb2: {
65+
_9 = const Greater;
66+
StorageDead(_8);
67+
StorageDead(_7);
68+
StorageDead(_6);
69+
StorageDead(_5);
70+
_10 = Option::<std::cmp::Ordering>::Some(move _9);
71+
StorageDead(_9);
72+
StorageDead(_4);
73+
StorageDead(_3);
74+
goto -> bb11;
75+
}
76+
77+
bb3: {
78+
StorageDead(_8);
79+
StorageDead(_7);
80+
StorageDead(_6);
81+
StorageDead(_5);
82+
StorageDead(_9);
83+
StorageDead(_4);
84+
StorageDead(_3);
85+
StorageLive(_11);
86+
_11 = &((*_1).1: i16);
87+
StorageLive(_12);
88+
_12 = &((*_2).1: i16);
89+
StorageLive(_17);
90+
StorageLive(_13);
91+
StorageLive(_14);
92+
StorageLive(_15);
93+
_13 = ((*_1).1: i16);
94+
_14 = ((*_2).1: i16);
95+
_15 = Lt(_13, _14);
96+
switchInt(move _15) -> [0: bb4, otherwise: bb8];
97+
}
98+
99+
bb4: {
100+
StorageLive(_16);
101+
_16 = Eq(_13, _14);
102+
switchInt(move _16) -> [0: bb5, otherwise: bb6];
103+
}
104+
105+
bb5: {
106+
_17 = const Greater;
107+
goto -> bb7;
108+
}
109+
110+
bb6: {
111+
_17 = const Equal;
112+
goto -> bb7;
113+
}
114+
115+
bb7: {
116+
StorageDead(_16);
117+
goto -> bb9;
118+
}
119+
120+
bb8: {
121+
_17 = const Less;
122+
goto -> bb9;
123+
}
124+
125+
bb9: {
126+
StorageDead(_15);
127+
StorageDead(_14);
128+
StorageDead(_13);
129+
_0 = Option::<std::cmp::Ordering>::Some(move _17);
130+
StorageDead(_17);
131+
StorageDead(_12);
132+
StorageDead(_11);
133+
goto -> bb12;
134+
}
135+
136+
bb10: {
137+
_9 = const Less;
138+
StorageDead(_7);
139+
StorageDead(_6);
140+
StorageDead(_5);
141+
_10 = Option::<std::cmp::Ordering>::Some(move _9);
142+
StorageDead(_9);
143+
StorageDead(_4);
144+
StorageDead(_3);
145+
goto -> bb11;
146+
}
147+
148+
bb11: {
149+
StorageLive(_18);
150+
_18 = _10;
151+
_0 = _10;
152+
StorageDead(_18);
153+
goto -> bb12;
154+
}
155+
156+
bb12: {
157+
return;
158+
}
159+
}

0 commit comments

Comments
 (0)