2024-06-16 03:22:58 -05:00
|
|
|
- // MIR for `array_bound` before GVN
|
|
|
|
+ // MIR for `array_bound` after GVN
|
2021-10-06 10:53:11 -05:00
|
|
|
|
|
|
|
fn array_bound(_1: usize, _2: &[u8; N]) -> u8 {
|
2023-06-06 08:47:00 -05:00
|
|
|
debug index => _1;
|
|
|
|
debug slice => _2;
|
|
|
|
let mut _0: u8;
|
|
|
|
let mut _3: bool;
|
|
|
|
let mut _4: usize;
|
|
|
|
let mut _5: usize;
|
|
|
|
let mut _6: &[u8];
|
|
|
|
let mut _7: &[u8; N];
|
|
|
|
let _8: usize;
|
|
|
|
let mut _9: usize;
|
|
|
|
let mut _10: bool;
|
2021-10-06 10:53:11 -05:00
|
|
|
|
|
|
|
bb0: {
|
2024-06-22 14:11:14 -05:00
|
|
|
- StorageLive(_3);
|
|
|
|
+ nop;
|
2023-06-06 08:47:00 -05:00
|
|
|
StorageLive(_4);
|
|
|
|
_4 = copy _1;
|
2024-06-22 14:11:14 -05:00
|
|
|
- StorageLive(_5);
|
|
|
|
+ nop;
|
2023-06-06 08:47:00 -05:00
|
|
|
StorageLive(_6);
|
|
|
|
StorageLive(_7);
|
|
|
|
_7 = &(*_2);
|
2023-07-05 13:07:03 -05:00
|
|
|
_6 = move _7 as &[u8] (PointerCoercion(Unsize));
|
2023-06-06 08:47:00 -05:00
|
|
|
StorageDead(_7);
|
2024-06-16 03:22:58 -05:00
|
|
|
- _5 = PtrMetadata(move _6);
|
2023-06-06 08:47:00 -05:00
|
|
|
+ _5 = const N;
|
|
|
|
goto -> bb1;
|
2021-10-06 10:53:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bb1: {
|
2023-06-06 08:47:00 -05:00
|
|
|
StorageDead(_6);
|
2024-06-16 03:22:58 -05:00
|
|
|
- _3 = Lt(move _4, move _5);
|
2024-06-22 14:11:14 -05:00
|
|
|
- switchInt(move _3) -> [0: bb4, otherwise: bb2];
|
|
|
|
+ _3 = Lt(copy _1, const N);
|
|
|
|
+ switchInt(copy _3) -> [0: bb4, otherwise: bb2];
|
2021-10-06 10:53:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bb2: {
|
2024-06-22 14:11:14 -05:00
|
|
|
- StorageDead(_5);
|
|
|
|
+ nop;
|
2023-06-20 03:29:39 -05:00
|
|
|
StorageDead(_4);
|
2023-06-06 08:47:00 -05:00
|
|
|
StorageLive(_8);
|
|
|
|
_8 = copy _1;
|
2024-06-16 03:22:58 -05:00
|
|
|
- _9 = Len((*_2));
|
|
|
|
- _10 = Lt(copy _8, copy _9);
|
|
|
|
- assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, copy _8) -> [success: bb3, unwind unreachable];
|
|
|
|
+ _9 = const N;
|
2024-06-22 14:11:14 -05:00
|
|
|
+ _10 = copy _3;
|
|
|
|
+ assert(copy _3, "index out of bounds: the length is {} but the index is {}", const N, copy _1) -> [success: bb3, unwind unreachable];
|
2021-10-06 10:53:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bb3: {
|
2024-06-16 03:22:58 -05:00
|
|
|
- _0 = copy (*_2)[_8];
|
|
|
|
+ _0 = copy (*_2)[_1];
|
2023-06-06 08:47:00 -05:00
|
|
|
StorageDead(_8);
|
|
|
|
goto -> bb5;
|
2021-10-06 10:53:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bb4: {
|
2024-06-22 14:11:14 -05:00
|
|
|
- StorageDead(_5);
|
|
|
|
+ nop;
|
2023-06-20 03:29:39 -05:00
|
|
|
StorageDead(_4);
|
2023-06-06 08:47:00 -05:00
|
|
|
_0 = const 42_u8;
|
|
|
|
goto -> bb5;
|
2021-10-06 10:53:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bb5: {
|
2024-06-22 14:11:14 -05:00
|
|
|
- StorageDead(_3);
|
|
|
|
+ nop;
|
2023-06-06 08:47:00 -05:00
|
|
|
return;
|
2021-10-06 10:53:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|