Skip to content

Commit 7b56ce0

Browse files
committed
Add a MIR pre-codegen test for derived PartialOrd
1 parent 5c97719 commit 7b56ce0

File tree

2 files changed

+291
-0
lines changed

2 files changed

+291
-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=2
3+
4+
#![crate_type = "lib"]
5+
6+
#[derive(PartialOrd, PartialEq)]
7+
pub struct MultiField(u64, 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,282 @@
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: &u64;
8+
let mut _4: &u64;
9+
let mut _12: std::option::Option<std::cmp::Ordering>;
10+
let mut _13: isize;
11+
let mut _14: i8;
12+
let mut _15: &char;
13+
let mut _16: &char;
14+
let mut _24: std::option::Option<std::cmp::Ordering>;
15+
let mut _25: isize;
16+
let mut _26: i8;
17+
let mut _27: &i16;
18+
let mut _28: &i16;
19+
scope 1 {
20+
debug cmp => _24;
21+
}
22+
scope 2 {
23+
debug cmp => _12;
24+
}
25+
scope 3 (inlined cmp::impls::<impl PartialOrd for u64>::partial_cmp) {
26+
debug self => _3;
27+
debug other => _4;
28+
let mut _11: std::cmp::Ordering;
29+
scope 4 (inlined cmp::impls::<impl Ord for u64>::cmp) {
30+
debug self => _3;
31+
debug other => _4;
32+
let mut _5: u64;
33+
let mut _6: u64;
34+
let mut _7: bool;
35+
let mut _8: u64;
36+
let mut _9: u64;
37+
let mut _10: bool;
38+
}
39+
}
40+
scope 5 (inlined cmp::impls::<impl PartialOrd for char>::partial_cmp) {
41+
debug self => _15;
42+
debug other => _16;
43+
let mut _23: std::cmp::Ordering;
44+
scope 6 (inlined cmp::impls::<impl Ord for char>::cmp) {
45+
debug self => _15;
46+
debug other => _16;
47+
let mut _17: char;
48+
let mut _18: char;
49+
let mut _19: bool;
50+
let mut _20: char;
51+
let mut _21: char;
52+
let mut _22: bool;
53+
}
54+
}
55+
scope 7 (inlined cmp::impls::<impl PartialOrd for i16>::partial_cmp) {
56+
debug self => _27;
57+
debug other => _28;
58+
let mut _35: std::cmp::Ordering;
59+
scope 8 (inlined cmp::impls::<impl Ord for i16>::cmp) {
60+
debug self => _27;
61+
debug other => _28;
62+
let mut _29: i16;
63+
let mut _30: i16;
64+
let mut _31: bool;
65+
let mut _32: i16;
66+
let mut _33: i16;
67+
let mut _34: bool;
68+
}
69+
}
70+
71+
bb0: {
72+
StorageLive(_3);
73+
_3 = &((*_1).0: u64);
74+
StorageLive(_4);
75+
_4 = &((*_2).0: u64);
76+
StorageLive(_11);
77+
StorageLive(_7);
78+
StorageLive(_5);
79+
_5 = ((*_1).0: u64);
80+
StorageLive(_6);
81+
_6 = ((*_2).0: u64);
82+
_7 = Lt(move _5, move _6);
83+
switchInt(move _7) -> [0: bb1, otherwise: bb5];
84+
}
85+
86+
bb1: {
87+
StorageDead(_6);
88+
StorageDead(_5);
89+
StorageLive(_10);
90+
StorageLive(_8);
91+
_8 = ((*_1).0: u64);
92+
StorageLive(_9);
93+
_9 = ((*_2).0: u64);
94+
_10 = Eq(move _8, move _9);
95+
switchInt(move _10) -> [0: bb2, otherwise: bb3];
96+
}
97+
98+
bb2: {
99+
StorageDead(_9);
100+
StorageDead(_8);
101+
_11 = const Greater;
102+
goto -> bb4;
103+
}
104+
105+
bb3: {
106+
StorageDead(_9);
107+
StorageDead(_8);
108+
_11 = const Equal;
109+
goto -> bb4;
110+
}
111+
112+
bb4: {
113+
StorageDead(_10);
114+
goto -> bb6;
115+
}
116+
117+
bb5: {
118+
StorageDead(_6);
119+
StorageDead(_5);
120+
_11 = const Less;
121+
goto -> bb6;
122+
}
123+
124+
bb6: {
125+
StorageDead(_7);
126+
_12 = Option::<std::cmp::Ordering>::Some(move _11);
127+
StorageDead(_11);
128+
StorageDead(_4);
129+
StorageDead(_3);
130+
_13 = discriminant(_12);
131+
switchInt(move _13) -> [1: bb7, otherwise: bb24];
132+
}
133+
134+
bb7: {
135+
_14 = discriminant(((_12 as Some).0: std::cmp::Ordering));
136+
switchInt(move _14) -> [0: bb8, otherwise: bb24];
137+
}
138+
139+
bb8: {
140+
StorageLive(_15);
141+
_15 = &((*_1).1: char);
142+
StorageLive(_16);
143+
_16 = &((*_2).1: char);
144+
StorageLive(_23);
145+
StorageLive(_19);
146+
StorageLive(_17);
147+
_17 = ((*_1).1: char);
148+
StorageLive(_18);
149+
_18 = ((*_2).1: char);
150+
_19 = Lt(move _17, move _18);
151+
switchInt(move _19) -> [0: bb9, otherwise: bb13];
152+
}
153+
154+
bb9: {
155+
StorageDead(_18);
156+
StorageDead(_17);
157+
StorageLive(_22);
158+
StorageLive(_20);
159+
_20 = ((*_1).1: char);
160+
StorageLive(_21);
161+
_21 = ((*_2).1: char);
162+
_22 = Eq(move _20, move _21);
163+
switchInt(move _22) -> [0: bb10, otherwise: bb11];
164+
}
165+
166+
bb10: {
167+
StorageDead(_21);
168+
StorageDead(_20);
169+
_23 = const Greater;
170+
goto -> bb12;
171+
}
172+
173+
bb11: {
174+
StorageDead(_21);
175+
StorageDead(_20);
176+
_23 = const Equal;
177+
goto -> bb12;
178+
}
179+
180+
bb12: {
181+
StorageDead(_22);
182+
goto -> bb14;
183+
}
184+
185+
bb13: {
186+
StorageDead(_18);
187+
StorageDead(_17);
188+
_23 = const Less;
189+
goto -> bb14;
190+
}
191+
192+
bb14: {
193+
StorageDead(_19);
194+
_24 = Option::<std::cmp::Ordering>::Some(move _23);
195+
StorageDead(_23);
196+
StorageDead(_16);
197+
StorageDead(_15);
198+
_25 = discriminant(_24);
199+
switchInt(move _25) -> [1: bb15, otherwise: bb23];
200+
}
201+
202+
bb15: {
203+
_26 = discriminant(((_24 as Some).0: std::cmp::Ordering));
204+
switchInt(move _26) -> [0: bb16, otherwise: bb23];
205+
}
206+
207+
bb16: {
208+
StorageLive(_27);
209+
_27 = &((*_1).2: i16);
210+
StorageLive(_28);
211+
_28 = &((*_2).2: i16);
212+
StorageLive(_35);
213+
StorageLive(_31);
214+
StorageLive(_29);
215+
_29 = ((*_1).2: i16);
216+
StorageLive(_30);
217+
_30 = ((*_2).2: i16);
218+
_31 = Lt(move _29, move _30);
219+
switchInt(move _31) -> [0: bb17, otherwise: bb21];
220+
}
221+
222+
bb17: {
223+
StorageDead(_30);
224+
StorageDead(_29);
225+
StorageLive(_34);
226+
StorageLive(_32);
227+
_32 = ((*_1).2: i16);
228+
StorageLive(_33);
229+
_33 = ((*_2).2: i16);
230+
_34 = Eq(move _32, move _33);
231+
switchInt(move _34) -> [0: bb18, otherwise: bb19];
232+
}
233+
234+
bb18: {
235+
StorageDead(_33);
236+
StorageDead(_32);
237+
_35 = const Greater;
238+
goto -> bb20;
239+
}
240+
241+
bb19: {
242+
StorageDead(_33);
243+
StorageDead(_32);
244+
_35 = const Equal;
245+
goto -> bb20;
246+
}
247+
248+
bb20: {
249+
StorageDead(_34);
250+
goto -> bb22;
251+
}
252+
253+
bb21: {
254+
StorageDead(_30);
255+
StorageDead(_29);
256+
_35 = const Less;
257+
goto -> bb22;
258+
}
259+
260+
bb22: {
261+
StorageDead(_31);
262+
_0 = Option::<std::cmp::Ordering>::Some(move _35);
263+
StorageDead(_35);
264+
StorageDead(_28);
265+
StorageDead(_27);
266+
goto -> bb25;
267+
}
268+
269+
bb23: {
270+
_0 = _24;
271+
goto -> bb25;
272+
}
273+
274+
bb24: {
275+
_0 = _12;
276+
goto -> bb25;
277+
}
278+
279+
bb25: {
280+
return;
281+
}
282+
}

0 commit comments

Comments
 (0)