|
| 1 | +- // MIR for `test` before GVN |
| 2 | ++ // MIR for `test` after GVN |
| 3 | + |
| 4 | + fn test() -> () { |
| 5 | + let mut _0: (); |
| 6 | + let _1: &std::boxed::Box<()>; |
| 7 | + let _2: &std::boxed::Box<()>; |
| 8 | + let _3: std::boxed::Box<()>; |
| 9 | + let mut _6: *const (); |
| 10 | + let mut _8: *const [()]; |
| 11 | + let mut _9: std::boxed::Box<()>; |
| 12 | + let mut _10: *const (); |
| 13 | + let mut _23: usize; |
| 14 | + scope 1 { |
| 15 | + debug vp_ctx => _1; |
| 16 | + let _4: *const (); |
| 17 | + scope 2 { |
| 18 | + debug slf => _10; |
| 19 | + let _5: *const [()]; |
| 20 | + scope 3 { |
| 21 | + debug bytes => _5; |
| 22 | + let _7: *mut (); |
| 23 | + scope 4 { |
| 24 | + debug _x => _7; |
| 25 | + } |
| 26 | + scope 18 (inlined foo) { |
| 27 | + } |
| 28 | + } |
| 29 | + scope 16 (inlined slice_from_raw_parts::<()>) { |
| 30 | + scope 17 (inlined std::ptr::from_raw_parts::<[()], ()>) { |
| 31 | + } |
| 32 | + } |
| 33 | + } |
| 34 | + } |
| 35 | + scope 5 (inlined Box::<()>::new) { |
| 36 | + let mut _11: usize; |
| 37 | + let mut _12: usize; |
| 38 | + let mut _13: *mut u8; |
| 39 | + scope 6 (inlined alloc::alloc::exchange_malloc) { |
| 40 | + let _14: std::alloc::Layout; |
| 41 | + let mut _15: std::result::Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError>; |
| 42 | + let mut _16: isize; |
| 43 | + let mut _18: !; |
| 44 | + scope 7 { |
| 45 | + let _17: std::ptr::NonNull<[u8]>; |
| 46 | + scope 8 { |
| 47 | + scope 11 (inlined NonNull::<[u8]>::as_mut_ptr) { |
| 48 | + scope 12 (inlined NonNull::<[u8]>::as_non_null_ptr) { |
| 49 | + scope 13 (inlined NonNull::<[u8]>::cast::<u8>) { |
| 50 | + let mut _22: *mut [u8]; |
| 51 | + scope 14 (inlined NonNull::<[u8]>::as_ptr) { |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + scope 15 (inlined NonNull::<u8>::as_ptr) { |
| 56 | + } |
| 57 | + } |
| 58 | + } |
| 59 | + scope 10 (inlined <std::alloc::Global as Allocator>::allocate) { |
| 60 | + } |
| 61 | + } |
| 62 | + scope 9 (inlined Layout::from_size_align_unchecked) { |
| 63 | + let mut _19: bool; |
| 64 | + let _20: (); |
| 65 | + let mut _21: std::ptr::Alignment; |
| 66 | + } |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + bb0: { |
| 71 | + StorageLive(_1); |
| 72 | +- StorageLive(_2); |
| 73 | ++ nop; |
| 74 | + StorageLive(_3); |
| 75 | + StorageLive(_11); |
| 76 | + StorageLive(_12); |
| 77 | + StorageLive(_13); |
| 78 | +- _11 = SizeOf(()); |
| 79 | +- _12 = AlignOf(()); |
| 80 | ++ _11 = const 0_usize; |
| 81 | ++ _12 = const 1_usize; |
| 82 | + StorageLive(_14); |
| 83 | + StorageLive(_16); |
| 84 | + StorageLive(_17); |
| 85 | + StorageLive(_19); |
| 86 | + _19 = const false; |
| 87 | +- switchInt(move _19) -> [0: bb6, otherwise: bb5]; |
| 88 | ++ switchInt(const false) -> [0: bb6, otherwise: bb5]; |
| 89 | + } |
| 90 | + |
| 91 | + bb1: { |
| 92 | + StorageDead(_3); |
| 93 | + StorageDead(_1); |
| 94 | + return; |
| 95 | + } |
| 96 | + |
| 97 | + bb2: { |
| 98 | + unreachable; |
| 99 | + } |
| 100 | + |
| 101 | + bb3: { |
| 102 | +- _18 = handle_alloc_error(move _14) -> unwind unreachable; |
| 103 | ++ _18 = handle_alloc_error(const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}) -> unwind unreachable; |
| 104 | + } |
| 105 | + |
| 106 | + bb4: { |
| 107 | + _17 = copy ((_15 as Ok).0: std::ptr::NonNull<[u8]>); |
| 108 | + StorageLive(_22); |
| 109 | + _22 = copy _17 as *mut [u8] (Transmute); |
| 110 | + _13 = copy _22 as *mut u8 (PtrToPtr); |
| 111 | + StorageDead(_22); |
| 112 | + StorageDead(_15); |
| 113 | + StorageDead(_17); |
| 114 | + StorageDead(_16); |
| 115 | + StorageDead(_14); |
| 116 | + _3 = ShallowInitBox(move _13, ()); |
| 117 | + StorageDead(_13); |
| 118 | + StorageDead(_12); |
| 119 | + StorageDead(_11); |
| 120 | + _2 = &_3; |
| 121 | + _1 = copy _2; |
| 122 | +- StorageDead(_2); |
| 123 | ++ nop; |
| 124 | + StorageLive(_4); |
| 125 | +- _9 = deref_copy _3; |
| 126 | ++ _9 = copy _3; |
| 127 | + _10 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); |
| 128 | + _4 = copy _10; |
| 129 | +- StorageLive(_5); |
| 130 | ++ nop; |
| 131 | + StorageLive(_6); |
| 132 | +- _6 = copy _4; |
| 133 | ++ _6 = copy _10; |
| 134 | + StorageLive(_23); |
| 135 | + _23 = const 1_usize; |
| 136 | +- _5 = *const [()] from (copy _6, copy _23); |
| 137 | ++ _5 = *const [()] from (copy _10, const 1_usize); |
| 138 | + StorageDead(_23); |
| 139 | + StorageDead(_6); |
| 140 | + StorageLive(_7); |
| 141 | + StorageLive(_8); |
| 142 | + _8 = copy _5; |
| 143 | +- _7 = copy _8 as *mut () (PtrToPtr); |
| 144 | ++ _7 = copy _5 as *mut () (PtrToPtr); |
| 145 | + StorageDead(_8); |
| 146 | + StorageDead(_7); |
| 147 | +- StorageDead(_5); |
| 148 | ++ nop; |
| 149 | + StorageDead(_4); |
| 150 | + drop(_3) -> [return: bb1, unwind unreachable]; |
| 151 | + } |
| 152 | + |
| 153 | + bb5: { |
| 154 | +- _20 = Layout::from_size_align_unchecked::precondition_check(copy _11, copy _12) -> [return: bb6, unwind unreachable]; |
| 155 | ++ _20 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; |
| 156 | + } |
| 157 | + |
| 158 | + bb6: { |
| 159 | + StorageDead(_19); |
| 160 | + StorageLive(_21); |
| 161 | +- _21 = copy _12 as std::ptr::Alignment (Transmute); |
| 162 | +- _14 = Layout { size: copy _11, align: move _21 }; |
| 163 | ++ _21 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); |
| 164 | ++ _14 = const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}; |
| 165 | + StorageDead(_21); |
| 166 | + StorageLive(_15); |
| 167 | +- _15 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], copy _14, const false) -> [return: bb7, unwind unreachable]; |
| 168 | ++ _15 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}, const false) -> [return: bb7, unwind unreachable]; |
| 169 | + } |
| 170 | + |
| 171 | + bb7: { |
| 172 | + _16 = discriminant(_15); |
| 173 | + switchInt(move _16) -> [0: bb4, 1: bb3, otherwise: bb2]; |
| 174 | + } |
| 175 | ++ } |
| 176 | ++ |
| 177 | ++ ALLOC0 (size: 8, align: 4) { |
| 178 | ++ 01 00 00 00 00 00 00 00 │ ........ |
| 179 | + } |
| 180 | + |
0 commit comments