diff options
20 files changed, 96 insertions, 86 deletions
diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index fa8257cf984..d419329f2d6 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -553,6 +553,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { &normalize_array_len::NormalizeArrayLen, // has to run after `slice::len` lowering &const_goto::ConstGoto, &remove_unneeded_drops::RemoveUnneededDrops, + &ref_prop::ReferencePropagation, &sroa::ScalarReplacementOfAggregates, &match_branches::MatchBranchSimplification, // inst combine is after MatchBranchSimplification to clean up Ne(_1, false) @@ -560,7 +561,6 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { &instsimplify::InstSimplify, &simplify::SimplifyLocals::BeforeConstProp, ©_prop::CopyProp, - &ref_prop::ReferencePropagation, // Perform `SeparateConstSwitch` after SSA-based analyses, as cloning blocks may // destroy the SSA property. It should still happen before const-propagation, so the // latter pass will leverage the created opportunities. diff --git a/tests/codegen/slice-ref-equality.rs b/tests/codegen/slice-ref-equality.rs index 8f0adab35e7..c91e5bc3cd0 100644 --- a/tests/codegen/slice-ref-equality.rs +++ b/tests/codegen/slice-ref-equality.rs @@ -44,48 +44,48 @@ pub fn is_zero_array(data: &[u8; 4]) -> bool { // equality for non-byte types also just emit a `bcmp`, not a loop. // CHECK-LABEL: @eq_slice_of_nested_u8( -// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1 -// CHECK-SAME: [[USIZE]] noundef %3 +// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1 +// CHECK-SAME: [[USIZE]] noundef %y.1 #[no_mangle] fn eq_slice_of_nested_u8(x: &[[u8; 3]], y: &[[u8; 3]]) -> bool { - // CHECK: icmp eq [[USIZE]] %1, %3 - // CHECK: %[[BYTES:.+]] = mul nsw [[USIZE]] %1, 3 + // CHECK: icmp eq [[USIZE]] %x.1, %y.1 + // CHECK: %[[BYTES:.+]] = mul nsw [[USIZE]] %x.1, 3 // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}({{i8\*|ptr}} // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y } // CHECK-LABEL: @eq_slice_of_i32( -// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1 -// CHECK-SAME: [[USIZE]] noundef %3 +// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1 +// CHECK-SAME: [[USIZE]] noundef %y.1 #[no_mangle] fn eq_slice_of_i32(x: &[i32], y: &[i32]) -> bool { - // CHECK: icmp eq [[USIZE]] %1, %3 - // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 2 + // CHECK: icmp eq [[USIZE]] %x.1, %y.1 + // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %x.1, 2 // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}({{i32\*|ptr}} // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y } // CHECK-LABEL: @eq_slice_of_nonzero( -// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1 -// CHECK-SAME: [[USIZE]] noundef %3 +// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1 +// CHECK-SAME: [[USIZE]] noundef %y.1 #[no_mangle] fn eq_slice_of_nonzero(x: &[NonZeroU32], y: &[NonZeroU32]) -> bool { - // CHECK: icmp eq [[USIZE]] %1, %3 - // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 2 + // CHECK: icmp eq [[USIZE]] %x.1, %y.1 + // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %x.1, 2 // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}({{i32\*|ptr}} // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y } // CHECK-LABEL: @eq_slice_of_option_of_nonzero( -// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1 -// CHECK-SAME: [[USIZE]] noundef %3 +// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1 +// CHECK-SAME: [[USIZE]] noundef %y.1 #[no_mangle] fn eq_slice_of_option_of_nonzero(x: &[Option<NonZeroI16>], y: &[Option<NonZeroI16>]) -> bool { - // CHECK: icmp eq [[USIZE]] %1, %3 - // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 1 + // CHECK: icmp eq [[USIZE]] %x.1, %y.1 + // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %x.1, 1 // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}({{i16\*|ptr}} // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y diff --git a/tests/mir-opt/casts.redundant.InstSimplify.diff b/tests/mir-opt/casts.redundant.InstSimplify.diff index ff6d11c4596..f5ea78aecbe 100644 --- a/tests/mir-opt/casts.redundant.InstSimplify.diff +++ b/tests/mir-opt/casts.redundant.InstSimplify.diff @@ -7,7 +7,7 @@ let mut _2: *const &u8; let mut _3: *const &u8; scope 1 (inlined generic_cast::<&u8, &u8>) { - debug x => _3; + debug x => _1; } bb0: { diff --git a/tests/mir-opt/copy-prop/mutate_through_pointer.rs b/tests/mir-opt/copy-prop/mutate_through_pointer.rs index da142e33948..753787089b5 100644 --- a/tests/mir-opt/copy-prop/mutate_through_pointer.rs +++ b/tests/mir-opt/copy-prop/mutate_through_pointer.rs @@ -1,3 +1,5 @@ +// unit-test: CopyProp +// // This attempts to mutate `a` via a pointer derived from `addr_of!(a)`. That is UB // according to Miri. However, the decision to make this UB - and to allow // rustc to rely on that fact for the purpose of optimizations - has not been diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff index 1cc44ce06cf..b647455aeec 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff @@ -6,20 +6,16 @@ let mut _0: (); let _2: &[T]; let mut _3: &[T; 3]; - let _4: &[T; 3]; - let _5: [T; 3]; + let _4: [T; 3]; + let mut _5: T; let mut _6: T; let mut _7: T; - let mut _8: T; + let mut _8: usize; let mut _9: usize; - let mut _10: usize; - let mut _11: bool; - let mut _15: !; + let mut _10: bool; + let mut _11: !; scope 1 { debug v => _2; - let _12: &T; - let _13: &T; - let _14: &T; scope 2 { debug v1 => &(*_2)[0 of 3]; debug v2 => &(*_2)[1 of 3]; @@ -28,26 +24,26 @@ } bb0: { - StorageLive(_2); - StorageLive(_5); - _5 = [_1, _1, _1]; - _4 = &_5; - _2 = _4 as &[T] (PointerCoercion(Unsize)); - _9 = Len((*_2)); - _10 = const 3_usize; -- _11 = Eq(move _9, const 3_usize); -- switchInt(move _11) -> [0: bb1, otherwise: bb2]; + StorageLive(_3); + StorageLive(_4); + _4 = [_1, _1, _1]; + _3 = &_4; + _2 = move _3 as &[T] (PointerCoercion(Unsize)); + StorageDead(_3); + _8 = Len((*_2)); + _9 = const 3_usize; +- _10 = Eq(move _8, const 3_usize); +- switchInt(move _10) -> [0: bb1, otherwise: bb2]; + nop; -+ switchInt(move _9) -> [3: bb2, otherwise: bb1]; ++ switchInt(move _8) -> [3: bb2, otherwise: bb1]; } bb1: { - _15 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind unreachable; + _11 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind unreachable; } bb2: { - StorageDead(_5); - StorageDead(_2); + StorageDead(_4); return; } } diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff index b708f667438..b02be61d031 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff @@ -6,20 +6,16 @@ let mut _0: (); let _2: &[T]; let mut _3: &[T; 3]; - let _4: &[T; 3]; - let _5: [T; 3]; + let _4: [T; 3]; + let mut _5: T; let mut _6: T; let mut _7: T; - let mut _8: T; + let mut _8: usize; let mut _9: usize; - let mut _10: usize; - let mut _11: bool; - let mut _15: !; + let mut _10: bool; + let mut _11: !; scope 1 { debug v => _2; - let _12: &T; - let _13: &T; - let _14: &T; scope 2 { debug v1 => &(*_2)[0 of 3]; debug v2 => &(*_2)[1 of 3]; @@ -28,26 +24,26 @@ } bb0: { - StorageLive(_2); - StorageLive(_5); - _5 = [_1, _1, _1]; - _4 = &_5; - _2 = _4 as &[T] (PointerCoercion(Unsize)); - _9 = Len((*_2)); - _10 = const 3_usize; -- _11 = Eq(move _9, const 3_usize); -- switchInt(move _11) -> [0: bb1, otherwise: bb2]; + StorageLive(_3); + StorageLive(_4); + _4 = [_1, _1, _1]; + _3 = &_4; + _2 = move _3 as &[T] (PointerCoercion(Unsize)); + StorageDead(_3); + _8 = Len((*_2)); + _9 = const 3_usize; +- _10 = Eq(move _8, const 3_usize); +- switchInt(move _10) -> [0: bb1, otherwise: bb2]; + nop; -+ switchInt(move _9) -> [3: bb2, otherwise: bb1]; ++ switchInt(move _8) -> [3: bb2, otherwise: bb1]; } bb1: { - _15 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind continue; + _11 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind continue; } bb2: { - StorageDead(_5); - StorageDead(_2); + StorageDead(_4); return; } } diff --git a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir index e4e1d052e73..2614160363e 100644 --- a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir @@ -38,11 +38,13 @@ fn mapped(_1: impl Iterator<Item = T>, _2: impl Fn(T) -> U) -> () { bb2: { StorageLive(_7); + StorageLive(_6); _6 = &mut _5; - _7 = <Map<impl Iterator<Item = T>, impl Fn(T) -> U> as Iterator>::next(_6) -> [return: bb3, unwind: bb9]; + _7 = <Map<impl Iterator<Item = T>, impl Fn(T) -> U> as Iterator>::next(move _6) -> [return: bb3, unwind: bb9]; } bb3: { + StorageDead(_6); _8 = discriminant(_7); switchInt(move _8) -> [0: bb4, 1: bb6, otherwise: bb8]; } diff --git a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir index 1b5f2a0884b..8eff46fb931 100644 --- a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir @@ -30,11 +30,13 @@ fn vec_move(_1: Vec<impl Sized>) -> () { bb2: { StorageLive(_5); + StorageLive(_4); _4 = &mut _3; - _5 = <std::vec::IntoIter<impl Sized> as Iterator>::next(_4) -> [return: bb3, unwind: bb9]; + _5 = <std::vec::IntoIter<impl Sized> as Iterator>::next(move _4) -> [return: bb3, unwind: bb9]; } bb3: { + StorageDead(_4); _6 = discriminant(_5); switchInt(move _6) -> [0: bb4, 1: bb6, otherwise: bb8]; } diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir index 9737c9a87c7..8d306858b43 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir @@ -40,11 +40,13 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb1: { StorageLive(_7); + StorageLive(_6); _6 = &mut _5; _7 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(_6) -> [return: bb2, unwind unreachable]; } bb2: { + StorageDead(_6); _8 = discriminant(_7); switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb7]; } diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir index 04d6da1d9bd..e92c054c838 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir @@ -40,11 +40,13 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb1: { StorageLive(_7); + StorageLive(_6); _6 = &mut _5; _7 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(_6) -> [return: bb2, unwind: bb8]; } bb2: { + StorageDead(_6); _8 = discriminant(_7); switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb7]; } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir index 602f8652949..07a58309ee4 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir @@ -53,7 +53,7 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { } bb0: { - StorageLive(_8); + StorageLive(_7); StorageLive(_4); StorageLive(_3); _3 = Len((*_1)); @@ -68,7 +68,7 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { } bb2: { - StorageLive(_7); + StorageLive(_8); StorageLive(_5); _5 = &raw mut (*_1); StorageLive(_9); @@ -79,14 +79,14 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { StorageDead(_9); StorageDead(_5); _8 = &mut (*_7); - _0 = Option::<&mut u32>::Some(_8); - StorageDead(_7); + _0 = Option::<&mut u32>::Some(move _8); + StorageDead(_8); goto -> bb3; } bb3: { StorageDead(_4); - StorageDead(_8); + StorageDead(_7); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir index 602f8652949..07a58309ee4 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir @@ -53,7 +53,7 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { } bb0: { - StorageLive(_8); + StorageLive(_7); StorageLive(_4); StorageLive(_3); _3 = Len((*_1)); @@ -68,7 +68,7 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { } bb2: { - StorageLive(_7); + StorageLive(_8); StorageLive(_5); _5 = &raw mut (*_1); StorageLive(_9); @@ -79,14 +79,14 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { StorageDead(_9); StorageDead(_5); _8 = &mut (*_7); - _0 = Option::<&mut u32>::Some(_8); - StorageDead(_7); + _0 = Option::<&mut u32>::Some(move _8); + StorageDead(_8); goto -> bb3; } bb3: { StorageDead(_4); - StorageDead(_8); + StorageDead(_7); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir index e07e2bb7bfe..2f5d356a26d 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir @@ -61,7 +61,6 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> bb0: { _3 = move (_2.0: usize); _4 = move (_2.1: usize); - StorageLive(_13); StorageLive(_5); _5 = &raw mut (*_1); StorageLive(_14); @@ -92,7 +91,6 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> StorageDead(_15); StorageDead(_5); _0 = &mut (*_13); - StorageDead(_13); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir index e07e2bb7bfe..2f5d356a26d 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir @@ -61,7 +61,6 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> bb0: { _3 = move (_2.0: usize); _4 = move (_2.1: usize); - StorageLive(_13); StorageLive(_5); _5 = &raw mut (*_1); StorageLive(_14); @@ -92,7 +91,6 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> StorageDead(_15); StorageDead(_5); _0 = &mut (*_13); - StorageDead(_13); return; } } 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 d1ab16697a6..2cf81d86267 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 @@ -152,11 +152,13 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb4: { StorageLive(_17); + StorageLive(_16); _16 = &mut _15; - _17 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(_16) -> [return: bb5, unwind unreachable]; + _17 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _16) -> [return: bb5, unwind unreachable]; } bb5: { + StorageDead(_16); _18 = discriminant(_17); switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir index 03751f7fdf7..6985806ec93 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir @@ -152,11 +152,13 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb4: { StorageLive(_17); + StorageLive(_16); _16 = &mut _15; - _17 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(_16) -> [return: bb5, unwind: bb11]; + _17 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _16) -> [return: bb5, unwind: bb11]; } bb5: { + StorageDead(_16); _18 = discriminant(_17); switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; } 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 db971e10f32..a4b8460e98e 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 @@ -140,11 +140,13 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb4: { StorageLive(_16); + StorageLive(_15); _15 = &mut _14; - _16 = <std::slice::Iter<'_, T> as Iterator>::next(_15) -> [return: bb5, unwind unreachable]; + _16 = <std::slice::Iter<'_, T> as Iterator>::next(move _15) -> [return: bb5, unwind unreachable]; } bb5: { + StorageDead(_15); _17 = discriminant(_16); switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; } 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 74597799168..58f312b1aac 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 @@ -140,11 +140,13 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb4: { StorageLive(_16); + StorageLive(_15); _15 = &mut _14; - _16 = <std::slice::Iter<'_, T> as Iterator>::next(_15) -> [return: bb5, unwind: bb11]; + _16 = <std::slice::Iter<'_, T> as Iterator>::next(move _15) -> [return: bb5, unwind: bb11]; } bb5: { + StorageDead(_15); _17 = discriminant(_16); switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; } diff --git a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir index b9329520bab..ed7107e53ef 100644 --- a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-abort.mir @@ -3,17 +3,19 @@ fn outer(_1: u8) -> u8 { debug v => _1; // in scope 0 at $DIR/spans.rs:10:14: 10:15 let mut _0: u8; // return place in scope 0 at $DIR/spans.rs:10:24: 10:26 - let _2: &u8; // in scope 0 at $DIR/spans.rs:11:11: 11:13 + let mut _2: &u8; // in scope 0 at $DIR/spans.rs:11:11: 11:13 bb0: { + StorageLive(_2); // scope 0 at $DIR/spans.rs:11:11: 11:13 _2 = &_1; // scope 0 at $DIR/spans.rs:11:11: 11:13 - _0 = inner(_2) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/spans.rs:11:5: 11:14 + _0 = inner(move _2) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/spans.rs:11:5: 11:14 // mir::Constant // + span: $DIR/spans.rs:11:5: 11:10 // + literal: Const { ty: for<'a> fn(&'a u8) -> u8 {inner}, val: Value(<ZST>) } } bb1: { + StorageDead(_2); // scope 0 at $DIR/spans.rs:11:13: 11:14 return; // scope 0 at $DIR/spans.rs:12:2: 12:2 } } diff --git a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir index 1e20b1be56b..dc436dc2650 100644 --- a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir @@ -3,17 +3,19 @@ fn outer(_1: u8) -> u8 { debug v => _1; // in scope 0 at $DIR/spans.rs:10:14: 10:15 let mut _0: u8; // return place in scope 0 at $DIR/spans.rs:10:24: 10:26 - let _2: &u8; // in scope 0 at $DIR/spans.rs:11:11: 11:13 + let mut _2: &u8; // in scope 0 at $DIR/spans.rs:11:11: 11:13 bb0: { + StorageLive(_2); // scope 0 at $DIR/spans.rs:11:11: 11:13 _2 = &_1; // scope 0 at $DIR/spans.rs:11:11: 11:13 - _0 = inner(_2) -> [return: bb1, unwind continue]; // scope 0 at $DIR/spans.rs:11:5: 11:14 + _0 = inner(move _2) -> [return: bb1, unwind continue]; // scope 0 at $DIR/spans.rs:11:5: 11:14 // mir::Constant // + span: $DIR/spans.rs:11:5: 11:10 // + literal: Const { ty: for<'a> fn(&'a u8) -> u8 {inner}, val: Value(<ZST>) } } bb1: { + StorageDead(_2); // scope 0 at $DIR/spans.rs:11:13: 11:14 return; // scope 0 at $DIR/spans.rs:12:2: 12:2 } } |
