From 7323f2adda2dcbc3cd5b0d1ae03d2a176c73be22 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sun, 16 Jun 2024 01:22:58 -0700 Subject: [PATCH] Replace `NormalizeArrayLen` with `GVN` GVN is actually on in release, and covers all the same things (or more), with `LowerSliceLen` changed to produce `PtrMetadata`. --- compiler/rustc_mir_transform/src/lib.rs | 4 - .../src/lower_slice_len.rs | 24 ++-- .../src/normalize_array_len.rs | 103 ------------------ tests/mir-opt/issue_76432.rs | 1 - ...rray_len.array_bound.GVN.panic-abort.diff} | 21 ++-- ...ray_len.array_bound.GVN.panic-unwind.diff} | 21 ++-- ..._len.array_bound_mut.GVN.panic-abort.diff} | 33 ++++-- ...len.array_bound_mut.GVN.panic-unwind.diff} | 33 ++++-- ..._array_len.array_len.GVN.panic-abort.diff} | 6 +- ...array_len.array_len.GVN.panic-unwind.diff} | 6 +- ...n.array_len_by_value.GVN.panic-abort.diff} | 6 +- ....array_len_by_value.GVN.panic-unwind.diff} | 6 +- ...ay_len.array_len_raw.GVN.panic-abort.diff} | 12 +- ...y_len.array_len_raw.GVN.panic-unwind.diff} | 12 +- ...n.array_len_reborrow.GVN.panic-abort.diff} | 12 +- ....array_len_reborrow.GVN.panic-unwind.diff} | 12 +- tests/mir-opt/lower_array_len.rs | 18 +-- ....bound.LowerSliceLenCalls.panic-abort.diff | 2 +- ...bound.LowerSliceLenCalls.panic-unwind.diff | 2 +- tests/mir-opt/pre-codegen/slice_index.rs | 2 +- ...mut_usize.PreCodegen.after.panic-abort.mir | 2 +- ...ut_usize.PreCodegen.after.panic-unwind.mir | 2 +- ...ated_loop.PreCodegen.after.panic-abort.mir | 2 +- ...ted_loop.PreCodegen.after.panic-unwind.mir | 2 +- ...ward_loop.PreCodegen.after.panic-abort.mir | 2 +- ...ard_loop.PreCodegen.after.panic-unwind.mir | 2 +- ...ange_loop.PreCodegen.after.panic-abort.mir | 2 +- ...nge_loop.PreCodegen.after.panic-unwind.mir | 2 +- ...erse_loop.PreCodegen.after.panic-abort.mir | 2 +- ...rse_loop.PreCodegen.after.panic-unwind.mir | 2 +- 30 files changed, 138 insertions(+), 218 deletions(-) delete mode 100644 compiler/rustc_mir_transform/src/normalize_array_len.rs rename tests/mir-opt/{lower_array_len.array_bound.NormalizeArrayLen.panic-abort.diff => lower_array_len.array_bound.GVN.panic-abort.diff} (69%) rename tests/mir-opt/{lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff => lower_array_len.array_bound.GVN.panic-unwind.diff} (69%) rename tests/mir-opt/{lower_array_len.array_bound_mut.NormalizeArrayLen.panic-abort.diff => lower_array_len.array_bound_mut.GVN.panic-abort.diff} (60%) rename tests/mir-opt/{lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff => lower_array_len.array_bound_mut.GVN.panic-unwind.diff} (60%) rename tests/mir-opt/{lower_array_len.array_len.NormalizeArrayLen.panic-abort.diff => lower_array_len.array_len.GVN.panic-abort.diff} (78%) rename tests/mir-opt/{lower_array_len.array_len.NormalizeArrayLen.panic-unwind.diff => lower_array_len.array_len.GVN.panic-unwind.diff} (78%) rename tests/mir-opt/{lower_array_len.array_len_by_value.NormalizeArrayLen.panic-abort.diff => lower_array_len.array_len_by_value.GVN.panic-abort.diff} (76%) rename tests/mir-opt/{lower_array_len.array_len_by_value.NormalizeArrayLen.panic-unwind.diff => lower_array_len.array_len_by_value.GVN.panic-unwind.diff} (76%) rename tests/mir-opt/{lower_array_len.array_len_raw.NormalizeArrayLen.panic-abort.diff => lower_array_len.array_len_raw.GVN.panic-abort.diff} (82%) rename tests/mir-opt/{lower_array_len.array_len_raw.NormalizeArrayLen.panic-unwind.diff => lower_array_len.array_len_raw.GVN.panic-unwind.diff} (82%) rename tests/mir-opt/{lower_array_len.array_len_reborrow.NormalizeArrayLen.panic-abort.diff => lower_array_len.array_len_reborrow.GVN.panic-abort.diff} (80%) rename tests/mir-opt/{lower_array_len.array_len_reborrow.NormalizeArrayLen.panic-unwind.diff => lower_array_len.array_len_reborrow.GVN.panic-unwind.diff} (80%) diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 3c0f4e9142b1a..5c70f8086a7cd 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -88,7 +88,6 @@ mod lower_slice_len; mod match_branches; mod mentioned_items; mod multiple_return_terminators; -mod normalize_array_len; mod nrvo; mod prettify; mod promote_consts; @@ -581,9 +580,6 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { &o1(simplify::SimplifyCfg::AfterUnreachableEnumBranching), // Inlining may have introduced a lot of redundant code and a large move pattern. // Now, we need to shrink the generated MIR. - - // Has to run after `slice::len` lowering - &normalize_array_len::NormalizeArrayLen, &ref_prop::ReferencePropagation, &sroa::ScalarReplacementOfAggregates, &match_branches::MatchBranchSimplification, diff --git a/compiler/rustc_mir_transform/src/lower_slice_len.rs b/compiler/rustc_mir_transform/src/lower_slice_len.rs index 2267a621a834a..77a7f4f47dd4e 100644 --- a/compiler/rustc_mir_transform/src/lower_slice_len.rs +++ b/compiler/rustc_mir_transform/src/lower_slice_len.rs @@ -1,10 +1,9 @@ -//! This pass lowers calls to core::slice::len to just Len op. +//! This pass lowers calls to core::slice::len to just PtrMetadata op. //! It should run before inlining! use rustc_hir::def_id::DefId; -use rustc_index::IndexSlice; use rustc_middle::mir::*; -use rustc_middle::ty::{self, TyCtxt}; +use rustc_middle::ty::TyCtxt; pub struct LowerSliceLenCalls; @@ -29,16 +28,11 @@ pub fn lower_slice_len_calls<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { let basic_blocks = body.basic_blocks.as_mut_preserves_cfg(); for block in basic_blocks { // lower `<[_]>::len` calls - lower_slice_len_call(tcx, block, &body.local_decls, slice_len_fn_item_def_id); + lower_slice_len_call(block, slice_len_fn_item_def_id); } } -fn lower_slice_len_call<'tcx>( - tcx: TyCtxt<'tcx>, - block: &mut BasicBlockData<'tcx>, - local_decls: &IndexSlice>, - slice_len_fn_item_def_id: DefId, -) { +fn lower_slice_len_call<'tcx>(block: &mut BasicBlockData<'tcx>, slice_len_fn_item_def_id: DefId) { let terminator = block.terminator(); if let TerminatorKind::Call { func, @@ -50,19 +44,17 @@ fn lower_slice_len_call<'tcx>( } = &terminator.kind // some heuristics for fast rejection && let [arg] = &args[..] - && let Some(arg) = arg.node.place() - && let ty::FnDef(fn_def_id, _) = func.ty(local_decls, tcx).kind() - && *fn_def_id == slice_len_fn_item_def_id + && let Some((fn_def_id, _)) = func.const_fn_def() + && fn_def_id == slice_len_fn_item_def_id { // perform modifications from something like: // _5 = core::slice::::len(move _6) -> bb1 // into: - // _5 = Len(*_6) + // _5 = PtrMetadata(move _6) // goto bb1 // make new RValue for Len - let deref_arg = tcx.mk_place_deref(arg); - let r_value = Rvalue::Len(deref_arg); + let r_value = Rvalue::UnaryOp(UnOp::PtrMetadata, arg.node.clone()); let len_statement_kind = StatementKind::Assign(Box::new((*destination, r_value))); let add_statement = Statement { kind: len_statement_kind, source_info: terminator.source_info }; diff --git a/compiler/rustc_mir_transform/src/normalize_array_len.rs b/compiler/rustc_mir_transform/src/normalize_array_len.rs deleted file mode 100644 index d5e727066614a..0000000000000 --- a/compiler/rustc_mir_transform/src/normalize_array_len.rs +++ /dev/null @@ -1,103 +0,0 @@ -//! This pass eliminates casting of arrays into slices when their length -//! is taken using `.len()` method. Handy to preserve information in MIR for const prop - -use crate::ssa::SsaLocals; -use rustc_index::IndexVec; -use rustc_middle::mir::visit::*; -use rustc_middle::mir::*; -use rustc_middle::ty::{self, TyCtxt}; - -pub struct NormalizeArrayLen; - -impl<'tcx> MirPass<'tcx> for NormalizeArrayLen { - fn is_enabled(&self, sess: &rustc_session::Session) -> bool { - sess.mir_opt_level() >= 3 - } - - #[instrument(level = "trace", skip(self, tcx, body))] - fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { - debug!(def_id = ?body.source.def_id()); - normalize_array_len_calls(tcx, body) - } -} - -fn normalize_array_len_calls<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { - let param_env = tcx.param_env_reveal_all_normalized(body.source.def_id()); - let ssa = SsaLocals::new(tcx, body, param_env); - - let slice_lengths = compute_slice_length(tcx, &ssa, body); - debug!(?slice_lengths); - - Replacer { tcx, slice_lengths }.visit_body_preserves_cfg(body); -} - -fn compute_slice_length<'tcx>( - tcx: TyCtxt<'tcx>, - ssa: &SsaLocals, - body: &Body<'tcx>, -) -> IndexVec>> { - let mut slice_lengths = IndexVec::from_elem(None, &body.local_decls); - - for (local, rvalue, _) in ssa.assignments(body) { - match rvalue { - Rvalue::Cast( - CastKind::PointerCoercion(ty::adjustment::PointerCoercion::Unsize), - operand, - cast_ty, - ) => { - let operand_ty = operand.ty(body, tcx); - debug!(?operand_ty); - if let Some(operand_ty) = operand_ty.builtin_deref(true) - && let ty::Array(_, len) = operand_ty.kind() - && let Some(cast_ty) = cast_ty.builtin_deref(true) - && let ty::Slice(..) = cast_ty.kind() - { - slice_lengths[local] = Some(*len); - } - } - // The length information is stored in the fat pointer, so we treat `operand` as a value. - Rvalue::Use(operand) => { - if let Some(rhs) = operand.place() - && let Some(rhs) = rhs.as_local() - { - slice_lengths[local] = slice_lengths[rhs]; - } - } - // The length information is stored in the fat pointer. - // Reborrowing copies length information from one pointer to the other. - Rvalue::Ref(_, _, rhs) | Rvalue::AddressOf(_, rhs) => { - if let [PlaceElem::Deref] = rhs.projection[..] { - slice_lengths[local] = slice_lengths[rhs.local]; - } - } - _ => {} - } - } - - slice_lengths -} - -struct Replacer<'tcx> { - tcx: TyCtxt<'tcx>, - slice_lengths: IndexVec>>, -} - -impl<'tcx> MutVisitor<'tcx> for Replacer<'tcx> { - fn tcx(&self) -> TyCtxt<'tcx> { - self.tcx - } - - fn visit_rvalue(&mut self, rvalue: &mut Rvalue<'tcx>, loc: Location) { - if let Rvalue::Len(place) = rvalue - && let [PlaceElem::Deref] = &place.projection[..] - && let Some(len) = self.slice_lengths[place.local] - { - *rvalue = Rvalue::Use(Operand::Constant(Box::new(ConstOperand { - span: rustc_span::DUMMY_SP, - user_ty: None, - const_: Const::from_ty_const(len, self.tcx.types.usize, self.tcx), - }))); - } - self.super_rvalue(rvalue, loc); - } -} diff --git a/tests/mir-opt/issue_76432.rs b/tests/mir-opt/issue_76432.rs index be5ccbd49e24f..4422827369a4e 100644 --- a/tests/mir-opt/issue_76432.rs +++ b/tests/mir-opt/issue_76432.rs @@ -1,6 +1,5 @@ // skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -//@ compile-flags: -Zmir-enable-passes=-NormalizeArrayLen // Check that we do not insert StorageDead at each target if StorageDead was never seen // EMIT_MIR issue_76432.test.SimplifyComparisonIntegral.diff diff --git a/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-abort.diff b/tests/mir-opt/lower_array_len.array_bound.GVN.panic-abort.diff similarity index 69% rename from tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-abort.diff rename to tests/mir-opt/lower_array_len.array_bound.GVN.panic-abort.diff index 5242c5f6afd87..6c0c7a1d4389e 100644 --- a/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-abort.diff +++ b/tests/mir-opt/lower_array_len.array_bound.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `array_bound` before NormalizeArrayLen -+ // MIR for `array_bound` after NormalizeArrayLen +- // MIR for `array_bound` before GVN ++ // MIR for `array_bound` after GVN fn array_bound(_1: usize, _2: &[u8; N]) -> u8 { debug index => _1; @@ -24,14 +24,15 @@ _7 = &(*_2); _6 = move _7 as &[u8] (PointerCoercion(Unsize)); StorageDead(_7); -- _5 = Len((*_6)); +- _5 = PtrMetadata(move _6); + _5 = const N; goto -> bb1; } bb1: { StorageDead(_6); - _3 = Lt(move _4, move _5); +- _3 = Lt(move _4, move _5); ++ _3 = Lt(_1, move _5); switchInt(move _3) -> [0: bb4, otherwise: bb2]; } @@ -40,13 +41,17 @@ StorageDead(_4); StorageLive(_8); _8 = _1; - _9 = Len((*_2)); - _10 = Lt(_8, _9); - assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> [success: bb3, unwind unreachable]; +- _9 = Len((*_2)); +- _10 = Lt(_8, _9); +- assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> [success: bb3, unwind unreachable]; ++ _9 = const N; ++ _10 = Lt(_1, const N); ++ assert(move _10, "index out of bounds: the length is {} but the index is {}", const N, _1) -> [success: bb3, unwind unreachable]; } bb3: { - _0 = (*_2)[_8]; +- _0 = (*_2)[_8]; ++ _0 = (*_2)[_1]; StorageDead(_8); goto -> bb5; } diff --git a/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff b/tests/mir-opt/lower_array_len.array_bound.GVN.panic-unwind.diff similarity index 69% rename from tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff rename to tests/mir-opt/lower_array_len.array_bound.GVN.panic-unwind.diff index a9e99933b123f..ed41703c8734f 100644 --- a/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff +++ b/tests/mir-opt/lower_array_len.array_bound.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `array_bound` before NormalizeArrayLen -+ // MIR for `array_bound` after NormalizeArrayLen +- // MIR for `array_bound` before GVN ++ // MIR for `array_bound` after GVN fn array_bound(_1: usize, _2: &[u8; N]) -> u8 { debug index => _1; @@ -24,14 +24,15 @@ _7 = &(*_2); _6 = move _7 as &[u8] (PointerCoercion(Unsize)); StorageDead(_7); -- _5 = Len((*_6)); +- _5 = PtrMetadata(move _6); + _5 = const N; goto -> bb1; } bb1: { StorageDead(_6); - _3 = Lt(move _4, move _5); +- _3 = Lt(move _4, move _5); ++ _3 = Lt(_1, move _5); switchInt(move _3) -> [0: bb4, otherwise: bb2]; } @@ -40,13 +41,17 @@ StorageDead(_4); StorageLive(_8); _8 = _1; - _9 = Len((*_2)); - _10 = Lt(_8, _9); - assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> [success: bb3, unwind continue]; +- _9 = Len((*_2)); +- _10 = Lt(_8, _9); +- assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> [success: bb3, unwind continue]; ++ _9 = const N; ++ _10 = Lt(_1, const N); ++ assert(move _10, "index out of bounds: the length is {} but the index is {}", const N, _1) -> [success: bb3, unwind continue]; } bb3: { - _0 = (*_2)[_8]; +- _0 = (*_2)[_8]; ++ _0 = (*_2)[_1]; StorageDead(_8); goto -> bb5; } diff --git a/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-abort.diff b/tests/mir-opt/lower_array_len.array_bound_mut.GVN.panic-abort.diff similarity index 60% rename from tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-abort.diff rename to tests/mir-opt/lower_array_len.array_bound_mut.GVN.panic-abort.diff index 7749ba6beca76..80e8ea37f4182 100644 --- a/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-abort.diff +++ b/tests/mir-opt/lower_array_len.array_bound_mut.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `array_bound_mut` before NormalizeArrayLen -+ // MIR for `array_bound_mut` after NormalizeArrayLen +- // MIR for `array_bound_mut` before GVN ++ // MIR for `array_bound_mut` after GVN fn array_bound_mut(_1: usize, _2: &mut [u8; N]) -> u8 { debug index => _1; @@ -27,14 +27,15 @@ _7 = &(*_2); _6 = move _7 as &[u8] (PointerCoercion(Unsize)); StorageDead(_7); -- _5 = Len((*_6)); +- _5 = PtrMetadata(move _6); + _5 = const N; goto -> bb1; } bb1: { StorageDead(_6); - _3 = Lt(move _4, move _5); +- _3 = Lt(move _4, move _5); ++ _3 = Lt(_1, move _5); switchInt(move _3) -> [0: bb4, otherwise: bb2]; } @@ -43,13 +44,17 @@ StorageDead(_4); StorageLive(_8); _8 = _1; - _9 = Len((*_2)); - _10 = Lt(_8, _9); - assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> [success: bb3, unwind unreachable]; +- _9 = Len((*_2)); +- _10 = Lt(_8, _9); +- assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> [success: bb3, unwind unreachable]; ++ _9 = const N; ++ _10 = Lt(_1, const N); ++ assert(move _10, "index out of bounds: the length is {} but the index is {}", const N, _1) -> [success: bb3, unwind unreachable]; } bb3: { - _0 = (*_2)[_8]; +- _0 = (*_2)[_8]; ++ _0 = (*_2)[_1]; StorageDead(_8); goto -> bb6; } @@ -59,13 +64,17 @@ StorageDead(_4); StorageLive(_11); _11 = const 0_usize; - _12 = Len((*_2)); - _13 = Lt(_11, _12); - assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb5, unwind unreachable]; +- _12 = Len((*_2)); +- _13 = Lt(_11, _12); +- assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb5, unwind unreachable]; ++ _12 = const N; ++ _13 = Lt(const 0_usize, const N); ++ assert(move _13, "index out of bounds: the length is {} but the index is {}", const N, const 0_usize) -> [success: bb5, unwind unreachable]; } bb5: { - (*_2)[_11] = const 42_u8; +- (*_2)[_11] = const 42_u8; ++ (*_2)[0 of 1] = const 42_u8; StorageDead(_11); _0 = const 42_u8; goto -> bb6; diff --git a/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff b/tests/mir-opt/lower_array_len.array_bound_mut.GVN.panic-unwind.diff similarity index 60% rename from tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff rename to tests/mir-opt/lower_array_len.array_bound_mut.GVN.panic-unwind.diff index fcc2c1653dc1d..6e67a6c17efb2 100644 --- a/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff +++ b/tests/mir-opt/lower_array_len.array_bound_mut.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `array_bound_mut` before NormalizeArrayLen -+ // MIR for `array_bound_mut` after NormalizeArrayLen +- // MIR for `array_bound_mut` before GVN ++ // MIR for `array_bound_mut` after GVN fn array_bound_mut(_1: usize, _2: &mut [u8; N]) -> u8 { debug index => _1; @@ -27,14 +27,15 @@ _7 = &(*_2); _6 = move _7 as &[u8] (PointerCoercion(Unsize)); StorageDead(_7); -- _5 = Len((*_6)); +- _5 = PtrMetadata(move _6); + _5 = const N; goto -> bb1; } bb1: { StorageDead(_6); - _3 = Lt(move _4, move _5); +- _3 = Lt(move _4, move _5); ++ _3 = Lt(_1, move _5); switchInt(move _3) -> [0: bb4, otherwise: bb2]; } @@ -43,13 +44,17 @@ StorageDead(_4); StorageLive(_8); _8 = _1; - _9 = Len((*_2)); - _10 = Lt(_8, _9); - assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> [success: bb3, unwind continue]; +- _9 = Len((*_2)); +- _10 = Lt(_8, _9); +- assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> [success: bb3, unwind continue]; ++ _9 = const N; ++ _10 = Lt(_1, const N); ++ assert(move _10, "index out of bounds: the length is {} but the index is {}", const N, _1) -> [success: bb3, unwind continue]; } bb3: { - _0 = (*_2)[_8]; +- _0 = (*_2)[_8]; ++ _0 = (*_2)[_1]; StorageDead(_8); goto -> bb6; } @@ -59,13 +64,17 @@ StorageDead(_4); StorageLive(_11); _11 = const 0_usize; - _12 = Len((*_2)); - _13 = Lt(_11, _12); - assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb5, unwind continue]; +- _12 = Len((*_2)); +- _13 = Lt(_11, _12); +- assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb5, unwind continue]; ++ _12 = const N; ++ _13 = Lt(const 0_usize, const N); ++ assert(move _13, "index out of bounds: the length is {} but the index is {}", const N, const 0_usize) -> [success: bb5, unwind continue]; } bb5: { - (*_2)[_11] = const 42_u8; +- (*_2)[_11] = const 42_u8; ++ (*_2)[0 of 1] = const 42_u8; StorageDead(_11); _0 = const 42_u8; goto -> bb6; diff --git a/tests/mir-opt/lower_array_len.array_len.NormalizeArrayLen.panic-abort.diff b/tests/mir-opt/lower_array_len.array_len.GVN.panic-abort.diff similarity index 78% rename from tests/mir-opt/lower_array_len.array_len.NormalizeArrayLen.panic-abort.diff rename to tests/mir-opt/lower_array_len.array_len.GVN.panic-abort.diff index 1bdc62183c37f..9c1b9a708c59a 100644 --- a/tests/mir-opt/lower_array_len.array_len.NormalizeArrayLen.panic-abort.diff +++ b/tests/mir-opt/lower_array_len.array_len.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `array_len` before NormalizeArrayLen -+ // MIR for `array_len` after NormalizeArrayLen +- // MIR for `array_len` before GVN ++ // MIR for `array_len` after GVN fn array_len(_1: &[u8; N]) -> usize { debug arr => _1; @@ -13,7 +13,7 @@ _3 = &(*_1); _2 = move _3 as &[u8] (PointerCoercion(Unsize)); StorageDead(_3); -- _0 = Len((*_2)); +- _0 = PtrMetadata(move _2); + _0 = const N; goto -> bb1; } diff --git a/tests/mir-opt/lower_array_len.array_len.NormalizeArrayLen.panic-unwind.diff b/tests/mir-opt/lower_array_len.array_len.GVN.panic-unwind.diff similarity index 78% rename from tests/mir-opt/lower_array_len.array_len.NormalizeArrayLen.panic-unwind.diff rename to tests/mir-opt/lower_array_len.array_len.GVN.panic-unwind.diff index 1bdc62183c37f..9c1b9a708c59a 100644 --- a/tests/mir-opt/lower_array_len.array_len.NormalizeArrayLen.panic-unwind.diff +++ b/tests/mir-opt/lower_array_len.array_len.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `array_len` before NormalizeArrayLen -+ // MIR for `array_len` after NormalizeArrayLen +- // MIR for `array_len` before GVN ++ // MIR for `array_len` after GVN fn array_len(_1: &[u8; N]) -> usize { debug arr => _1; @@ -13,7 +13,7 @@ _3 = &(*_1); _2 = move _3 as &[u8] (PointerCoercion(Unsize)); StorageDead(_3); -- _0 = Len((*_2)); +- _0 = PtrMetadata(move _2); + _0 = const N; goto -> bb1; } diff --git a/tests/mir-opt/lower_array_len.array_len_by_value.NormalizeArrayLen.panic-abort.diff b/tests/mir-opt/lower_array_len.array_len_by_value.GVN.panic-abort.diff similarity index 76% rename from tests/mir-opt/lower_array_len.array_len_by_value.NormalizeArrayLen.panic-abort.diff rename to tests/mir-opt/lower_array_len.array_len_by_value.GVN.panic-abort.diff index 9862b2fad8eec..97fa503ac2e46 100644 --- a/tests/mir-opt/lower_array_len.array_len_by_value.NormalizeArrayLen.panic-abort.diff +++ b/tests/mir-opt/lower_array_len.array_len_by_value.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `array_len_by_value` before NormalizeArrayLen -+ // MIR for `array_len_by_value` after NormalizeArrayLen +- // MIR for `array_len_by_value` before GVN ++ // MIR for `array_len_by_value` after GVN fn array_len_by_value(_1: [u8; N]) -> usize { debug arr => _1; @@ -13,7 +13,7 @@ _3 = &_1; _2 = move _3 as &[u8] (PointerCoercion(Unsize)); StorageDead(_3); -- _0 = Len((*_2)); +- _0 = PtrMetadata(move _2); + _0 = const N; goto -> bb1; } diff --git a/tests/mir-opt/lower_array_len.array_len_by_value.NormalizeArrayLen.panic-unwind.diff b/tests/mir-opt/lower_array_len.array_len_by_value.GVN.panic-unwind.diff similarity index 76% rename from tests/mir-opt/lower_array_len.array_len_by_value.NormalizeArrayLen.panic-unwind.diff rename to tests/mir-opt/lower_array_len.array_len_by_value.GVN.panic-unwind.diff index 9862b2fad8eec..97fa503ac2e46 100644 --- a/tests/mir-opt/lower_array_len.array_len_by_value.NormalizeArrayLen.panic-unwind.diff +++ b/tests/mir-opt/lower_array_len.array_len_by_value.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `array_len_by_value` before NormalizeArrayLen -+ // MIR for `array_len_by_value` after NormalizeArrayLen +- // MIR for `array_len_by_value` before GVN ++ // MIR for `array_len_by_value` after GVN fn array_len_by_value(_1: [u8; N]) -> usize { debug arr => _1; @@ -13,7 +13,7 @@ _3 = &_1; _2 = move _3 as &[u8] (PointerCoercion(Unsize)); StorageDead(_3); -- _0 = Len((*_2)); +- _0 = PtrMetadata(move _2); + _0 = const N; goto -> bb1; } diff --git a/tests/mir-opt/lower_array_len.array_len_raw.NormalizeArrayLen.panic-abort.diff b/tests/mir-opt/lower_array_len.array_len_raw.GVN.panic-abort.diff similarity index 82% rename from tests/mir-opt/lower_array_len.array_len_raw.NormalizeArrayLen.panic-abort.diff rename to tests/mir-opt/lower_array_len.array_len_raw.GVN.panic-abort.diff index 633a344a2edb3..b5e8b66813ae3 100644 --- a/tests/mir-opt/lower_array_len.array_len_raw.NormalizeArrayLen.panic-abort.diff +++ b/tests/mir-opt/lower_array_len.array_len_raw.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `array_len_raw` before NormalizeArrayLen -+ // MIR for `array_len_raw` after NormalizeArrayLen +- // MIR for `array_len_raw` before GVN ++ // MIR for `array_len_raw` after GVN fn array_len_raw(_1: [u8; N]) -> usize { debug arr => _1; @@ -18,7 +18,8 @@ } bb0: { - StorageLive(_2); +- StorageLive(_2); ++ nop; StorageLive(_3); StorageLive(_4); _4 = &_1; @@ -32,7 +33,7 @@ StorageLive(_7); _7 = &(*_5); _6 = &(*_7); -- _0 = Len((*_6)); +- _0 = PtrMetadata(move _6); + _0 = const N; goto -> bb1; } @@ -40,7 +41,8 @@ bb1: { StorageDead(_6); StorageDead(_5); - StorageDead(_2); +- StorageDead(_2); ++ nop; StorageDead(_7); return; } diff --git a/tests/mir-opt/lower_array_len.array_len_raw.NormalizeArrayLen.panic-unwind.diff b/tests/mir-opt/lower_array_len.array_len_raw.GVN.panic-unwind.diff similarity index 82% rename from tests/mir-opt/lower_array_len.array_len_raw.NormalizeArrayLen.panic-unwind.diff rename to tests/mir-opt/lower_array_len.array_len_raw.GVN.panic-unwind.diff index 633a344a2edb3..b5e8b66813ae3 100644 --- a/tests/mir-opt/lower_array_len.array_len_raw.NormalizeArrayLen.panic-unwind.diff +++ b/tests/mir-opt/lower_array_len.array_len_raw.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `array_len_raw` before NormalizeArrayLen -+ // MIR for `array_len_raw` after NormalizeArrayLen +- // MIR for `array_len_raw` before GVN ++ // MIR for `array_len_raw` after GVN fn array_len_raw(_1: [u8; N]) -> usize { debug arr => _1; @@ -18,7 +18,8 @@ } bb0: { - StorageLive(_2); +- StorageLive(_2); ++ nop; StorageLive(_3); StorageLive(_4); _4 = &_1; @@ -32,7 +33,7 @@ StorageLive(_7); _7 = &(*_5); _6 = &(*_7); -- _0 = Len((*_6)); +- _0 = PtrMetadata(move _6); + _0 = const N; goto -> bb1; } @@ -40,7 +41,8 @@ bb1: { StorageDead(_6); StorageDead(_5); - StorageDead(_2); +- StorageDead(_2); ++ nop; StorageDead(_7); return; } diff --git a/tests/mir-opt/lower_array_len.array_len_reborrow.NormalizeArrayLen.panic-abort.diff b/tests/mir-opt/lower_array_len.array_len_reborrow.GVN.panic-abort.diff similarity index 80% rename from tests/mir-opt/lower_array_len.array_len_reborrow.NormalizeArrayLen.panic-abort.diff rename to tests/mir-opt/lower_array_len.array_len_reborrow.GVN.panic-abort.diff index ecba06a2e4de7..0299c6acd804a 100644 --- a/tests/mir-opt/lower_array_len.array_len_reborrow.NormalizeArrayLen.panic-abort.diff +++ b/tests/mir-opt/lower_array_len.array_len_reborrow.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `array_len_reborrow` before NormalizeArrayLen -+ // MIR for `array_len_reborrow` after NormalizeArrayLen +- // MIR for `array_len_reborrow` before GVN ++ // MIR for `array_len_reborrow` after GVN fn array_len_reborrow(_1: [u8; N]) -> usize { debug arr => _1; @@ -17,7 +17,8 @@ } bb0: { - StorageLive(_2); +- StorageLive(_2); ++ nop; StorageLive(_3); StorageLive(_4); _4 = &mut _1; @@ -29,7 +30,7 @@ _5 = &(*_2); StorageLive(_6); _6 = &(*_5); -- _0 = Len((*_6)); +- _0 = PtrMetadata(move _6); + _0 = const N; goto -> bb1; } @@ -37,7 +38,8 @@ bb1: { StorageDead(_6); StorageDead(_5); - StorageDead(_2); +- StorageDead(_2); ++ nop; return; } } diff --git a/tests/mir-opt/lower_array_len.array_len_reborrow.NormalizeArrayLen.panic-unwind.diff b/tests/mir-opt/lower_array_len.array_len_reborrow.GVN.panic-unwind.diff similarity index 80% rename from tests/mir-opt/lower_array_len.array_len_reborrow.NormalizeArrayLen.panic-unwind.diff rename to tests/mir-opt/lower_array_len.array_len_reborrow.GVN.panic-unwind.diff index ecba06a2e4de7..0299c6acd804a 100644 --- a/tests/mir-opt/lower_array_len.array_len_reborrow.NormalizeArrayLen.panic-unwind.diff +++ b/tests/mir-opt/lower_array_len.array_len_reborrow.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `array_len_reborrow` before NormalizeArrayLen -+ // MIR for `array_len_reborrow` after NormalizeArrayLen +- // MIR for `array_len_reborrow` before GVN ++ // MIR for `array_len_reborrow` after GVN fn array_len_reborrow(_1: [u8; N]) -> usize { debug arr => _1; @@ -17,7 +17,8 @@ } bb0: { - StorageLive(_2); +- StorageLive(_2); ++ nop; StorageLive(_3); StorageLive(_4); _4 = &mut _1; @@ -29,7 +30,7 @@ _5 = &(*_2); StorageLive(_6); _6 = &(*_5); -- _0 = Len((*_6)); +- _0 = PtrMetadata(move _6); + _0 = const N; goto -> bb1; } @@ -37,7 +38,8 @@ bb1: { StorageDead(_6); StorageDead(_5); - StorageDead(_2); +- StorageDead(_2); ++ nop; return; } } diff --git a/tests/mir-opt/lower_array_len.rs b/tests/mir-opt/lower_array_len.rs index 62fc9ef67d66a..caa598d067a36 100644 --- a/tests/mir-opt/lower_array_len.rs +++ b/tests/mir-opt/lower_array_len.rs @@ -1,20 +1,20 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -//@ test-mir-pass: NormalizeArrayLen +//@ test-mir-pass: GVN //@ compile-flags: -Zmir-enable-passes=+LowerSliceLenCalls -// EMIT_MIR lower_array_len.array_bound.NormalizeArrayLen.diff +// EMIT_MIR lower_array_len.array_bound.GVN.diff pub fn array_bound(index: usize, slice: &[u8; N]) -> u8 { // CHECK-LABEL: fn array_bound( // CHECK: [[len:_.*]] = const N; - // CHECK: Lt(move {{_.*}}, move [[len]]); + // CHECK: Lt(_1, move [[len]]); if index < slice.len() { slice[index] } else { 42 } } -// EMIT_MIR lower_array_len.array_bound_mut.NormalizeArrayLen.diff +// EMIT_MIR lower_array_len.array_bound_mut.GVN.diff pub fn array_bound_mut(index: usize, slice: &mut [u8; N]) -> u8 { // CHECK-LABEL: fn array_bound_mut( // CHECK: [[len:_.*]] = const N; - // CHECK: Lt(move {{_.*}}, move [[len]]); + // CHECK: Lt(_1, move [[len]]); if index < slice.len() { slice[index] } else { @@ -24,21 +24,21 @@ pub fn array_bound_mut(index: usize, slice: &mut [u8; N]) -> u8 } } -// EMIT_MIR lower_array_len.array_len.NormalizeArrayLen.diff +// EMIT_MIR lower_array_len.array_len.GVN.diff pub fn array_len(arr: &[u8; N]) -> usize { // CHECK-LABEL: fn array_len( // CHECK: _0 = const N; arr.len() } -// EMIT_MIR lower_array_len.array_len_by_value.NormalizeArrayLen.diff +// EMIT_MIR lower_array_len.array_len_by_value.GVN.diff pub fn array_len_by_value(arr: [u8; N]) -> usize { // CHECK-LABEL: fn array_len_by_value( // CHECK: _0 = const N; arr.len() } -// EMIT_MIR lower_array_len.array_len_reborrow.NormalizeArrayLen.diff +// EMIT_MIR lower_array_len.array_len_reborrow.GVN.diff pub fn array_len_reborrow(mut arr: [u8; N]) -> usize { // CHECK-LABEL: fn array_len_reborrow( // CHECK: _0 = const N; @@ -47,7 +47,7 @@ pub fn array_len_reborrow(mut arr: [u8; N]) -> usize { arr.len() } -// EMIT_MIR lower_array_len.array_len_raw.NormalizeArrayLen.diff +// EMIT_MIR lower_array_len.array_len_raw.GVN.diff pub fn array_len_raw(arr: [u8; N]) -> usize { // CHECK-LABEL: fn array_len_raw( // CHECK: _0 = const N; diff --git a/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-abort.diff b/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-abort.diff index 7f752ca0f5a2c..a212ee6788115 100644 --- a/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-abort.diff +++ b/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-abort.diff @@ -21,7 +21,7 @@ StorageLive(_6); _6 = &(*_2); - _5 = core::slice::::len(move _6) -> [return: bb1, unwind unreachable]; -+ _5 = Len((*_6)); ++ _5 = PtrMetadata(move _6); + goto -> bb1; } diff --git a/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-unwind.diff b/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-unwind.diff index d73b563a0e5de..38ec8a5b0c72e 100644 --- a/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-unwind.diff +++ b/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-unwind.diff @@ -21,7 +21,7 @@ StorageLive(_6); _6 = &(*_2); - _5 = core::slice::::len(move _6) -> [return: bb1, unwind continue]; -+ _5 = Len((*_6)); ++ _5 = PtrMetadata(move _6); + goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/slice_index.rs b/tests/mir-opt/pre-codegen/slice_index.rs index 886e57a3380c1..6ddc4ad022075 100644 --- a/tests/mir-opt/pre-codegen/slice_index.rs +++ b/tests/mir-opt/pre-codegen/slice_index.rs @@ -19,7 +19,7 @@ pub fn slice_index_usize(slice: &[u32], index: usize) -> u32 { // EMIT_MIR slice_index.slice_get_mut_usize.PreCodegen.after.mir pub fn slice_get_mut_usize(slice: &mut [u32], index: usize) -> Option<&mut u32> { // CHECK-LABEL: slice_get_mut_usize - // CHECK: [[LEN:_[0-9]+]] = Len((*_1)) + // CHECK: [[LEN:_[0-9]+]] = PtrMetadata(_1) // CHECK: Lt(_2, move [[LEN]]) // CHECK-NOT: precondition_check slice.get_mut(index) 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 f2ef2b0cc3c6c..d7f09fafeebe7 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 @@ -23,7 +23,7 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { StorageLive(_7); StorageLive(_4); StorageLive(_3); - _3 = Len((*_1)); + _3 = PtrMetadata(_1); _4 = Lt(_2, move _3); switchInt(move _4) -> [0: bb1, otherwise: bb2]; } 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 f2ef2b0cc3c6c..d7f09fafeebe7 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 @@ -23,7 +23,7 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { StorageLive(_7); StorageLive(_4); StorageLive(_3); - _3 = Len((*_1)); + _3 = PtrMetadata(_1); _4 = Lt(_2, move _3); switchInt(move _4) -> [0: bb1, otherwise: bb2]; } 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 8f41fb70925f2..7d0ff3be628f7 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 @@ -65,7 +65,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { StorageLive(_6); StorageLive(_4); StorageLive(_5); - _3 = Len((*_1)); + _3 = PtrMetadata(_1); _4 = &raw const (*_1); _5 = _4 as *const T (PtrToPtr); _6 = NonNull:: { pointer: _5 }; 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 17cf305468e8c..73b3235d30fa7 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 @@ -65,7 +65,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { StorageLive(_6); StorageLive(_4); StorageLive(_5); - _3 = Len((*_1)); + _3 = PtrMetadata(_1); _4 = &raw const (*_1); _5 = _4 as *const T (PtrToPtr); _6 = NonNull:: { pointer: _5 }; 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 3c1bbdc87424e..1831cfd937b90 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 @@ -57,7 +57,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { StorageLive(_6); StorageLive(_4); StorageLive(_5); - _3 = Len((*_1)); + _3 = PtrMetadata(_1); _4 = &raw const (*_1); _5 = _4 as *const T (PtrToPtr); _6 = NonNull:: { pointer: _5 }; 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 b2ec1ea7b9f2f..f78575786330b 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 @@ -57,7 +57,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { StorageLive(_6); StorageLive(_4); StorageLive(_5); - _3 = Len((*_1)); + _3 = PtrMetadata(_1); _4 = &raw const (*_1); _5 = _4 as *const T (PtrToPtr); _6 = NonNull:: { pointer: _5 }; diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir index dbe6f39548c8c..cea2fcbcdc0b2 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir @@ -40,7 +40,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb0: { - _3 = Len((*_1)); + _3 = PtrMetadata(_1); StorageLive(_4); _4 = const 0_usize; goto -> bb1; diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir index 5b6441cfb3b21..bd658a770ea91 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir @@ -40,7 +40,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb0: { - _3 = Len((*_1)); + _3 = PtrMetadata(_1); StorageLive(_4); _4 = const 0_usize; goto -> bb1; diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir index bf982f076de7a..4d3a72824a1da 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir @@ -65,7 +65,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { StorageLive(_6); StorageLive(_4); StorageLive(_5); - _3 = Len((*_1)); + _3 = PtrMetadata(_1); _4 = &raw const (*_1); _5 = _4 as *const T (PtrToPtr); _6 = NonNull:: { pointer: _5 }; diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir index 532b81625212c..44a0525224024 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir @@ -65,7 +65,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { StorageLive(_6); StorageLive(_4); StorageLive(_5); - _3 = Len((*_1)); + _3 = PtrMetadata(_1); _4 = &raw const (*_1); _5 = _4 as *const T (PtrToPtr); _6 = NonNull:: { pointer: _5 };