rust/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff
bors bf2637f4e8 Auto merge of #119954 - scottmcm:option-unwrap-failed, r=WaffleLapkin
Split out `option::unwrap_failed` like we have `result::unwrap_failed`

...and like `option::expect_failed`
2024-01-16 15:32:39 +00:00

138 lines
4.6 KiB
Diff

- // MIR for `main` before GVN
+ // MIR for `main` after GVN
fn main() -> () {
let mut _0: ();
let _1: std::alloc::Layout;
let mut _2: std::option::Option<std::alloc::Layout>;
let mut _3: *mut u8;
let mut _4: *mut [u8];
let mut _5: std::ptr::NonNull<[u8]>;
let mut _6: std::result::Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError>;
let mut _7: &std::alloc::Global;
let mut _8: std::alloc::Layout;
scope 1 {
debug layout => _1;
let mut _9: &std::alloc::Global;
scope 2 {
debug ptr => _3;
}
scope 5 (inlined <std::alloc::Global as Allocator>::allocate) {
debug self => _9;
debug layout => _8;
}
scope 6 (inlined #[track_caller] Result::<NonNull<[u8]>, std::alloc::AllocError>::unwrap) {
debug self => _6;
let mut _12: isize;
let _13: std::alloc::AllocError;
let mut _14: !;
let _15: &str;
let mut _16: &dyn std::fmt::Debug;
let mut _17: &std::alloc::AllocError;
scope 7 {
debug t => _5;
}
scope 8 {
debug e => const std::alloc::AllocError;
}
}
scope 9 (inlined NonNull::<[u8]>::as_ptr) {
debug self => _5;
let mut _18: *const [u8];
}
}
scope 3 (inlined #[track_caller] Option::<Layout>::unwrap) {
debug self => _2;
let mut _10: isize;
let mut _11: !;
scope 4 {
debug val => _1;
}
}
bb0: {
- StorageLive(_1);
+ nop;
StorageLive(_2);
- _2 = Option::<Layout>::None;
+ _2 = const Option::<Layout>::None;
StorageLive(_10);
- _10 = discriminant(_2);
- switchInt(move _10) -> [0: bb1, 1: bb2, otherwise: bb6];
+ _10 = const 0_isize;
+ switchInt(const 0_isize) -> [0: bb1, 1: bb2, otherwise: bb6];
}
bb1: {
_11 = option::unwrap_failed() -> unwind unreachable;
}
bb2: {
- _1 = move ((_2 as Some).0: std::alloc::Layout);
+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum32) }};
StorageDead(_10);
StorageDead(_2);
StorageLive(_3);
StorageLive(_4);
StorageLive(_5);
StorageLive(_6);
StorageLive(_7);
_9 = const _;
- _7 = _9;
+ _7 = const {ALLOC1<imm>: &std::alloc::Global};
StorageLive(_8);
- _8 = _1;
- _6 = std::alloc::Global::alloc_impl(move _7, move _8, const false) -> [return: bb3, unwind unreachable];
+ _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum32) }};
+ _6 = std::alloc::Global::alloc_impl(const {ALLOC1<imm>: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum32) }}, const false) -> [return: bb3, unwind unreachable];
}
bb3: {
StorageDead(_8);
StorageDead(_7);
StorageLive(_12);
StorageLive(_15);
_12 = discriminant(_6);
switchInt(move _12) -> [0: bb5, 1: bb4, otherwise: bb6];
}
bb4: {
_15 = const "called `Result::unwrap()` on an `Err` value";
StorageLive(_16);
StorageLive(_17);
_17 = &_13;
_16 = move _17 as &dyn std::fmt::Debug (PointerCoercion(Unsize));
StorageDead(_17);
_14 = result::unwrap_failed(move _15, move _16) -> unwind unreachable;
}
bb5: {
_5 = move ((_6 as Ok).0: std::ptr::NonNull<[u8]>);
StorageDead(_15);
StorageDead(_12);
StorageDead(_6);
StorageLive(_18);
_18 = (_5.0: *const [u8]);
_4 = move _18 as *mut [u8] (PtrToPtr);
StorageDead(_18);
StorageDead(_5);
_3 = move _4 as *mut u8 (PtrToPtr);
StorageDead(_4);
StorageDead(_3);
- StorageDead(_1);
+ nop;
return;
}
bb6: {
unreachable;
}
}
+
+ ALLOC0 (size: 8, align: 4) {
+ 00 00 00 00 __ __ __ __ │ ....░░░░
+ }
+
+ ALLOC1 (size: 0, align: 1) {}