diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2025-02-13 22:28:29 -0800 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2025-02-14 22:24:27 -0800 |
| commit | 3a62c70051e40fbcfc7e5b9ad60cb9cfc4dddcee (patch) | |
| tree | c80b9645f00035a33413948ffc463f923af9b5f2 /tests/mir-opt/pre-codegen | |
| parent | aede8f5fbff92bd1b257685c2e654a9bdf3a021f (diff) | |
| download | rust-3a62c70051e40fbcfc7e5b9ad60cb9cfc4dddcee.tar.gz rust-3a62c70051e40fbcfc7e5b9ad60cb9cfc4dddcee.zip | |
Save another BB by using `SubUnchecked` instead of a call to `arith_offset`
Probably reasonable anyway since it more obviously drops provenance.
Diffstat (limited to 'tests/mir-opt/pre-codegen')
5 files changed, 251 insertions, 315 deletions
diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir index e12f97073d0..80b96e01041 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir @@ -7,27 +7,27 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _11: std::ptr::NonNull<T>; let mut _12: *const T; let mut _13: usize; - let mut _33: std::option::Option<(usize, &T)>; - let mut _36: &impl Fn(usize, &T); - let mut _37: (usize, &T); - let _38: (); + let mut _31: std::option::Option<(usize, &T)>; + let mut _34: &impl Fn(usize, &T); + let mut _35: (usize, &T); + let _36: (); scope 1 { debug (((iter: Enumerate<std::slice::Iter<'_, T>>).0: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>) => _11; debug (((iter: Enumerate<std::slice::Iter<'_, T>>).0: std::slice::Iter<'_, T>).1: *const T) => _12; debug (((iter: Enumerate<std::slice::Iter<'_, T>>).0: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; debug ((iter: Enumerate<std::slice::Iter<'_, T>>).1: usize) => _13; - let _34: usize; - let _35: &T; + let _32: usize; + let _33: &T; scope 2 { - debug i => _34; - debug x => _35; + debug i => _32; + debug x => _33; } scope 19 (inlined <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next) { - let mut _27: std::option::Option<&T>; - let mut _31: (usize, bool); - let mut _32: (usize, &T); + let mut _25: std::option::Option<&T>; + let mut _29: (usize, bool); + let mut _30: (usize, &T); scope 20 { - let _30: usize; + let _28: usize; scope 25 { } } @@ -42,8 +42,8 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 26 (inlined <Option<&T> as Try>::branch) { - let mut _28: isize; - let _29: &T; + let mut _26: isize; + let _27: &T; scope 27 { } } @@ -52,43 +52,37 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let _16: std::ptr::NonNull<T>; let mut _19: bool; let mut _22: std::ptr::NonNull<T>; - let mut _24: bool; - let mut _25: *const u8; - let mut _26: *const T; + let mut _24: usize; scope 30 { let _15: *const T; scope 31 { - let _23: *const u8; + let _23: usize; scope 32 { - scope 33 (inlined null::<u8>) { - scope 34 (inlined without_provenance::<()>) { - scope 35 (inlined without_provenance_mut::<()>) { + scope 35 (inlined core::num::<impl usize>::unchecked_sub) { + scope 36 (inlined core::ub_checks::check_language_ub) { + scope 37 (inlined core::ub_checks::check_language_ub::runtime) { } } - scope 36 (inlined std::ptr::from_raw_parts::<u8, ()>) { - } } - scope 37 (inlined std::ptr::const_ptr::<impl *const u8>::wrapping_sub) { - scope 38 (inlined core::num::<impl isize>::wrapping_neg) { - scope 39 (inlined core::num::<impl isize>::wrapping_sub) { - } - } - scope 40 (inlined std::ptr::const_ptr::<impl *const u8>::wrapping_offset) { - } + scope 38 (inlined without_provenance_mut::<T>) { } } - scope 41 (inlined <NonNull<T> as PartialEq>::eq) { + scope 33 (inlined std::ptr::const_ptr::<impl *const T>::addr) { + scope 34 (inlined std::ptr::const_ptr::<impl *const T>::cast::<()>) { + } + } + scope 39 (inlined <NonNull<T> as PartialEq>::eq) { let mut _17: *mut T; let mut _18: *mut T; - scope 42 (inlined NonNull::<T>::as_ptr) { + scope 40 (inlined NonNull::<T>::as_ptr) { } - scope 43 (inlined NonNull::<T>::as_ptr) { + scope 41 (inlined NonNull::<T>::as_ptr) { } } - scope 44 (inlined NonNull::<T>::add) { + scope 42 (inlined NonNull::<T>::add) { let mut _20: *const T; let mut _21: *const T; - scope 45 (inlined NonNull::<T>::as_ptr) { + scope 43 (inlined NonNull::<T>::as_ptr) { } } } @@ -181,13 +175,14 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb4: { - StorageLive(_33); - StorageLive(_30); StorageLive(_31); - StorageLive(_27); + StorageLive(_28); + StorageLive(_29); + StorageLive(_25); StorageLive(_14); StorageLive(_15); StorageLive(_23); + StorageLive(_24); StorageLive(_16); _14 = copy _11; _15 = copy _12; @@ -225,104 +220,97 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb7: { StorageDead(_19); StorageDead(_16); + StorageDead(_24); StorageDead(_23); StorageDead(_15); StorageDead(_14); - StorageLive(_28); - goto -> bb17; + StorageLive(_26); + goto -> bb12; } bb8: { - _23 = copy _15 as *const u8 (PtrToPtr); - StorageLive(_24); - _24 = Eq(copy _23, const {0x0 as *const u8}); - switchInt(move _24) -> [0: bb9, otherwise: bb16]; + _23 = copy _15 as usize (Transmute); + switchInt(copy _23) -> [0: bb9, otherwise: bb10]; } bb9: { + StorageDead(_16); StorageDead(_24); - StorageLive(_25); - _25 = arith_offset::<u8>(move _23, const -1_isize) -> [return: bb10, unwind unreachable]; + StorageDead(_23); + StorageDead(_15); + StorageDead(_14); + StorageLive(_26); + goto -> bb12; } bb10: { - _26 = move _25 as *const T (PtrToPtr); - StorageDead(_25); - _12 = copy _26; + _24 = SubUnchecked(copy _23, const 1_usize); + _12 = copy _24 as *const T (Transmute); goto -> bb11; } bb11: { - _27 = copy _14 as std::option::Option<&T> (Transmute); + _25 = copy _14 as std::option::Option<&T> (Transmute); StorageDead(_16); + StorageDead(_24); StorageDead(_23); StorageDead(_15); StorageDead(_14); - StorageLive(_28); - _28 = discriminant(_27); - switchInt(move _28) -> [0: bb17, 1: bb12, otherwise: bb15]; + StorageLive(_26); + _26 = discriminant(_25); + switchInt(move _26) -> [0: bb12, 1: bb14, otherwise: bb17]; } bb12: { - _29 = move ((_27 as Some).0: &T); + StorageDead(_26); + StorageDead(_25); + StorageDead(_29); StorageDead(_28); - StorageDead(_27); - _30 = copy _13; - _31 = AddWithOverflow(copy _13, const 1_usize); - assert(!move (_31.1: bool), "attempt to compute `{} + {}`, which would overflow", copy _13, const 1_usize) -> [success: bb13, unwind unreachable]; + StorageDead(_31); + StorageDead(_11); + StorageDead(_12); + StorageDead(_13); + drop(_2) -> [return: bb13, unwind unreachable]; } bb13: { - _13 = move (_31.0: usize); - StorageLive(_32); - _32 = (copy _30, copy _29); - _33 = Option::<(usize, &T)>::Some(move _32); - StorageDead(_32); - StorageDead(_31); - StorageDead(_30); - _34 = copy (((_33 as Some).0: (usize, &T)).0: usize); - _35 = copy (((_33 as Some).0: (usize, &T)).1: &T); - StorageLive(_36); - _36 = &_2; - StorageLive(_37); - _37 = (copy _34, copy _35); - _38 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _36, move _37) -> [return: bb14, unwind unreachable]; + return; } bb14: { - StorageDead(_37); - StorageDead(_36); - StorageDead(_33); - goto -> bb4; + _27 = move ((_25 as Some).0: &T); + StorageDead(_26); + StorageDead(_25); + _28 = copy _13; + _29 = AddWithOverflow(copy _13, const 1_usize); + assert(!move (_29.1: bool), "attempt to compute `{} + {}`, which would overflow", copy _13, const 1_usize) -> [success: bb15, unwind unreachable]; } bb15: { - unreachable; + _13 = move (_29.0: usize); + StorageLive(_30); + _30 = (copy _28, copy _27); + _31 = Option::<(usize, &T)>::Some(move _30); + StorageDead(_30); + StorageDead(_29); + StorageDead(_28); + _32 = copy (((_31 as Some).0: (usize, &T)).0: usize); + _33 = copy (((_31 as Some).0: (usize, &T)).1: &T); + StorageLive(_34); + _34 = &_2; + StorageLive(_35); + _35 = (copy _32, copy _33); + _36 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _34, move _35) -> [return: bb16, unwind unreachable]; } bb16: { - StorageDead(_24); - StorageDead(_16); - StorageDead(_23); - StorageDead(_15); - StorageDead(_14); - StorageLive(_28); - goto -> bb17; - } - - bb17: { - StorageDead(_28); - StorageDead(_27); + StorageDead(_35); + StorageDead(_34); StorageDead(_31); - StorageDead(_30); - StorageDead(_33); - StorageDead(_11); - StorageDead(_12); - StorageDead(_13); - drop(_2) -> [return: bb18, unwind unreachable]; + goto -> bb4; } - bb18: { - return; + bb17: { + unreachable; } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir index 88d0aa7f624..c539170055d 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -6,61 +6,55 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { let mut _0: (); let mut _11: std::ptr::NonNull<T>; let mut _12: *const T; - let mut _26: std::option::Option<&T>; - let mut _27: isize; - let mut _29: &impl Fn(&T); - let mut _30: (&T,); - let _31: (); + let mut _24: std::option::Option<&T>; + let mut _25: isize; + let mut _27: &impl Fn(&T); + let mut _28: (&T,); + let _29: (); scope 1 { debug ((iter: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>) => _11; debug ((iter: std::slice::Iter<'_, T>).1: *const T) => _12; debug ((iter: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; - let _28: &T; + let _26: &T; scope 2 { - debug x => _28; + debug x => _26; } scope 17 (inlined <std::slice::Iter<'_, T> as Iterator>::next) { let _13: std::ptr::NonNull<T>; let _15: std::ptr::NonNull<T>; let mut _18: bool; let mut _21: std::ptr::NonNull<T>; - let mut _23: bool; - let mut _24: *const u8; - let mut _25: *const T; + let mut _23: usize; scope 18 { let _14: *const T; scope 19 { - let _22: *const u8; + let _22: usize; scope 20 { - scope 21 (inlined null::<u8>) { - scope 22 (inlined without_provenance::<()>) { - scope 23 (inlined without_provenance_mut::<()>) { + scope 23 (inlined core::num::<impl usize>::unchecked_sub) { + scope 24 (inlined core::ub_checks::check_language_ub) { + scope 25 (inlined core::ub_checks::check_language_ub::runtime) { } } - scope 24 (inlined std::ptr::from_raw_parts::<u8, ()>) { - } } - scope 25 (inlined std::ptr::const_ptr::<impl *const u8>::wrapping_sub) { - scope 26 (inlined core::num::<impl isize>::wrapping_neg) { - scope 27 (inlined core::num::<impl isize>::wrapping_sub) { - } - } - scope 28 (inlined std::ptr::const_ptr::<impl *const u8>::wrapping_offset) { - } + scope 26 (inlined without_provenance_mut::<T>) { + } + } + scope 21 (inlined std::ptr::const_ptr::<impl *const T>::addr) { + scope 22 (inlined std::ptr::const_ptr::<impl *const T>::cast::<()>) { } } - scope 29 (inlined <NonNull<T> as PartialEq>::eq) { + scope 27 (inlined <NonNull<T> as PartialEq>::eq) { let mut _16: *mut T; let mut _17: *mut T; - scope 30 (inlined NonNull::<T>::as_ptr) { + scope 28 (inlined NonNull::<T>::as_ptr) { } - scope 31 (inlined NonNull::<T>::as_ptr) { + scope 29 (inlined NonNull::<T>::as_ptr) { } } - scope 32 (inlined NonNull::<T>::add) { + scope 30 (inlined NonNull::<T>::add) { let mut _19: *const T; let mut _20: *const T; - scope 33 (inlined NonNull::<T>::as_ptr) { + scope 31 (inlined NonNull::<T>::as_ptr) { } } } @@ -146,10 +140,11 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb4: { - StorageLive(_26); + StorageLive(_24); StorageLive(_13); StorageLive(_14); StorageLive(_22); + StorageLive(_23); StorageLive(_15); _13 = copy _11; _14 = copy _12; @@ -187,79 +182,72 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb7: { StorageDead(_18); StorageDead(_15); + StorageDead(_23); StorageDead(_22); StorageDead(_14); StorageDead(_13); - goto -> bb16; + goto -> bb12; } bb8: { - _22 = copy _14 as *const u8 (PtrToPtr); - StorageLive(_23); - _23 = Eq(copy _22, const {0x0 as *const u8}); - switchInt(move _23) -> [0: bb9, otherwise: bb15]; + _22 = copy _14 as usize (Transmute); + switchInt(copy _22) -> [0: bb9, otherwise: bb10]; } bb9: { + StorageDead(_15); StorageDead(_23); - StorageLive(_24); - _24 = arith_offset::<u8>(move _22, const -1_isize) -> [return: bb10, unwind unreachable]; + StorageDead(_22); + StorageDead(_14); + StorageDead(_13); + goto -> bb12; } bb10: { - _25 = move _24 as *const T (PtrToPtr); - StorageDead(_24); - _12 = copy _25; + _23 = SubUnchecked(copy _22, const 1_usize); + _12 = copy _23 as *const T (Transmute); goto -> bb11; } bb11: { - _26 = copy _13 as std::option::Option<&T> (Transmute); + _24 = copy _13 as std::option::Option<&T> (Transmute); StorageDead(_15); + StorageDead(_23); StorageDead(_22); StorageDead(_14); StorageDead(_13); - _27 = discriminant(_26); - switchInt(move _27) -> [0: bb16, 1: bb12, otherwise: bb14]; + _25 = discriminant(_24); + switchInt(move _25) -> [0: bb12, 1: bb14, otherwise: bb16]; } bb12: { - _28 = copy ((_26 as Some).0: &T); - StorageLive(_29); - _29 = &_2; - StorageLive(_30); - _30 = (copy _28,); - _31 = <impl Fn(&T) as Fn<(&T,)>>::call(move _29, move _30) -> [return: bb13, unwind unreachable]; + StorageDead(_24); + StorageDead(_11); + StorageDead(_12); + drop(_2) -> [return: bb13, unwind unreachable]; } bb13: { - StorageDead(_30); - StorageDead(_29); - StorageDead(_26); - goto -> bb4; + return; } bb14: { - unreachable; + _26 = copy ((_24 as Some).0: &T); + StorageLive(_27); + _27 = &_2; + StorageLive(_28); + _28 = (copy _26,); + _29 = <impl Fn(&T) as Fn<(&T,)>>::call(move _27, move _28) -> [return: bb15, unwind unreachable]; } bb15: { - StorageDead(_23); - StorageDead(_15); - StorageDead(_22); - StorageDead(_14); - StorageDead(_13); - goto -> bb16; + StorageDead(_28); + StorageDead(_27); + StorageDead(_24); + goto -> bb4; } bb16: { - StorageDead(_26); - StorageDead(_11); - StorageDead(_12); - drop(_2) -> [return: bb17, unwind unreachable]; - } - - bb17: { - return; + unreachable; } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir index f34edc4775d..dc537ad8740 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -6,61 +6,55 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { let mut _0: (); let mut _11: std::ptr::NonNull<T>; let mut _12: *const T; - let mut _26: std::option::Option<&T>; - let mut _27: isize; - let mut _29: &impl Fn(&T); - let mut _30: (&T,); - let _31: (); + let mut _24: std::option::Option<&T>; + let mut _25: isize; + let mut _27: &impl Fn(&T); + let mut _28: (&T,); + let _29: (); scope 1 { debug ((iter: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>) => _11; debug ((iter: std::slice::Iter<'_, T>).1: *const T) => _12; debug ((iter: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; - let _28: &T; + let _26: &T; scope 2 { - debug x => _28; + debug x => _26; } scope 17 (inlined <std::slice::Iter<'_, T> as Iterator>::next) { let _13: std::ptr::NonNull<T>; let _15: std::ptr::NonNull<T>; let mut _18: bool; let mut _21: std::ptr::NonNull<T>; - let mut _23: bool; - let mut _24: *const u8; - let mut _25: *const T; + let mut _23: usize; scope 18 { let _14: *const T; scope 19 { - let _22: *const u8; + let _22: usize; scope 20 { - scope 21 (inlined null::<u8>) { - scope 22 (inlined without_provenance::<()>) { - scope 23 (inlined without_provenance_mut::<()>) { + scope 23 (inlined core::num::<impl usize>::unchecked_sub) { + scope 24 (inlined core::ub_checks::check_language_ub) { + scope 25 (inlined core::ub_checks::check_language_ub::runtime) { } } - scope 24 (inlined std::ptr::from_raw_parts::<u8, ()>) { - } } - scope 25 (inlined std::ptr::const_ptr::<impl *const u8>::wrapping_sub) { - scope 26 (inlined core::num::<impl isize>::wrapping_neg) { - scope 27 (inlined core::num::<impl isize>::wrapping_sub) { - } - } - scope 28 (inlined std::ptr::const_ptr::<impl *const u8>::wrapping_offset) { - } + scope 26 (inlined without_provenance_mut::<T>) { + } + } + scope 21 (inlined std::ptr::const_ptr::<impl *const T>::addr) { + scope 22 (inlined std::ptr::const_ptr::<impl *const T>::cast::<()>) { } } - scope 29 (inlined <NonNull<T> as PartialEq>::eq) { + scope 27 (inlined <NonNull<T> as PartialEq>::eq) { let mut _16: *mut T; let mut _17: *mut T; - scope 30 (inlined NonNull::<T>::as_ptr) { + scope 28 (inlined NonNull::<T>::as_ptr) { } - scope 31 (inlined NonNull::<T>::as_ptr) { + scope 29 (inlined NonNull::<T>::as_ptr) { } } - scope 32 (inlined NonNull::<T>::add) { + scope 30 (inlined NonNull::<T>::add) { let mut _19: *const T; let mut _20: *const T; - scope 33 (inlined NonNull::<T>::as_ptr) { + scope 31 (inlined NonNull::<T>::as_ptr) { } } } @@ -146,10 +140,11 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb4: { - StorageLive(_26); + StorageLive(_24); StorageLive(_13); StorageLive(_14); StorageLive(_22); + StorageLive(_23); StorageLive(_15); _13 = copy _11; _14 = copy _12; @@ -187,87 +182,80 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb7: { StorageDead(_18); StorageDead(_15); + StorageDead(_23); StorageDead(_22); StorageDead(_14); StorageDead(_13); - goto -> bb18; + goto -> bb12; } bb8: { - _22 = copy _14 as *const u8 (PtrToPtr); - StorageLive(_23); - _23 = Eq(copy _22, const {0x0 as *const u8}); - switchInt(move _23) -> [0: bb9, otherwise: bb17]; + _22 = copy _14 as usize (Transmute); + switchInt(copy _22) -> [0: bb9, otherwise: bb10]; } bb9: { + StorageDead(_15); StorageDead(_23); - StorageLive(_24); - _24 = arith_offset::<u8>(move _22, const -1_isize) -> [return: bb10, unwind unreachable]; + StorageDead(_22); + StorageDead(_14); + StorageDead(_13); + goto -> bb12; } bb10: { - _25 = move _24 as *const T (PtrToPtr); - StorageDead(_24); - _12 = copy _25; + _23 = SubUnchecked(copy _22, const 1_usize); + _12 = copy _23 as *const T (Transmute); goto -> bb11; } bb11: { - _26 = copy _13 as std::option::Option<&T> (Transmute); + _24 = copy _13 as std::option::Option<&T> (Transmute); StorageDead(_15); + StorageDead(_23); StorageDead(_22); StorageDead(_14); StorageDead(_13); - _27 = discriminant(_26); - switchInt(move _27) -> [0: bb18, 1: bb12, otherwise: bb16]; + _25 = discriminant(_24); + switchInt(move _25) -> [0: bb12, 1: bb14, otherwise: bb18]; } bb12: { - _28 = copy ((_26 as Some).0: &T); - StorageLive(_29); - _29 = &_2; - StorageLive(_30); - _30 = (copy _28,); - _31 = <impl Fn(&T) as Fn<(&T,)>>::call(move _29, move _30) -> [return: bb13, unwind: bb14]; + StorageDead(_24); + StorageDead(_11); + StorageDead(_12); + drop(_2) -> [return: bb13, unwind continue]; } bb13: { - StorageDead(_30); - StorageDead(_29); - StorageDead(_26); - goto -> bb4; + return; } - bb14 (cleanup): { - drop(_2) -> [return: bb15, unwind terminate(cleanup)]; + bb14: { + _26 = copy ((_24 as Some).0: &T); + StorageLive(_27); + _27 = &_2; + StorageLive(_28); + _28 = (copy _26,); + _29 = <impl Fn(&T) as Fn<(&T,)>>::call(move _27, move _28) -> [return: bb15, unwind: bb16]; } - bb15 (cleanup): { - resume; + bb15: { + StorageDead(_28); + StorageDead(_27); + StorageDead(_24); + goto -> bb4; } - bb16: { - unreachable; + bb16 (cleanup): { + drop(_2) -> [return: bb17, unwind terminate(cleanup)]; } - bb17: { - StorageDead(_23); - StorageDead(_15); - StorageDead(_22); - StorageDead(_14); - StorageDead(_13); - goto -> bb18; + bb17 (cleanup): { + resume; } bb18: { - StorageDead(_26); - StorageDead(_11); - StorageDead(_12); - drop(_2) -> [return: bb19, unwind continue]; - } - - bb19: { - return; + unreachable; } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir index 975a8a11fb2..0fe469c21f7 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir @@ -8,43 +8,37 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { let _4: std::ptr::NonNull<T>; let mut _7: bool; let mut _10: std::ptr::NonNull<T>; - let mut _12: bool; - let mut _13: *const u8; - let mut _14: *const T; + let mut _12: usize; scope 2 { let _3: *const T; scope 3 { - let _11: *const u8; + let _11: usize; scope 4 { - scope 5 (inlined null::<u8>) { - scope 6 (inlined without_provenance::<()>) { - scope 7 (inlined without_provenance_mut::<()>) { + scope 7 (inlined core::num::<impl usize>::unchecked_sub) { + scope 8 (inlined core::ub_checks::check_language_ub) { + scope 9 (inlined core::ub_checks::check_language_ub::runtime) { } } - scope 8 (inlined std::ptr::from_raw_parts::<u8, ()>) { - } } - scope 9 (inlined std::ptr::const_ptr::<impl *const u8>::wrapping_sub) { - scope 10 (inlined core::num::<impl isize>::wrapping_neg) { - scope 11 (inlined core::num::<impl isize>::wrapping_sub) { - } - } - scope 12 (inlined std::ptr::const_ptr::<impl *const u8>::wrapping_offset) { - } + scope 10 (inlined without_provenance_mut::<T>) { } } - scope 13 (inlined <NonNull<T> as PartialEq>::eq) { + scope 5 (inlined std::ptr::const_ptr::<impl *const T>::addr) { + scope 6 (inlined std::ptr::const_ptr::<impl *const T>::cast::<()>) { + } + } + scope 11 (inlined <NonNull<T> as PartialEq>::eq) { let mut _5: *mut T; let mut _6: *mut T; - scope 14 (inlined NonNull::<T>::as_ptr) { + scope 12 (inlined NonNull::<T>::as_ptr) { } - scope 15 (inlined NonNull::<T>::as_ptr) { + scope 13 (inlined NonNull::<T>::as_ptr) { } } - scope 16 (inlined NonNull::<T>::add) { + scope 14 (inlined NonNull::<T>::add) { let mut _8: *const T; let mut _9: *const T; - scope 17 (inlined NonNull::<T>::as_ptr) { + scope 15 (inlined NonNull::<T>::as_ptr) { } } } @@ -55,6 +49,7 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { StorageLive(_2); StorageLive(_3); StorageLive(_11); + StorageLive(_12); StorageLive(_4); _2 = copy ((*_1).0: std::ptr::NonNull<T>); _3 = copy ((*_1).1: *const T); @@ -92,42 +87,33 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { bb3: { _0 = const {transmute(0x0000000000000000): Option<&T>}; StorageDead(_7); - goto -> bb9; + goto -> bb8; } bb4: { - _11 = copy _3 as *const u8 (PtrToPtr); - StorageLive(_12); - _12 = Eq(copy _11, const {0x0 as *const u8}); - switchInt(move _12) -> [0: bb5, otherwise: bb8]; + _11 = copy _3 as usize (Transmute); + switchInt(copy _11) -> [0: bb5, otherwise: bb6]; } bb5: { - StorageDead(_12); - StorageLive(_13); - _13 = arith_offset::<u8>(move _11, const -1_isize) -> [return: bb6, unwind unreachable]; + _0 = const {transmute(0x0000000000000000): Option<&T>}; + goto -> bb8; } bb6: { - _14 = move _13 as *const T (PtrToPtr); - StorageDead(_13); - ((*_1).1: *const T) = copy _14; + _12 = SubUnchecked(copy _11, const 1_usize); + ((*_1).1: *const T) = copy _12 as *const T (Transmute); goto -> bb7; } bb7: { _0 = copy _2 as std::option::Option<&T> (Transmute); - goto -> bb9; + goto -> bb8; } bb8: { - _0 = const {transmute(0x0000000000000000): Option<&T>}; - StorageDead(_12); - goto -> bb9; - } - - bb9: { StorageDead(_4); + StorageDead(_12); StorageDead(_11); StorageDead(_3); StorageDead(_2); diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir index 975a8a11fb2..0fe469c21f7 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir @@ -8,43 +8,37 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { let _4: std::ptr::NonNull<T>; let mut _7: bool; let mut _10: std::ptr::NonNull<T>; - let mut _12: bool; - let mut _13: *const u8; - let mut _14: *const T; + let mut _12: usize; scope 2 { let _3: *const T; scope 3 { - let _11: *const u8; + let _11: usize; scope 4 { - scope 5 (inlined null::<u8>) { - scope 6 (inlined without_provenance::<()>) { - scope 7 (inlined without_provenance_mut::<()>) { + scope 7 (inlined core::num::<impl usize>::unchecked_sub) { + scope 8 (inlined core::ub_checks::check_language_ub) { + scope 9 (inlined core::ub_checks::check_language_ub::runtime) { } } - scope 8 (inlined std::ptr::from_raw_parts::<u8, ()>) { - } } - scope 9 (inlined std::ptr::const_ptr::<impl *const u8>::wrapping_sub) { - scope 10 (inlined core::num::<impl isize>::wrapping_neg) { - scope 11 (inlined core::num::<impl isize>::wrapping_sub) { - } - } - scope 12 (inlined std::ptr::const_ptr::<impl *const u8>::wrapping_offset) { - } + scope 10 (inlined without_provenance_mut::<T>) { } } - scope 13 (inlined <NonNull<T> as PartialEq>::eq) { + scope 5 (inlined std::ptr::const_ptr::<impl *const T>::addr) { + scope 6 (inlined std::ptr::const_ptr::<impl *const T>::cast::<()>) { + } + } + scope 11 (inlined <NonNull<T> as PartialEq>::eq) { let mut _5: *mut T; let mut _6: *mut T; - scope 14 (inlined NonNull::<T>::as_ptr) { + scope 12 (inlined NonNull::<T>::as_ptr) { } - scope 15 (inlined NonNull::<T>::as_ptr) { + scope 13 (inlined NonNull::<T>::as_ptr) { } } - scope 16 (inlined NonNull::<T>::add) { + scope 14 (inlined NonNull::<T>::add) { let mut _8: *const T; let mut _9: *const T; - scope 17 (inlined NonNull::<T>::as_ptr) { + scope 15 (inlined NonNull::<T>::as_ptr) { } } } @@ -55,6 +49,7 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { StorageLive(_2); StorageLive(_3); StorageLive(_11); + StorageLive(_12); StorageLive(_4); _2 = copy ((*_1).0: std::ptr::NonNull<T>); _3 = copy ((*_1).1: *const T); @@ -92,42 +87,33 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { bb3: { _0 = const {transmute(0x0000000000000000): Option<&T>}; StorageDead(_7); - goto -> bb9; + goto -> bb8; } bb4: { - _11 = copy _3 as *const u8 (PtrToPtr); - StorageLive(_12); - _12 = Eq(copy _11, const {0x0 as *const u8}); - switchInt(move _12) -> [0: bb5, otherwise: bb8]; + _11 = copy _3 as usize (Transmute); + switchInt(copy _11) -> [0: bb5, otherwise: bb6]; } bb5: { - StorageDead(_12); - StorageLive(_13); - _13 = arith_offset::<u8>(move _11, const -1_isize) -> [return: bb6, unwind unreachable]; + _0 = const {transmute(0x0000000000000000): Option<&T>}; + goto -> bb8; } bb6: { - _14 = move _13 as *const T (PtrToPtr); - StorageDead(_13); - ((*_1).1: *const T) = copy _14; + _12 = SubUnchecked(copy _11, const 1_usize); + ((*_1).1: *const T) = copy _12 as *const T (Transmute); goto -> bb7; } bb7: { _0 = copy _2 as std::option::Option<&T> (Transmute); - goto -> bb9; + goto -> bb8; } bb8: { - _0 = const {transmute(0x0000000000000000): Option<&T>}; - StorageDead(_12); - goto -> bb9; - } - - bb9: { StorageDead(_4); + StorageDead(_12); StorageDead(_11); StorageDead(_3); StorageDead(_2); |
