diff --git a/compiler/rustc_middle/src/mir/consts.rs b/compiler/rustc_middle/src/mir/consts.rs index 5764a9c84eeaf..ca80c9995b95e 100644 --- a/compiler/rustc_middle/src/mir/consts.rs +++ b/compiler/rustc_middle/src/mir/consts.rs @@ -495,6 +495,11 @@ impl<'tcx> Const<'tcx> { /// Return true if any evaluation of this constant always returns the same value, /// taking into account even pointer identity tests. pub fn is_deterministic(&self) -> bool { + if self.ty().is_primitive() { + // Primitive types hold no provenance, so their result is deterministic. + return true; + } + // Some constants may generate fresh allocations for pointers they contain, // so using the same constant twice can yield two different results. // Notably, valtrees purposefully generate new allocations. diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 3ff8dc6dbb378..aeee897069c05 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -91,6 +91,7 @@ use either::Either; use hashbrown::hash_table::{Entry, HashTable}; use itertools::Itertools as _; use rustc_abi::{self as abi, BackendRepr, FIRST_VARIANT, FieldIdx, Primitive, Size, VariantIdx}; +use rustc_arena::DroplessArena; use rustc_const_eval::const_eval::DummyMachine; use rustc_const_eval::interpret::{ ImmTy, Immediate, InterpCx, MemPlaceMeta, MemoryKind, OpTy, Projectable, Scalar, @@ -129,7 +130,9 @@ impl<'tcx> crate::MirPass<'tcx> for GVN { // Clone dominators because we need them while mutating the body. let dominators = body.basic_blocks.dominators().clone(); - let mut state = VnState::new(tcx, body, typing_env, &ssa, dominators, &body.local_decls); + let arena = DroplessArena::default(); + let mut state = + VnState::new(tcx, body, typing_env, &ssa, dominators, &body.local_decls, &arena); for local in body.args_iter().filter(|&local| ssa.is_ssa(local)) { let opaque = state.new_opaque(body.local_decls[local].ty); @@ -142,6 +145,10 @@ impl<'tcx> crate::MirPass<'tcx> for GVN { state.visit_basic_block_data(bb, data); } + for var_debug_info in body.var_debug_info.iter_mut() { + state.visit_var_debug_info(var_debug_info); + } + // For each local that is reused (`y` above), we remove its storage statements do avoid any // difficulty. Those locals are SSA, so should be easy to optimize by LLVM without storage // statements. @@ -183,8 +190,16 @@ enum AddressKind { Address(RawPtrKind), } -#[derive(Debug, PartialEq, Eq, Hash)] -enum Value<'tcx> { +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +enum AddressBase { + /// This address is based on this local. + Local(Local), + /// This address is based on the deref of this pointer. + Deref(VnIndex), +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +enum Value<'a, 'tcx> { // Root values. /// Used to represent values we know nothing about. /// The `usize` is a counter incremented by `new_opaque`. @@ -201,7 +216,7 @@ enum Value<'tcx> { // Aggregates. /// An aggregate value, either tuple/closure/struct/enum. /// This does not contain unions, as we cannot reason with the value. - Aggregate(VariantIdx, Vec), + Aggregate(VariantIdx, &'a [VnIndex]), /// A raw pointer aggregate built from a thin pointer and metadata. RawPtr { /// Thin pointer component. This is field 0 in MIR. @@ -213,7 +228,10 @@ enum Value<'tcx> { Repeat(VnIndex, ty::Const<'tcx>), /// The address of a place. Address { - place: Place<'tcx>, + base: AddressBase, + // We do not use a plain `Place` as we want to be able to reason about indices. + // This does not contain any `Deref` projection. + projection: &'a [ProjectionElem>], kind: AddressKind, /// Give each borrow and pointer a different provenance, so we don't merge them. provenance: VnOpaque, @@ -240,15 +258,15 @@ enum Value<'tcx> { /// This data structure is mostly a partial reimplementation of `FxIndexMap`. /// We do not use a regular `FxIndexMap` to skip hashing values that are unique by construction, /// like opaque values, address with provenance and non-deterministic constants. -struct ValueSet<'tcx> { +struct ValueSet<'a, 'tcx> { indices: HashTable, hashes: IndexVec, - values: IndexVec>, + values: IndexVec>, types: IndexVec>, } -impl<'tcx> ValueSet<'tcx> { - fn new(num_values: usize) -> ValueSet<'tcx> { +impl<'a, 'tcx> ValueSet<'a, 'tcx> { + fn new(num_values: usize) -> ValueSet<'a, 'tcx> { ValueSet { indices: HashTable::with_capacity(num_values), hashes: IndexVec::with_capacity(num_values), @@ -263,7 +281,7 @@ impl<'tcx> ValueSet<'tcx> { fn insert_unique( &mut self, ty: Ty<'tcx>, - value: impl FnOnce(VnOpaque) -> Value<'tcx>, + value: impl FnOnce(VnOpaque) -> Value<'a, 'tcx>, ) -> VnIndex { let value = value(VnOpaque); @@ -284,7 +302,7 @@ impl<'tcx> ValueSet<'tcx> { /// Insert a `(Value, Ty)` pair to be deduplicated. /// Returns `true` as second tuple field if this value did not exist previously. #[allow(rustc::pass_by_value)] // closures take `&VnIndex` - fn insert(&mut self, ty: Ty<'tcx>, value: Value<'tcx>) -> (VnIndex, bool) { + fn insert(&mut self, ty: Ty<'tcx>, value: Value<'a, 'tcx>) -> (VnIndex, bool) { debug_assert!(match value { Value::Opaque(_) | Value::Address { .. } => false, Value::Constant { disambiguator, .. } => disambiguator.is_none(), @@ -319,8 +337,8 @@ impl<'tcx> ValueSet<'tcx> { /// Return the `Value` associated with the given `VnIndex`. #[inline] - fn value(&self, index: VnIndex) -> &Value<'tcx> { - &self.values[index] + fn value(&self, index: VnIndex) -> Value<'a, 'tcx> { + self.values[index] } /// Return the type associated with the given `VnIndex`. @@ -336,7 +354,7 @@ impl<'tcx> ValueSet<'tcx> { } } -struct VnState<'body, 'tcx> { +struct VnState<'body, 'a, 'tcx> { tcx: TyCtxt<'tcx>, ecx: InterpCx<'tcx, DummyMachine>, local_decls: &'body LocalDecls<'tcx>, @@ -346,7 +364,7 @@ struct VnState<'body, 'tcx> { /// Locals that are assigned that value. // This vector does not hold all the values of `VnIndex` that we create. rev_locals: IndexVec>, - values: ValueSet<'tcx>, + values: ValueSet<'a, 'tcx>, /// Values evaluated as constants if possible. evaluated: IndexVec>>, /// Cache the deref values. @@ -354,9 +372,10 @@ struct VnState<'body, 'tcx> { ssa: &'body SsaLocals, dominators: Dominators, reused_locals: DenseBitSet, + arena: &'a DroplessArena, } -impl<'body, 'tcx> VnState<'body, 'tcx> { +impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> { fn new( tcx: TyCtxt<'tcx>, body: &Body<'tcx>, @@ -364,6 +383,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { ssa: &'body SsaLocals, dominators: Dominators, local_decls: &'body LocalDecls<'tcx>, + arena: &'a DroplessArena, ) -> Self { // Compute a rough estimate of the number of values in the body from the number of // statements. This is meant to reduce the number of allocations, but it's all right if @@ -385,6 +405,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { ssa, dominators, reused_locals: DenseBitSet::new_empty(local_decls.len()), + arena, } } @@ -393,7 +414,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { } #[instrument(level = "trace", skip(self), ret)] - fn insert(&mut self, ty: Ty<'tcx>, value: Value<'tcx>) -> VnIndex { + fn insert(&mut self, ty: Ty<'tcx>, value: Value<'a, 'tcx>) -> VnIndex { let (index, new) = self.values.insert(ty, value); if new { // Grow `evaluated` and `rev_locals` here to amortize the allocations. @@ -420,7 +441,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { /// Create a new `Value::Address` distinct from all the others. #[instrument(level = "trace", skip(self), ret)] - fn new_pointer(&mut self, place: Place<'tcx>, kind: AddressKind) -> VnIndex { + fn new_pointer(&mut self, place: Place<'tcx>, kind: AddressKind) -> Option { let pty = place.ty(self.local_decls, self.tcx).ty; let ty = match kind { AddressKind::Ref(bk) => { @@ -428,14 +449,34 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { } AddressKind::Address(mutbl) => Ty::new_ptr(self.tcx, pty, mutbl.to_mutbl_lossy()), }; - let index = - self.values.insert_unique(ty, |provenance| Value::Address { place, kind, provenance }); + + let mut projection = place.projection.iter(); + let base = if place.is_indirect_first_projection() { + let base = self.locals[place.local]?; + // Skip the initial `Deref`. + projection.next(); + AddressBase::Deref(base) + } else { + AddressBase::Local(place.local) + }; + // Do not try evaluating inside `Index`, this has been done by `simplify_place_projection`. + let projection = + projection.map(|proj| proj.try_map(|index| self.locals[index], |ty| ty).ok_or(())); + let projection = self.arena.try_alloc_from_iter(projection).ok()?; + + let index = self.values.insert_unique(ty, |provenance| Value::Address { + base, + projection, + kind, + provenance, + }); let evaluated = self.eval_to_const(index); let _index = self.evaluated.push(evaluated); debug_assert_eq!(index, _index); let _index = self.rev_locals.push(SmallVec::new()); debug_assert_eq!(index, _index); - index + + Some(index) } #[instrument(level = "trace", skip(self), ret)] @@ -464,7 +505,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { } #[inline] - fn get(&self, index: VnIndex) -> &Value<'tcx> { + fn get(&self, index: VnIndex) -> Value<'a, 'tcx> { self.values.value(index) } @@ -495,8 +536,8 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { self.insert(ty, Value::Constant { value, disambiguator: None }) } - fn insert_tuple(&mut self, ty: Ty<'tcx>, values: Vec) -> VnIndex { - self.insert(ty, Value::Aggregate(VariantIdx::ZERO, values)) + fn insert_tuple(&mut self, ty: Ty<'tcx>, values: &[VnIndex]) -> VnIndex { + self.insert(ty, Value::Aggregate(VariantIdx::ZERO, self.arena.alloc_slice(values))) } fn insert_deref(&mut self, ty: Ty<'tcx>, value: VnIndex) -> VnIndex { @@ -521,7 +562,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { } else { return None; }; - let op = match *self.get(value) { + let op = match self.get(value) { _ if ty.is_zst() => ImmTy::uninit(ty).into(), Opaque(_) => return None, @@ -585,14 +626,15 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { let elem = elem.try_map(|_| None, |()| ty.ty)?; self.ecx.project(base, elem).discard_err()? } - Address { place, kind: _, provenance: _ } => { - if !place.is_indirect_first_projection() { - return None; - } - let local = self.locals[place.local]?; - let pointer = self.evaluated[local].as_ref()?; + Address { base, projection, .. } => { + debug_assert!(!projection.contains(&ProjectionElem::Deref)); + let pointer = match base { + AddressBase::Deref(pointer) => self.evaluated[pointer].as_ref()?, + // We have no stack to point to. + AddressBase::Local(_) => return None, + }; let mut mplace = self.ecx.deref_pointer(pointer).discard_err()?; - for elem in place.projection.iter().skip(1) { + for elem in projection { // `Index` by constants should have been replaced by `ConstantIndex` by // `simplify_place_projection`. let elem = elem.try_map(|_| None, |ty| ty)?; @@ -711,12 +753,38 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { Some(op) } + /// Represent the *value* we obtain by dereferencing an `Address` value. + #[instrument(level = "trace", skip(self), ret)] + fn dereference_address( + &mut self, + base: AddressBase, + projection: &[ProjectionElem>], + ) -> Option { + let (mut place_ty, mut value) = match base { + // The base is a local, so we take the local's value and project from it. + AddressBase::Local(local) => { + let local = self.locals[local]?; + let place_ty = PlaceTy::from_ty(self.ty(local)); + (place_ty, local) + } + // The base is a pointer's deref, so we introduce the implicit deref. + AddressBase::Deref(reborrow) => { + let place_ty = PlaceTy::from_ty(self.ty(reborrow)); + self.project(place_ty, reborrow, ProjectionElem::Deref)? + } + }; + for &proj in projection { + (place_ty, value) = self.project(place_ty, value, proj)?; + } + Some(value) + } + + #[instrument(level = "trace", skip(self), ret)] fn project( &mut self, place_ty: PlaceTy<'tcx>, value: VnIndex, - proj: PlaceElem<'tcx>, - from_non_ssa_index: &mut bool, + proj: ProjectionElem>, ) -> Option<(placety<'tcx>, VnIndex)> { let projection_ty = place_ty.projection_ty(self.tcx, proj); let proj = match proj { @@ -724,6 +792,12 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { if let Some(Mutability::Not) = place_ty.ty.ref_mutability() && projection_ty.ty.is_freeze(self.tcx, self.typing_env()) { + if let Value::Address { base, projection, .. } = self.get(value) + && let Some(value) = self.dereference_address(base, projection) + { + return Some((projection_ty, value)); + } + // An immutable borrow `_x` always points to the same value for the // lifetime of the borrow, so we can merge all instances of `*_x`. return Some((projection_ty, self.insert_deref(projection_ty.ty, value))); @@ -736,7 +810,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { if let Value::Aggregate(_, fields) = self.get(value) { return Some((projection_ty, fields[f.as_usize()])); } else if let Value::Projection(outer_value, ProjectionElem::Downcast(_, read_variant)) = self.get(value) - && let Value::Aggregate(written_variant, fields) = self.get(*outer_value) + && let Value::Aggregate(written_variant, fields) = self.get(outer_value) // This pass is not aware of control-flow, so we do not know whether the // replacement we are doing is actually reachable. We could be in any arm of // ``` @@ -760,16 +834,14 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { } ProjectionElem::Index(idx) => { if let Value::Repeat(inner, _) = self.get(value) { - *from_non_ssa_index |= self.locals[idx].is_none(); - return Some((projection_ty, *inner)); + return Some((projection_ty, inner)); } - let idx = self.locals[idx]?; ProjectionElem::Index(idx) } ProjectionElem::ConstantIndex { offset, min_length, from_end } => { match self.get(value) { Value::Repeat(inner, _) => { - return Some((projection_ty, *inner)); + return Some((projection_ty, inner)); } Value::Aggregate(_, operands) => { let offset = if from_end { @@ -797,10 +869,11 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { /// Simplify the projection chain if we know better. #[instrument(level = "trace", skip(self))] - fn simplify_place_projection(&mut self, place: &mut Place<'tcx>, location: Location) { + fn simplify_place_projection(&mut self, place: &mut Place<'tcx>, location: Option) { // If the projection is indirect, we treat the local as a value, so can replace it with // another local. - if place.is_indirect_first_projection() + if let Some(location) = location + && place.is_indirect_first_projection() && let Some(base) = self.locals[place.local] && let Some(new_local) = self.try_as_local(base, location) && place.local != new_local @@ -822,7 +895,8 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { { projection.to_mut()[i] = ProjectionElem::ConstantIndex { offset, min_length, from_end: false }; - } else if let Some(new_idx_local) = self.try_as_local(idx, location) + } else if let Some(location) = location + && let Some(new_idx_local) = self.try_as_local(idx, location) && idx_local != new_idx_local { projection.to_mut()[i] = ProjectionElem::Index(new_idx_local); @@ -838,77 +912,77 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { trace!(?place); } - /// Represent the *value* which would be read from `place`, and point `place` to a preexisting - /// place with the same value (if that already exists). + /// Represent the *value* which would be read from `place`. If we succeed, return it. + /// If we fail, return a `PlaceRef` that contains the same value. #[instrument(level = "trace", skip(self), ret)] - fn simplify_place_value( + fn compute_place_value( &mut self, - place: &mut Place<'tcx>, - location: Location, - ) -> Option { - self.simplify_place_projection(place, location); - + place: Place<'tcx>, + location: Option, + ) -> Result> { // Invariant: `place` and `place_ref` point to the same value, even if they point to // different memory locations. let mut place_ref = place.as_ref(); // Invariant: `value` holds the value up-to the `index`th projection excluded. - let mut value = self.locals[place.local]?; + let Some(mut value) = self.locals[place.local] else { return Err(place_ref) }; // Invariant: `value` has type `place_ty`, with optional downcast variant if needed. let mut place_ty = PlaceTy::from_ty(self.local_decls[place.local].ty); - let mut from_non_ssa_index = false; for (index, proj) in place.projection.iter().enumerate() { - if let Value::Projection(pointer, ProjectionElem::Deref) = *self.get(value) - && let Value::Address { place: mut pointee, kind, .. } = *self.get(pointer) - && let AddressKind::Ref(BorrowKind::Shared) = kind - && let Some(v) = self.simplify_place_value(&mut pointee, location) + if let Some(location) = location + && let Some(local) = self.try_as_local(value, location) { - value = v; - // `pointee` holds a `Place`, so `ProjectionElem::Index` holds a `Local`. - // That local is SSA, but we otherwise have no guarantee on that local's value at - // the current location compared to its value where `pointee` was borrowed. - if pointee.projection.iter().all(|elem| !matches!(elem, ProjectionElem::Index(_))) { - place_ref = - pointee.project_deeper(&place.projection[index..], self.tcx).as_ref(); - } - } - if let Some(local) = self.try_as_local(value, location) { // Both `local` and `Place { local: place.local, projection: projection[..index] }` // hold the same value. Therefore, following place holds the value in the original // `place`. place_ref = PlaceRef { local, projection: &place.projection[index..] }; } - (place_ty, value) = self.project(place_ty, value, proj, &mut from_non_ssa_index)?; + let Some(proj) = proj.try_map(|value| self.locals[value], |ty| ty) else { + return Err(place_ref); + }; + let Some(ty_and_value) = self.project(place_ty, value, proj) else { + return Err(place_ref); + }; + (place_ty, value) = ty_and_value; } - if let Value::Projection(pointer, ProjectionElem::Deref) = *self.get(value) - && let Value::Address { place: mut pointee, kind, .. } = *self.get(pointer) - && let AddressKind::Ref(BorrowKind::Shared) = kind - && let Some(v) = self.simplify_place_value(&mut pointee, location) - { - value = v; - // `pointee` holds a `Place`, so `ProjectionElem::Index` holds a `Local`. - // That local is SSA, but we otherwise have no guarantee on that local's value at - // the current location compared to its value where `pointee` was borrowed. - if pointee.projection.iter().all(|elem| !matches!(elem, ProjectionElem::Index(_))) { - place_ref = pointee.project_deeper(&[], self.tcx).as_ref(); - } - } - if let Some(new_local) = self.try_as_local(value, location) { - place_ref = PlaceRef { local: new_local, projection: &[] }; - } else if from_non_ssa_index { - // If access to non-SSA locals is unavoidable, bail out. - return None; - } + Ok(value) + } - if place_ref.local != place.local || place_ref.projection.len() < place.projection.len() { - // By the invariant on `place_ref`. - *place = place_ref.project_deeper(&[], self.tcx); - self.reused_locals.insert(place_ref.local); - } + /// Represent the *value* which would be read from `place`, and point `place` to a preexisting + /// place with the same value (if that already exists). + #[instrument(level = "trace", skip(self), ret)] + fn simplify_place_value( + &mut self, + place: &mut Place<'tcx>, + location: Option, + ) -> Option { + self.simplify_place_projection(place, location); - Some(value) + match self.compute_place_value(*place, location) { + Ok(value) => { + if let Some(location) = location + && let Some(new_place) = self.try_as_place(value, location, true) + && (new_place.local != place.local + || new_place.projection.len() < place.projection.len()) + { + *place = new_place; + self.reused_locals.insert(new_place.local); + } + Some(value) + } + Err(place_ref) => { + if place_ref.local != place.local + || place_ref.projection.len() < place.projection.len() + { + // By the invariant on `place_ref`. + *place = place_ref.project_deeper(&[], self.tcx); + self.reused_locals.insert(place_ref.local); + } + None + } + } } #[instrument(level = "trace", skip(self), ret)] @@ -917,16 +991,16 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { operand: &mut Operand<'tcx>, location: Location, ) -> Option { - match *operand { - Operand::Constant(ref constant) => Some(self.insert_constant(constant.const_)), + let value = match *operand { + Operand::Constant(ref constant) => self.insert_constant(constant.const_), Operand::Copy(ref mut place) | Operand::Move(ref mut place) => { - let value = self.simplify_place_value(place, location)?; - if let Some(const_) = self.try_as_constant(value) { - *operand = Operand::Constant(Box::new(const_)); - } - Some(value) + self.simplify_place_value(place, Some(location))? } + }; + if let Some(const_) = self.try_as_constant(value) { + *operand = Operand::Constant(Box::new(const_)); } + Some(value) } #[instrument(level = "trace", skip(self), ret)] @@ -954,12 +1028,12 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { Rvalue::NullaryOp(op, ty) => Value::NullaryOp(op, ty), Rvalue::Aggregate(..) => return self.simplify_aggregate(lhs, rvalue, location), Rvalue::Ref(_, borrow_kind, ref mut place) => { - self.simplify_place_projection(place, location); - return Some(self.new_pointer(*place, AddressKind::Ref(borrow_kind))); + self.simplify_place_projection(place, Some(location)); + return self.new_pointer(*place, AddressKind::Ref(borrow_kind)); } Rvalue::RawPtr(mutbl, ref mut place) => { - self.simplify_place_projection(place, location); - return Some(self.new_pointer(*place, AddressKind::Address(mutbl))); + self.simplify_place_projection(place, Some(location)); + return self.new_pointer(*place, AddressKind::Address(mutbl)); } Rvalue::WrapUnsafeBinder(ref mut op, _) => { let value = self.simplify_operand(op, location)?; @@ -977,7 +1051,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { return self.simplify_unary(op, arg_op, location); } Rvalue::Discriminant(ref mut place) => { - let place = self.simplify_place_value(place, location)?; + let place = self.simplify_place_value(place, Some(location))?; if let Some(discr) = self.simplify_discriminant(place) { return Some(discr); } @@ -994,7 +1068,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { fn simplify_discriminant(&mut self, place: VnIndex) -> Option { let enum_ty = self.ty(place); if enum_ty.is_enum() - && let Value::Aggregate(variant, _) = *self.get(place) + && let Value::Aggregate(variant, _) = self.get(place) { let discr = self.ecx.discriminant_for_variant(enum_ty, variant).discard_err()?; return Some(self.insert_scalar(discr.layout.ty, discr.to_scalar())); @@ -1026,11 +1100,11 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { fields: &[VnIndex], ) -> Option { let Some(&first_field) = fields.first() else { return None }; - let Value::Projection(copy_from_value, _) = *self.get(first_field) else { return None }; + let Value::Projection(copy_from_value, _) = self.get(first_field) else { return None }; // All fields must correspond one-to-one and come from the same aggregate value. if fields.iter().enumerate().any(|(index, &v)| { - if let Value::Projection(pointer, ProjectionElem::Field(from_index, _)) = *self.get(v) + if let Value::Projection(pointer, ProjectionElem::Field(from_index, _)) = self.get(v) && copy_from_value == pointer && from_index.index() == index { @@ -1042,7 +1116,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { } let mut copy_from_local_value = copy_from_value; - if let Value::Projection(pointer, proj) = *self.get(copy_from_value) + if let Value::Projection(pointer, proj) = self.get(copy_from_value) && let ProjectionElem::Downcast(_, read_variant) = proj { if variant_index == read_variant { @@ -1087,13 +1161,10 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { } } - let fields: Vec<_> = field_ops - .iter_mut() - .map(|op| { - self.simplify_operand(op, location) - .unwrap_or_else(|| self.new_opaque(op.ty(self.local_decls, self.tcx))) - }) - .collect(); + let fields = self.arena.alloc_from_iter(field_ops.iter_mut().map(|op| { + self.simplify_operand(op, location) + .unwrap_or_else(|| self.new_opaque(op.ty(self.local_decls, self.tcx))) + })); let variant_index = match *kind { AggregateKind::Array(..) | AggregateKind::Tuple => { @@ -1114,12 +1185,12 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { let mut was_updated = false; while let Value::Cast { kind: CastKind::PtrToPtr, value: cast_value } = self.get(pointer) - && let ty::RawPtr(from_pointee_ty, from_mtbl) = self.ty(*cast_value).kind() + && let ty::RawPtr(from_pointee_ty, from_mtbl) = self.ty(cast_value).kind() && let ty::RawPtr(_, output_mtbl) = ty.kind() && from_mtbl == output_mtbl && from_pointee_ty.is_sized(self.tcx, self.typing_env()) { - pointer = *cast_value; + pointer = cast_value; was_updated = true; } @@ -1184,16 +1255,16 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { // To allow things like `*mut (?A, ?T)` <-> `*mut (?B, ?T)`, // it's fine to get a projection as the type. Value::Cast { kind: CastKind::PtrToPtr, value: inner } - if self.pointers_have_same_metadata(self.ty(*inner), arg_ty) => + if self.pointers_have_same_metadata(self.ty(inner), arg_ty) => { - *inner + inner } // We have an unsizing cast, which assigns the length to wide pointer metadata. Value::Cast { kind: CastKind::PointerCoercion(ty::adjustment::PointerCoercion::Unsize, _), value: from, - } if let Some(from) = self.ty(*from).builtin_deref(true) + } if let Some(from) = self.ty(from).builtin_deref(true) && let ty::Array(_, len) = from.kind() && let Some(to) = self.ty(arg_index).builtin_deref(true) && let ty::Slice(..) = to.kind() => @@ -1202,12 +1273,10 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { } // `&mut *p`, `&raw *p`, etc don't change metadata. - Value::Address { place, kind: _, provenance: _ } - if let PlaceRef { local, projection: [PlaceElem::Deref] } = - place.as_ref() - && let Some(local_index) = self.locals[local] => + Value::Address { base: AddressBase::Deref(reborrowed), projection, .. } + if projection.is_empty() => { - local_index + reborrowed } _ => break, @@ -1221,15 +1290,15 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { } let value = match (op, self.get(arg_index)) { - (UnOp::Not, Value::UnaryOp(UnOp::Not, inner)) => return Some(*inner), - (UnOp::Neg, Value::UnaryOp(UnOp::Neg, inner)) => return Some(*inner), + (UnOp::Not, Value::UnaryOp(UnOp::Not, inner)) => return Some(inner), + (UnOp::Neg, Value::UnaryOp(UnOp::Neg, inner)) => return Some(inner), (UnOp::Not, Value::BinaryOp(BinOp::Eq, lhs, rhs)) => { - Value::BinaryOp(BinOp::Ne, *lhs, *rhs) + Value::BinaryOp(BinOp::Ne, lhs, rhs) } (UnOp::Not, Value::BinaryOp(BinOp::Ne, lhs, rhs)) => { - Value::BinaryOp(BinOp::Eq, *lhs, *rhs) + Value::BinaryOp(BinOp::Eq, lhs, rhs) } - (UnOp::PtrMetadata, Value::RawPtr { metadata, .. }) => return Some(*metadata), + (UnOp::PtrMetadata, Value::RawPtr { metadata, .. }) => return Some(metadata), // We have an unsizing cast, which assigns the length to wide pointer metadata. ( UnOp::PtrMetadata, @@ -1238,7 +1307,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { value: inner, }, ) if let ty::Slice(..) = arg_ty.builtin_deref(true).unwrap().kind() - && let ty::Array(_, len) = self.ty(*inner).builtin_deref(true).unwrap().kind() => + && let ty::Array(_, len) = self.ty(inner).builtin_deref(true).unwrap().kind() => { return Some(self.insert_constant(Const::Ty(self.tcx.types.usize, *len))); } @@ -1271,12 +1340,12 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { && lhs_ty.is_any_ptr() && let Value::Cast { kind: CastKind::PtrToPtr, value: lhs_value } = self.get(lhs) && let Value::Cast { kind: CastKind::PtrToPtr, value: rhs_value } = self.get(rhs) - && let lhs_from = self.ty(*lhs_value) - && lhs_from == self.ty(*rhs_value) + && let lhs_from = self.ty(lhs_value) + && lhs_from == self.ty(rhs_value) && self.pointers_have_same_metadata(lhs_from, lhs_ty) { - lhs = *lhs_value; - rhs = *rhs_value; + lhs = lhs_value; + rhs = rhs_value; if let Some(lhs_op) = self.try_as_operand(lhs, location) && let Some(rhs_op) = self.try_as_operand(rhs, location) { @@ -1410,7 +1479,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { if op.is_overflowing() { let ty = Ty::new_tup(self.tcx, &[self.ty(result), self.tcx.types.bool]); let false_val = self.insert_bool(false); - Some(self.insert_tuple(ty, vec![result, false_val])) + Some(self.insert_tuple(ty, &[result, false_val])) } else { Some(result) } @@ -1463,11 +1532,11 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { && let ty::RawPtr(to_pointee, _) = to.kind() && to_pointee.is_sized(self.tcx, self.typing_env()) { - from = self.ty(*pointer); - value = *pointer; + from = self.ty(pointer); + value = pointer; was_updated_this_iteration = true; if from == to { - return Some(*pointer); + return Some(pointer); } } @@ -1476,7 +1545,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { if let Transmute = kind && let Value::Aggregate(variant_idx, field_values) = self.get(value) && let Some((field_idx, field_ty)) = - self.value_is_all_in_one_field(from, *variant_idx) + self.value_is_all_in_one_field(from, variant_idx) { from = field_ty; value = field_values[field_idx.as_usize()]; @@ -1487,7 +1556,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { } // Various cast-then-cast cases can be simplified. - if let Value::Cast { kind: inner_kind, value: inner_value } = *self.get(value) { + if let Value::Cast { kind: inner_kind, value: inner_value } = self.get(value) { let inner_from = self.ty(inner_value); let new_kind = match (inner_kind, kind) { // Even if there's a narrowing cast in here that's fine, because @@ -1686,7 +1755,7 @@ fn op_to_prop_const<'tcx>( None } -impl<'tcx> VnState<'_, 'tcx> { +impl<'tcx> VnState<'_, '_, 'tcx> { /// If either [`Self::try_as_constant`] as [`Self::try_as_place`] succeeds, /// returns that result as an [`Operand`]. fn try_as_operand(&mut self, index: VnIndex, location: Location) -> Option> { @@ -1702,14 +1771,30 @@ impl<'tcx> VnState<'_, 'tcx> { /// If `index` is a `Value::Constant`, return the `Constant` to be put in the MIR. fn try_as_constant(&mut self, index: VnIndex) -> Option> { - // This was already constant in MIR, do not change it. If the constant is not - // deterministic, adding an additional mention of it in MIR will not give the same value as - // the former mention. - if let Value::Constant { value, disambiguator: None } = *self.get(index) { + let value = self.get(index); + + // This was already an *evaluated* constant in MIR, do not change it. + if let Value::Constant { value, disambiguator: None } = value + && let Const::Val(..) = value + { debug_assert!(value.is_deterministic()); return Some(ConstOperand { span: DUMMY_SP, user_ty: None, const_: value }); } + if let Some(value) = self.try_as_evaluated_constant(index) { + return Some(ConstOperand { span: DUMMY_SP, user_ty: None, const_: value }); + } + + // We failed to provide an evaluated form, fallback to using the unevaluated constant. + if let Value::Constant { value, disambiguator: None } = value { + debug_assert!(value.is_deterministic()); + return Some(ConstOperand { span: DUMMY_SP, user_ty: None, const_: value }); + } + + None + } + + fn try_as_evaluated_constant(&mut self, index: VnIndex) -> Option> { let op = self.evaluated[index].as_ref()?; if op.layout.is_unsized() { // Do not attempt to propagate unsized locals. @@ -1723,8 +1808,7 @@ impl<'tcx> VnState<'_, 'tcx> { // FIXME: remove this hack once https://github.com/rust-lang/rust/issues/79738 is fixed. assert!(!value.may_have_provenance(self.tcx, op.layout.size)); - let const_ = Const::Val(value, op.layout.ty); - Some(ConstOperand { span: DUMMY_SP, user_ty: None, const_ }) + Some(Const::Val(value, op.layout.ty)) } /// Construct a place which holds the same value as `index` and for which all locals strictly @@ -1749,7 +1833,7 @@ impl<'tcx> VnState<'_, 'tcx> { // If we are here, we failed to find a local, and we already have a `Deref`. // Trying to add projections will only result in an ill-formed place. return None; - } else if let Value::Projection(pointer, proj) = *self.get(index) + } else if let Value::Projection(pointer, proj) = self.get(index) && (allow_complex_projection || proj.is_stable_offset()) && let Some(proj) = self.try_as_place_elem(self.ty(index), proj, loc) { @@ -1772,13 +1856,26 @@ impl<'tcx> VnState<'_, 'tcx> { } } -impl<'tcx> MutVisitor<'tcx> for VnState<'_, 'tcx> { +impl<'tcx> MutVisitor<'tcx> for VnState<'_, '_, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } + fn visit_var_debug_info(&mut self, var_debug_info: &mut VarDebugInfo<'tcx>) { + match &mut var_debug_info.value { + VarDebugInfoContents::Const(_) => {} + VarDebugInfoContents::Place(place) => { + if let Some(value) = self.simplify_place_value(place, None) + && let Some(constant) = self.try_as_constant(value) + { + var_debug_info.value = VarDebugInfoContents::Const(constant); + } + } + } + } + fn visit_place(&mut self, place: &mut Place<'tcx>, context: PlaceContext, location: Location) { - self.simplify_place_projection(place, location); + self.simplify_place_projection(place, Some(location)); if context.is_mutating_use() && place.is_indirect() { // Non-local mutation maybe invalidate deref. self.invalidate_derefs(); @@ -1797,7 +1894,7 @@ impl<'tcx> MutVisitor<'tcx> for VnState<'_, 'tcx> { rvalue: &mut Rvalue<'tcx>, location: Location, ) { - self.simplify_place_projection(lhs, location); + self.simplify_place_projection(lhs, Some(location)); let value = self.simplify_rvalue(lhs, rvalue, location); if let Some(value) = value { diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 9ff7e0b550030..13e0f2916c215 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -191,7 +191,6 @@ declare_passes! { Final }; mod simplify_comparison_integral : SimplifyComparisonIntegral; - mod single_use_consts : SingleUseConsts; mod sroa : ScalarReplacementOfAggregates; mod strip_debuginfo : StripDebugInfo; mod unreachable_enum_branching : UnreachableEnumBranching; @@ -709,7 +708,6 @@ pub(crate) fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<' &simplify::SimplifyLocals::AfterGVN, &match_branches::MatchBranchSimplification, &dataflow_const_prop::DataflowConstProp, - &single_use_consts::SingleUseConsts, &o1(simplify_branches::SimplifyConstCondition::AfterConstProp), &jump_threading::JumpThreading, &early_otherwise_branch::EarlyOtherwiseBranch, diff --git a/compiler/rustc_mir_transform/src/single_use_consts.rs b/compiler/rustc_mir_transform/src/single_use_consts.rs deleted file mode 100644 index 02caa92ad3fc8..0000000000000 --- a/compiler/rustc_mir_transform/src/single_use_consts.rs +++ /dev/null @@ -1,205 +0,0 @@ -use rustc_index::IndexVec; -use rustc_index::bit_set::DenseBitSet; -use rustc_middle::bug; -use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor}; -use rustc_middle::mir::*; -use rustc_middle::ty::TyCtxt; - -/// Various parts of MIR building introduce temporaries that are commonly not needed. -/// -/// Notably, `if CONST` and `match CONST` end up being used-once temporaries, which -/// obfuscates the structure for other passes and codegen, which would like to always -/// be able to just see the constant directly. -/// -/// At higher optimization levels fancier passes like GVN will take care of this -/// in a more general fashion, but this handles the easy cases so can run in debug. -/// -/// This only removes constants with a single-use because re-evaluating constants -/// isn't always an improvement, especially for large ones. -/// -/// It also removes *never*-used constants, since it had all the information -/// needed to do that too, including updating the debug info. -pub(super) struct SingleUseConsts; - -impl<'tcx> crate::MirPass<'tcx> for SingleUseConsts { - fn is_enabled(&self, sess: &rustc_session::Session) -> bool { - sess.mir_opt_level()> 0 - } - - fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { - let mut finder = SingleUseConstsFinder { - ineligible_locals: DenseBitSet::new_empty(body.local_decls.len()), - locations: IndexVec::from_elem(LocationPair::new(), &body.local_decls), - locals_in_debug_info: DenseBitSet::new_empty(body.local_decls.len()), - }; - - finder.ineligible_locals.insert_range(..=Local::from_usize(body.arg_count)); - - finder.visit_body(body); - - for (local, locations) in finder.locations.iter_enumerated() { - if finder.ineligible_locals.contains(local) { - continue; - } - - let Some(init_loc) = locations.init_loc else { - continue; - }; - - // We're only changing an operand, not the terminator kinds or successors - let basic_blocks = body.basic_blocks.as_mut_preserves_cfg(); - let init_statement_kind = std::mem::replace( - &mut basic_blocks[init_loc.block].statements[init_loc.statement_index].kind, - StatementKind::Nop, - ); - let StatementKind::Assign(place_and_rvalue) = init_statement_kind else { - bug!("No longer an assign?"); - }; - let (place, rvalue) = *place_and_rvalue; - assert_eq!(place.as_local(), Some(local)); - let Rvalue::Use(operand) = rvalue else { bug!("No longer a use?") }; - - let mut replacer = LocalReplacer { tcx, local, operand: Some(operand) }; - - if finder.locals_in_debug_info.contains(local) { - for var_debug_info in &mut body.var_debug_info { - replacer.visit_var_debug_info(var_debug_info); - } - } - - let Some(use_loc) = locations.use_loc else { continue }; - - let use_block = &mut basic_blocks[use_loc.block]; - if let Some(use_statement) = use_block.statements.get_mut(use_loc.statement_index) { - replacer.visit_statement(use_statement, use_loc); - } else { - replacer.visit_terminator(use_block.terminator_mut(), use_loc); - } - - if replacer.operand.is_some() { - bug!( - "operand wasn't used replacing local {local:?} with locations {locations:?} in body {body:#?}" - ); - } - } - } - - fn is_required(&self) -> bool { - true - } -} - -#[derive(Copy, Clone, Debug)] -struct LocationPair { - init_loc: Option, - use_loc: Option, -} - -impl LocationPair { - fn new() -> Self { - Self { init_loc: None, use_loc: None } - } -} - -struct SingleUseConstsFinder { - ineligible_locals: DenseBitSet, - locations: IndexVec, - locals_in_debug_info: DenseBitSet, -} - -impl<'tcx> Visitor<'tcx> for SingleUseConstsFinder { - fn visit_assign(&mut self, place: &Place<'tcx>, rvalue: &Rvalue<'tcx>, location: Location) { - if let Some(local) = place.as_local() - && let Rvalue::Use(operand) = rvalue - && let Operand::Constant(_) = operand - { - let locations = &mut self.locations[local]; - if locations.init_loc.is_some() { - self.ineligible_locals.insert(local); - } else { - locations.init_loc = Some(location); - } - } else { - self.super_assign(place, rvalue, location); - } - } - - fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) { - if let Some(place) = operand.place() - && let Some(local) = place.as_local() - { - let locations = &mut self.locations[local]; - if locations.use_loc.is_some() { - self.ineligible_locals.insert(local); - } else { - locations.use_loc = Some(location); - } - } else { - self.super_operand(operand, location); - } - } - - fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) { - match &statement.kind { - // Storage markers are irrelevant to this. - StatementKind::StorageLive(_) | StatementKind::StorageDead(_) => {} - _ => self.super_statement(statement, location), - } - } - - fn visit_var_debug_info(&mut self, var_debug_info: &VarDebugInfo<'tcx>) { - if let VarDebugInfoContents::Place(place) = &var_debug_info.value - && let Some(local) = place.as_local() - { - self.locals_in_debug_info.insert(local); - } else { - self.super_var_debug_info(var_debug_info); - } - } - - fn visit_local(&mut self, local: Local, _context: PlaceContext, _location: Location) { - // If there's any path that gets here, rather than being understood elsewhere, - // then we'd better not do anything with this local. - self.ineligible_locals.insert(local); - } -} - -struct LocalReplacer<'tcx> { - tcx: TyCtxt<'tcx>, - local: Local, - operand: Option>, -} - -impl<'tcx> MutVisitor<'tcx> for LocalReplacer<'tcx> { - fn tcx(&self) -> TyCtxt<'tcx> { - self.tcx - } - - fn visit_operand(&mut self, operand: &mut Operand<'tcx>, _location: Location) { - if let Operand::Copy(place) | Operand::Move(place) = operand - && let Some(local) = place.as_local() - && local == self.local - { - *operand = self.operand.take().unwrap_or_else(|| { - bug!("there was a second use of the operand"); - }); - } - } - - fn visit_var_debug_info(&mut self, var_debug_info: &mut VarDebugInfo<'tcx>) { - if let VarDebugInfoContents::Place(place) = &var_debug_info.value - && let Some(local) = place.as_local() - && local == self.local - { - let const_op = *self - .operand - .as_ref() - .unwrap_or_else(|| { - bug!("the operand was already stolen"); - }) - .constant() - .unwrap(); - var_debug_info.value = VarDebugInfoContents::Const(const_op); - } - } -} diff --git a/tests/codegen-llvm/amdgpu-addrspacecast.rs b/tests/codegen-llvm/amdgpu-addrspacecast.rs index 829133de00d8b..2b895cf256d6d 100644 --- a/tests/codegen-llvm/amdgpu-addrspacecast.rs +++ b/tests/codegen-llvm/amdgpu-addrspacecast.rs @@ -10,7 +10,7 @@ extern crate minicore; // CHECK-LABEL: @ref_of_local // CHECK: [[alloca:%[0-9]]] = alloca -// CHECK: %i = addrspacecast ptr addrspace(5) [[alloca]] to ptr +// CHECK: {{%.*}} = addrspacecast ptr addrspace(5) [[alloca]] to ptr #[no_mangle] pub fn ref_of_local(f: fn(&i32)) { let i = 0; diff --git a/tests/incremental/hashes/enum_constructors.rs b/tests/incremental/hashes/enum_constructors.rs index d839dabf293af..4bcf546107c87 100644 --- a/tests/incremental/hashes/enum_constructors.rs +++ b/tests/incremental/hashes/enum_constructors.rs @@ -64,7 +64,7 @@ pub fn change_field_order_struct_like() -> Enum { #[cfg(not(any(cfail1,cfail4)))] #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck,optimized_mir")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail6")] // FIXME(michaelwoerister):Interesting. I would have thought that that changes the MIR. And it // would if it were not all constants diff --git a/tests/incremental/hashes/struct_constructors.rs b/tests/incremental/hashes/struct_constructors.rs index 31c549c6e7a90..648bd82e02d14 100644 --- a/tests/incremental/hashes/struct_constructors.rs +++ b/tests/incremental/hashes/struct_constructors.rs @@ -61,7 +61,7 @@ pub fn change_field_order_regular_struct() -> RegularStruct { #[cfg(not(any(cfail1,cfail4)))] #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck,optimized_mir")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail6")] pub fn change_field_order_regular_struct() -> RegularStruct { RegularStruct { diff --git a/tests/mir-opt/building/match/sort_candidates.rs b/tests/mir-opt/building/match/sort_candidates.rs index d7dd82791ffa1..da8bf48084c12 100644 --- a/tests/mir-opt/building/match/sort_candidates.rs +++ b/tests/mir-opt/building/match/sort_candidates.rs @@ -1,4 +1,5 @@ -// Check specific cases of sorting candidates in match lowering. +//! Check specific cases of sorting candidates in match lowering. +//@ compile-flags: -Zmir-opt-level=0 // EMIT_MIR sort_candidates.constant_eq.SimplifyCfg-initial.after.mir fn constant_eq(s: &str, b: bool) -> u32 { @@ -6,7 +7,7 @@ fn constant_eq(s: &str, b: bool) -> u32 { // CHECK-LABEL: fn constant_eq( // CHECK-NOT: const "a" - // CHECK: {{_[0-9]+}} = const "a" as &[u8] (Transmute); + // CHECK: eq({{.*}}, const "a") // CHECK-NOT: const "a" match (s, b) { ("a", _) if true => 1, @@ -23,11 +24,16 @@ fn disjoint_ranges(x: i32, b: bool) -> u32 { // other candidates. // CHECK-LABEL: fn disjoint_ranges( - // CHECK: debug b => _2; - // CHECK: bb0: { - // CHECK: switchInt(copy _2) -> [0: [[jump:bb.*]], otherwise: {{bb.*}}]; + // CHECK: debug b => [[b:_.*]]; + // CHECK: [[tmp:_.*]] = copy [[b]]; + // CHECK-NEXT: switchInt(move [[tmp]]) -> [0: [[jump:bb.*]], otherwise: {{bb.*}}]; // CHECK: [[jump]]: { + // CHECK-NEXT: StorageDead([[tmp]]); + // CHECK-NEXT: goto -> [[jump3:bb.*]]; + // CHECK: [[jump3]]: { // CHECK-NEXT: _0 = const 3_u32; + // CHECK-NEXT: goto -> [[jumpret:bb.*]]; + // CHECK: [[jumpret]]: { // CHECK-NEXT: return; match x { 0..10 if b => 0, diff --git a/tests/mir-opt/const_debuginfo.main.SingleUseConsts.diff b/tests/mir-opt/const_debuginfo.main.GVN.diff similarity index 68% rename from tests/mir-opt/const_debuginfo.main.SingleUseConsts.diff rename to tests/mir-opt/const_debuginfo.main.GVN.diff index 9baf8439e59f5..9f37626a7fbf0 100644 --- a/tests/mir-opt/const_debuginfo.main.SingleUseConsts.diff +++ b/tests/mir-opt/const_debuginfo.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before SingleUseConsts -+ // MIR for `main` after SingleUseConsts +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -55,56 +55,57 @@ } bb0: { - nop; -- _1 = const 1_u8; - nop; -- _2 = const 2_u8; - nop; -- _3 = const 3_u8; +- StorageLive(_1); + nop; + _1 = const 1_u8; +- StorageLive(_2); + nop; + _2 = const 2_u8; +- StorageLive(_3); + nop; + _3 = const 3_u8; StorageLive(_4); StorageLive(_5); StorageLive(_6); -- _6 = const 1_u8; -+ nop; +- _6 = copy _1; ++ _6 = const 1_u8; StorageLive(_7); -- _7 = const 2_u8; -- _5 = const 3_u8; -+ nop; -+ nop; +- _7 = copy _2; +- _5 = Add(move _6, move _7); ++ _7 = const 2_u8; ++ _5 = const 3_u8; StorageDead(_7); StorageDead(_6); StorageLive(_8); -- _8 = const 3_u8; -- _4 = const 6_u8; -+ nop; -+ nop; +- _8 = copy _3; +- _4 = Add(move _5, move _8); ++ _8 = const 3_u8; ++ _4 = const 6_u8; StorageDead(_8); StorageDead(_5); StorageLive(_9); -- _9 = const "hello, world!"; -+ nop; + _9 = const "hello, world!"; StorageLive(_10); _10 = (const true, const false, const 123_u32); StorageLive(_11); -- _11 = const Option::::Some(99_u16); -+ nop; +- _11 = Option::::Some(const 99_u16); ++ _11 = const Option::::Some(99_u16); StorageLive(_12); -- _12 = const Point {{ x: 32_u32, y: 32_u32 }}; -+ nop; +- _12 = Point { x: const 32_u32, y: const 32_u32 }; ++ _12 = const Point {{ x: 32_u32, y: 32_u32 }}; StorageLive(_13); - nop; -- _14 = const 32_u32; +- StorageLive(_14); +- _14 = copy (_12.0: u32); + nop; ++ _14 = const 32_u32; StorageLive(_15); -- _15 = const 32_u32; -- _13 = const 64_u32; -+ nop; -+ nop; +- _15 = copy (_12.1: u32); +- _13 = Add(move _14, move _15); ++ _15 = const 32_u32; ++ _13 = const 64_u32; StorageDead(_15); - nop; +- StorageDead(_14); ++ nop; _0 = const (); StorageDead(_13); StorageDead(_12); @@ -112,16 +113,20 @@ StorageDead(_10); StorageDead(_9); StorageDead(_4); - nop; - nop; - nop; +- StorageDead(_3); +- StorageDead(_2); +- StorageDead(_1); ++ nop; ++ nop; ++ nop; return; } } - ALLOC0 (size: 8, align: 4) { .. } - - ALLOC1 (size: 4, align: 2) { .. } - - ALLOC2 (size: 13, align: 1) { .. } +- ALLOC0 (size: 13, align: 1) { .. } ++ ALLOC0 (size: 8, align: 4) { .. } ++ ++ ALLOC1 (size: 4, align: 2) { .. } ++ ++ ALLOC2 (size: 13, align: 1) { .. } diff --git a/tests/mir-opt/const_debuginfo.rs b/tests/mir-opt/const_debuginfo.rs index 3b2bc4559ced9..c286786682410 100644 --- a/tests/mir-opt/const_debuginfo.rs +++ b/tests/mir-opt/const_debuginfo.rs @@ -1,4 +1,4 @@ -//@ test-mir-pass: SingleUseConsts +//@ test-mir-pass: GVN //@ compile-flags: -C overflow-checks=no -Zmir-enable-passes=+GVN -Zdump-mir-exclude-alloc-bytes #![allow(unused)] @@ -8,7 +8,7 @@ struct Point { y: u32, } -// EMIT_MIR const_debuginfo.main.SingleUseConsts.diff +// EMIT_MIR const_debuginfo.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => const 1_u8; diff --git a/tests/mir-opt/const_prop/aggregate.foo.GVN.panic-abort.diff b/tests/mir-opt/const_prop/aggregate.foo.GVN.panic-abort.diff index c6d3bad0790c4..1cfb63d9ee774 100644 --- a/tests/mir-opt/const_prop/aggregate.foo.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/aggregate.foo.GVN.panic-abort.diff @@ -12,10 +12,12 @@ let mut _8: (u8, i32); let mut _9: u8; scope 1 { - debug first => _2; +- debug first => _2; ++ debug first => const 1_i32; let _6: i32; scope 2 { - debug second => _6; +- debug second => _6; ++ debug second => const 3_i32; } } diff --git a/tests/mir-opt/const_prop/aggregate.foo.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/aggregate.foo.GVN.panic-unwind.diff index c6d3bad0790c4..1cfb63d9ee774 100644 --- a/tests/mir-opt/const_prop/aggregate.foo.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/aggregate.foo.GVN.panic-unwind.diff @@ -12,10 +12,12 @@ let mut _8: (u8, i32); let mut _9: u8; scope 1 { - debug first => _2; +- debug first => _2; ++ debug first => const 1_i32; let _6: i32; scope 2 { - debug second => _6; +- debug second => _6; ++ debug second => const 3_i32; } } diff --git a/tests/mir-opt/const_prop/aggregate.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/aggregate.main.GVN.panic-abort.diff index 0a59c59c2ed2c..769c07ab468cb 100644 --- a/tests/mir-opt/const_prop/aggregate.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/aggregate.main.GVN.panic-abort.diff @@ -9,7 +9,8 @@ let _4: (); let mut _5: u8; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 1_u8; } bb0: { diff --git a/tests/mir-opt/const_prop/aggregate.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/aggregate.main.GVN.panic-unwind.diff index 100369a2eee31..5d4a6a2296387 100644 --- a/tests/mir-opt/const_prop/aggregate.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/aggregate.main.GVN.panic-unwind.diff @@ -9,7 +9,8 @@ let _4: (); let mut _5: u8; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 1_u8; } bb0: { diff --git a/tests/mir-opt/const_prop/aggregate.rs b/tests/mir-opt/const_prop/aggregate.rs index 8f8f92bbba19b..cf020371af820 100644 --- a/tests/mir-opt/const_prop/aggregate.rs +++ b/tests/mir-opt/const_prop/aggregate.rs @@ -5,9 +5,7 @@ // EMIT_MIR aggregate.main.GVN.diff fn main() { // CHECK-LABEL: fn main( - // CHECK: debug x => [[x:_.*]]; - // CHECK-NOT: = Add( - // CHECK: [[x]] = const 1_u8; + // CHECK: debug x => const 1_u8; // CHECK-NOT: = Add( // CHECK: foo(const 1_u8) let x = (0, 1, 2).1 + 0; @@ -18,12 +16,9 @@ fn main() { // EMIT_MIR aggregate.foo.GVN.diff fn foo(x: u8) { // CHECK-LABEL: fn foo( - // CHECK: debug first => [[first:_.*]]; - // CHECK: debug second => [[second:_.*]]; - // CHECK-NOT: = Add( - // CHECK: [[first]] = const 1_i32; + // CHECK: debug first => const 1_i32; + // CHECK: debug second => const 3_i32; // CHECK-NOT: = Add( - // CHECK: [[second]] = const 3_i32; let first = (0, x).0 + 1; let second = (x, 1).1 + 2; } diff --git a/tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-abort.diff index 3a5a8d0099128..2888c9265d193 100644 --- a/tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-abort.diff @@ -8,7 +8,8 @@ let _3: usize; let mut _4: bool; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 2_u32; } bb0: { diff --git a/tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-unwind.diff index 62d6e6007e5c9..91626ffd34cb0 100644 --- a/tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-unwind.diff @@ -8,7 +8,8 @@ let _3: usize; let mut _4: bool; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 2_u32; } bb0: { diff --git a/tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-abort.diff index 3a5a8d0099128..2888c9265d193 100644 --- a/tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-abort.diff @@ -8,7 +8,8 @@ let _3: usize; let mut _4: bool; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 2_u32; } bb0: { diff --git a/tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-unwind.diff index 62d6e6007e5c9..91626ffd34cb0 100644 --- a/tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-unwind.diff @@ -8,7 +8,8 @@ let _3: usize; let mut _4: bool; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 2_u32; } bb0: { diff --git a/tests/mir-opt/const_prop/array_index.rs b/tests/mir-opt/const_prop/array_index.rs index aff72268223b2..ee8056e51e974 100644 --- a/tests/mir-opt/const_prop/array_index.rs +++ b/tests/mir-opt/const_prop/array_index.rs @@ -5,7 +5,6 @@ // EMIT_MIR array_index.main.GVN.diff fn main() { // CHECK-LABEL: fn main( - // CHECK: debug x => [[x:_.*]]; - // CHECK: [[x]] = const 2_u32; + // CHECK: debug x => const 2_u32; let x: u32 = [0, 1, 2, 3][2]; } diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-abort.diff index 8c535b567c328..8a8b9fbf6145e 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-abort.diff @@ -10,7 +10,8 @@ let mut _6: bool; let mut _7: bool; scope 1 { - debug y => _1; +- debug y => _1; ++ debug y => const 0_i32; let _2: i32; scope 2 { debug _z => _2; diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-unwind.diff index 045f4d81db62e..e3deaa278e3b3 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-unwind.diff @@ -10,7 +10,8 @@ let mut _6: bool; let mut _7: bool; scope 1 { - debug y => _1; +- debug y => _1; ++ debug y => const 0_i32; let _2: i32; scope 2 { debug _z => _2; diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.rs b/tests/mir-opt/const_prop/bad_op_div_by_zero.rs index 6c576718ac878..951ed51fcd53b 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.rs +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.rs @@ -5,7 +5,7 @@ #[allow(unconditional_panic)] fn main() { // CHECK-LABEL: fn main( - // CHECK: debug y => [[y:_.*]]; + // CHECK: debug y => const 0_i32; // CHECK: debug _z => [[z:_.*]]; // CHECK: assert(!const true, "attempt to divide `{}` by zero", const 1_i32) // CHECK: assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, const 0_i32) diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-abort.diff index e5a8726b855c4..ebbd3d58365ad 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-abort.diff @@ -10,7 +10,8 @@ let mut _6: bool; let mut _7: bool; scope 1 { - debug y => _1; +- debug y => _1; ++ debug y => const 0_i32; let _2: i32; scope 2 { debug _z => _2; diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-unwind.diff index 1110ff186dc6e..188cd422de352 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-unwind.diff @@ -10,7 +10,8 @@ let mut _6: bool; let mut _7: bool; scope 1 { - debug y => _1; +- debug y => _1; ++ debug y => const 0_i32; let _2: i32; scope 2 { debug _z => _2; diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs index b7623dc23da1b..fc47aaea5fe60 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs @@ -5,7 +5,7 @@ #[allow(unconditional_panic)] fn main() { // CHECK-LABEL: fn main( - // CHECK: debug y => [[y:_.*]]; + // CHECK: debug y => const 0_i32; // CHECK: debug _z => [[z:_.*]]; // CHECK: assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of // zero", const 1_i32) diff --git a/tests/mir-opt/const_prop/boolean_identities.rs b/tests/mir-opt/const_prop/boolean_identities.rs index f23749312f232..5915986b9f74d 100644 --- a/tests/mir-opt/const_prop/boolean_identities.rs +++ b/tests/mir-opt/const_prop/boolean_identities.rs @@ -3,10 +3,8 @@ // EMIT_MIR boolean_identities.test.GVN.diff pub fn test(x: bool, y: bool) -> bool { // CHECK-LABEL: fn test( - // CHECK: debug a => [[a:_.*]]; - // CHECK: debug b => [[b:_.*]]; - // CHECK: [[a]] = const true; - // CHECK: [[b]] = const false; + // CHECK: debug a => const true; + // CHECK: debug b => const false; // CHECK: _0 = const false; let a = (y | true); let b = (x & false); diff --git a/tests/mir-opt/const_prop/boolean_identities.test.GVN.diff b/tests/mir-opt/const_prop/boolean_identities.test.GVN.diff index 3fe70302b21cf..f65ecdcbc599e 100644 --- a/tests/mir-opt/const_prop/boolean_identities.test.GVN.diff +++ b/tests/mir-opt/const_prop/boolean_identities.test.GVN.diff @@ -11,10 +11,12 @@ let mut _7: bool; let mut _8: bool; scope 1 { - debug a => _3; +- debug a => _3; ++ debug a => const true; let _5: bool; scope 2 { - debug b => _5; +- debug b => _5; ++ debug b => const false; } } diff --git a/tests/mir-opt/const_prop/cast.main.GVN.diff b/tests/mir-opt/const_prop/cast.main.GVN.diff index bc442c4e4468b..c4a84e1733bc5 100644 --- a/tests/mir-opt/const_prop/cast.main.GVN.diff +++ b/tests/mir-opt/const_prop/cast.main.GVN.diff @@ -5,10 +5,12 @@ let mut _0: (); let _1: u32; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 42_u32; let _2: u8; scope 2 { - debug y => _2; +- debug y => _2; ++ debug y => const 42_u8; } } diff --git a/tests/mir-opt/const_prop/cast.rs b/tests/mir-opt/const_prop/cast.rs index dce2e38fa9173..39027ce8ef065 100644 --- a/tests/mir-opt/const_prop/cast.rs +++ b/tests/mir-opt/const_prop/cast.rs @@ -3,10 +3,8 @@ fn main() { // CHECK-LABEL: fn main( - // CHECK: debug x => [[x:_.*]]; - // CHECK: debug y => [[y:_.*]]; - // CHECK: [[x]] = const 42_u32; - // CHECK: [[y]] = const 42_u8; + // CHECK: debug x => const 42_u32; + // CHECK: debug y => const 42_u8; let x = 42u8 as u32; let y = 42u32 as u8; } diff --git a/tests/mir-opt/const_prop/checked_add.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/checked_add.main.GVN.panic-abort.diff index 798f957caa58c..8714ef45ea240 100644 --- a/tests/mir-opt/const_prop/checked_add.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/checked_add.main.GVN.panic-abort.diff @@ -6,7 +6,8 @@ let _1: u32; let mut _2: (u32, bool); scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 2_u32; } bb0: { diff --git a/tests/mir-opt/const_prop/checked_add.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/checked_add.main.GVN.panic-unwind.diff index a09f8ee5be12a..5cefd83e06c04 100644 --- a/tests/mir-opt/const_prop/checked_add.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/checked_add.main.GVN.panic-unwind.diff @@ -6,7 +6,8 @@ let _1: u32; let mut _2: (u32, bool); scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 2_u32; } bb0: { diff --git a/tests/mir-opt/const_prop/checked_add.rs b/tests/mir-opt/const_prop/checked_add.rs index d450f7d03f38c..7e747b1686fe5 100644 --- a/tests/mir-opt/const_prop/checked_add.rs +++ b/tests/mir-opt/const_prop/checked_add.rs @@ -5,8 +5,7 @@ // EMIT_MIR checked_add.main.GVN.diff fn main() { // CHECK-LABEL: fn main( - // CHECK: debug x => [[x:_.*]]; + // CHECK: debug x => const 2_u32; // CHECK: assert(!const false, - // CHECK: [[x]] = const 2_u32; let x: u32 = 1 + 1; } diff --git a/tests/mir-opt/const_prop/indirect.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/indirect.main.GVN.panic-abort.diff index 208845942c76d..a4cc65a91ac4d 100644 --- a/tests/mir-opt/const_prop/indirect.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/indirect.main.GVN.panic-abort.diff @@ -7,7 +7,8 @@ let mut _2: u8; let mut _3: (u8, bool); scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 3_u8; } bb0: { diff --git a/tests/mir-opt/const_prop/indirect.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/indirect.main.GVN.panic-unwind.diff index 4a7c69bae3ca8..ef2c274aa73f9 100644 --- a/tests/mir-opt/const_prop/indirect.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/indirect.main.GVN.panic-unwind.diff @@ -7,7 +7,8 @@ let mut _2: u8; let mut _3: (u8, bool); scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 3_u8; } bb0: { diff --git a/tests/mir-opt/const_prop/indirect.rs b/tests/mir-opt/const_prop/indirect.rs index ca53e2b2f2b00..a2ee5be16d285 100644 --- a/tests/mir-opt/const_prop/indirect.rs +++ b/tests/mir-opt/const_prop/indirect.rs @@ -5,7 +5,6 @@ // EMIT_MIR indirect.main.GVN.diff fn main() { // CHECK-LABEL: fn main( - // CHECK: debug x => [[x:_.*]]; - // CHECK: [[x]] = const 3_u8; + // CHECK: debug x => const 3_u8; let x = (2u32 as u8) + 1; } diff --git a/tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-abort.diff index 3569998b13fa5..939610ffe0703 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-abort.diff @@ -8,7 +8,8 @@ let _3: usize; let mut _4: bool; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 0_u8; } bb0: { diff --git a/tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-unwind.diff index 50b31c9ac136c..f520b7fc19613 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-unwind.diff @@ -8,7 +8,8 @@ let _3: usize; let mut _4: bool; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 0_u8; } bb0: { diff --git a/tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-abort.diff index 3569998b13fa5..939610ffe0703 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-abort.diff @@ -8,7 +8,8 @@ let _3: usize; let mut _4: bool; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 0_u8; } bb0: { diff --git a/tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-unwind.diff index 50b31c9ac136c..f520b7fc19613 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-unwind.diff @@ -8,7 +8,8 @@ let _3: usize; let mut _4: bool; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 0_u8; } bb0: { diff --git a/tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-abort.diff b/tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-abort.diff index 77a2c5bcccc72..9b352c39037aa 100644 --- a/tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-abort.diff @@ -5,25 +5,32 @@ let mut _0: (); let _1: usize; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 4_usize; let _2: usize; scope 2 { - debug y => _2; +- debug y => _2; ++ debug y => const 0_usize; let _3: usize; scope 3 { - debug z0 => _3; +- debug z0 => _3; ++ debug z0 => const 2_usize; let _4: usize; scope 4 { - debug z1 => _4; +- debug z1 => _4; ++ debug z1 => const 3_usize; let _5: usize; scope 5 { - debug eA0 => _5; +- debug eA0 => _5; ++ debug eA0 => const 1_usize; let _6: usize; scope 6 { - debug eA1 => _6; +- debug eA1 => _6; ++ debug eA1 => const 2_usize; let _7: usize; scope 7 { - debug eC => _7; +- debug eC => _7; ++ debug eC => const 4_usize; } } } diff --git a/tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-unwind.diff index 77a2c5bcccc72..9b352c39037aa 100644 --- a/tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-unwind.diff @@ -5,25 +5,32 @@ let mut _0: (); let _1: usize; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 4_usize; let _2: usize; scope 2 { - debug y => _2; +- debug y => _2; ++ debug y => const 0_usize; let _3: usize; scope 3 { - debug z0 => _3; +- debug z0 => _3; ++ debug z0 => const 2_usize; let _4: usize; scope 4 { - debug z1 => _4; +- debug z1 => _4; ++ debug z1 => const 3_usize; let _5: usize; scope 5 { - debug eA0 => _5; +- debug eA0 => _5; ++ debug eA0 => const 1_usize; let _6: usize; scope 6 { - debug eA1 => _6; +- debug eA1 => _6; ++ debug eA1 => const 2_usize; let _7: usize; scope 7 { - debug eC => _7; +- debug eC => _7; ++ debug eC => const 4_usize; } } } diff --git a/tests/mir-opt/const_prop/offset_of.generic.GVN.panic-abort.diff b/tests/mir-opt/const_prop/offset_of.generic.GVN.panic-abort.diff index 130c31eff8ccc..b67c3c41d67e0 100644 --- a/tests/mir-opt/const_prop/offset_of.generic.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/offset_of.generic.GVN.panic-abort.diff @@ -11,10 +11,12 @@ debug gy => _2; let _3: usize; scope 3 { - debug dx => _3; +- debug dx => _3; ++ debug dx => const 0_usize; let _4: usize; scope 4 { - debug dy => _4; +- debug dy => _4; ++ debug dy => const 2_usize; let _5: usize; scope 5 { debug zA0 => _5; diff --git a/tests/mir-opt/const_prop/offset_of.generic.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/offset_of.generic.GVN.panic-unwind.diff index 130c31eff8ccc..b67c3c41d67e0 100644 --- a/tests/mir-opt/const_prop/offset_of.generic.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/offset_of.generic.GVN.panic-unwind.diff @@ -11,10 +11,12 @@ debug gy => _2; let _3: usize; scope 3 { - debug dx => _3; +- debug dx => _3; ++ debug dx => const 0_usize; let _4: usize; scope 4 { - debug dy => _4; +- debug dy => _4; ++ debug dy => const 2_usize; let _5: usize; scope 5 { debug zA0 => _5; diff --git a/tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff b/tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff index 8df262b351f12..1dffd99b5a62e 100644 --- a/tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff +++ b/tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff @@ -9,7 +9,8 @@ let mut _4: u8; let mut _5: &u8; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 4_u8; } bb0: { diff --git a/tests/mir-opt/const_prop/read_immutable_static.rs b/tests/mir-opt/const_prop/read_immutable_static.rs index 05fec2f3303b0..e030b09937c24 100644 --- a/tests/mir-opt/const_prop/read_immutable_static.rs +++ b/tests/mir-opt/const_prop/read_immutable_static.rs @@ -5,7 +5,6 @@ static FOO: u8 = 2; // EMIT_MIR read_immutable_static.main.GVN.diff fn main() { // CHECK-LABEL: fn main( - // CHECK: debug x => [[x:_.*]]; - // CHECK: [[x]] = const 4_u8; + // CHECK: debug x => const 4_u8; let x = FOO + FOO; } diff --git a/tests/mir-opt/const_prop/ref_deref.main.GVN.diff b/tests/mir-opt/const_prop/ref_deref.main.GVN.diff index b9e269266b0b1..a52b50042dd06 100644 --- a/tests/mir-opt/const_prop/ref_deref.main.GVN.diff +++ b/tests/mir-opt/const_prop/ref_deref.main.GVN.diff @@ -8,7 +8,8 @@ let _3: i32; let mut _4: &i32; scope 1 { - debug a => _1; +- debug a => _1; ++ debug a => const 4_i32; } bb0: { diff --git a/tests/mir-opt/const_prop/ref_deref.rs b/tests/mir-opt/const_prop/ref_deref.rs index aef36323cc033..51a67f8499956 100644 --- a/tests/mir-opt/const_prop/ref_deref.rs +++ b/tests/mir-opt/const_prop/ref_deref.rs @@ -3,7 +3,6 @@ // EMIT_MIR ref_deref.main.GVN.diff fn main() { // CHECK-LABEL: fn main( - // CHECK: debug a => [[a:_.*]]; - // CHECK: [[a]] = const 4_i32; + // CHECK: debug a => const 4_i32; let a = *(&4); } diff --git a/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff b/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff index dcc13c9251c41..f1c13a9316989 100644 --- a/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff +++ b/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff @@ -8,7 +8,8 @@ let _3: (i32, i32); let mut _4: &(i32, i32); scope 1 { - debug a => _1; +- debug a => _1; ++ debug a => const 5_i32; } bb0: { diff --git a/tests/mir-opt/const_prop/ref_deref_project.rs b/tests/mir-opt/const_prop/ref_deref_project.rs index 5a48a887f93d7..459b7a71af705 100644 --- a/tests/mir-opt/const_prop/ref_deref_project.rs +++ b/tests/mir-opt/const_prop/ref_deref_project.rs @@ -4,7 +4,6 @@ // EMIT_MIR ref_deref_project.main.GVN.diff fn main() { // CHECK-LABEL: fn main( - // CHECK: debug a => [[a:_.*]]; - // CHECK: [[a]] = const 5_i32; + // CHECK: debug a => const 5_i32; let a = *(&(4, 5).1); } diff --git a/tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-abort.diff index a41668b6fa36a..a63eef0dd6b7f 100644 --- a/tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-abort.diff @@ -9,7 +9,8 @@ let _4: usize; let mut _5: bool; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 42_u32; } bb0: { diff --git a/tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-unwind.diff index 2313084b49e6f..b7529e8baa7ed 100644 --- a/tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-unwind.diff @@ -9,7 +9,8 @@ let _4: usize; let mut _5: bool; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 42_u32; } bb0: { diff --git a/tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-abort.diff index a41668b6fa36a..a63eef0dd6b7f 100644 --- a/tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-abort.diff @@ -9,7 +9,8 @@ let _4: usize; let mut _5: bool; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 42_u32; } bb0: { diff --git a/tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-unwind.diff index 2313084b49e6f..b7529e8baa7ed 100644 --- a/tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-unwind.diff @@ -9,7 +9,8 @@ let _4: usize; let mut _5: bool; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 42_u32; } bb0: { diff --git a/tests/mir-opt/const_prop/repeat.rs b/tests/mir-opt/const_prop/repeat.rs index d778191389518..0bc8d46617518 100644 --- a/tests/mir-opt/const_prop/repeat.rs +++ b/tests/mir-opt/const_prop/repeat.rs @@ -5,7 +5,6 @@ // EMIT_MIR repeat.main.GVN.diff fn main() { // CHECK-LABEL: fn main( - // CHECK: debug x => [[x:_.*]]; - // CHECK: [[x]] = const 42_u32; + // CHECK: debug x => const 42_u32; let x: u32 = [42; 8][2] + 0; } diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-abort.diff index 3c73d34474c13..886d121a4cfdd 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-abort.diff @@ -7,7 +7,8 @@ let _2: (); let mut _3: u32; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 1_u32; } bb0: { diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-unwind.diff index 0a7fddee39b62..e39368326f25c 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-unwind.diff @@ -7,7 +7,8 @@ let _2: (); let mut _3: u32; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 1_u32; } bb0: { diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff index d6e81debccd81..046a3ebb26320 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff @@ -13,7 +13,8 @@ let mut _8: bool; let mut _9: &[u32; 3]; scope 1 { - debug a => _1; +- debug a => _1; ++ debug a => const 2_u32; } bb0: { diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff index 6713e531892ae..5a2209af07676 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff @@ -13,7 +13,8 @@ let mut _8: bool; let mut _9: &[u32; 3]; scope 1 { - debug a => _1; +- debug a => _1; ++ debug a => const 2_u32; } bb0: { diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff index d6e81debccd81..046a3ebb26320 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff @@ -13,7 +13,8 @@ let mut _8: bool; let mut _9: &[u32; 3]; scope 1 { - debug a => _1; +- debug a => _1; ++ debug a => const 2_u32; } bb0: { diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff index 6713e531892ae..5a2209af07676 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff @@ -13,7 +13,8 @@ let mut _8: bool; let mut _9: &[u32; 3]; scope 1 { - debug a => _1; +- debug a => _1; ++ debug a => const 2_u32; } bb0: { diff --git a/tests/mir-opt/const_prop/slice_len.rs b/tests/mir-opt/const_prop/slice_len.rs index ebd3c9e792dca..c47a8d0ee6377 100644 --- a/tests/mir-opt/const_prop/slice_len.rs +++ b/tests/mir-opt/const_prop/slice_len.rs @@ -6,9 +6,8 @@ // EMIT_MIR slice_len.main.GVN.diff fn main() { // CHECK-LABEL: fn main( - // CHECK: debug a => [[a:_.*]]; + // CHECK: debug a => const 2_u32; // CHECK: [[slice:_.*]] = copy {{.*}} as &[u32] (PointerCoercion(Unsize, AsCast)); // CHECK: assert(const true, - // CHECK: [[a]] = const 2_u32; let a = (&[1u32, 2, 3] as &[u32])[1]; } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff index b698d8f373575..9a28e6e8a8047 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff @@ -6,7 +6,8 @@ let _1: std::boxed::Box; let mut _2: *const Never; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const Box::(Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); } bb0: { diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff index b698d8f373575..9a28e6e8a8047 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff @@ -6,7 +6,8 @@ let _1: std::boxed::Box; let mut _2: *const Never; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const Box::(Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); } bb0: { diff --git a/tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.32bit.diff index 5aeb55a5a6a53..ff5545b02dca9 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.32bit.diff @@ -6,7 +6,8 @@ let _1: Never; let mut _2: (); scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const ZeroSized: Never; } bb0: { diff --git a/tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.64bit.diff index 5aeb55a5a6a53..ff5545b02dca9 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.64bit.diff @@ -6,7 +6,8 @@ let _1: Never; let mut _2: (); scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const ZeroSized: Never; } bb0: { diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff index a702079323789..ec55398e331c5 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff @@ -6,7 +6,8 @@ let _1: &mut Never; let mut _2: &mut Never; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const {0x1 as &mut Never}; } bb0: { diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff index a702079323789..ec55398e331c5 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff @@ -6,7 +6,8 @@ let _1: &mut Never; let mut _2: &mut Never; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const {0x1 as &mut Never}; } bb0: { diff --git a/tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.32bit.diff index d44b087203569..12846d892b260 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.32bit.diff @@ -5,7 +5,8 @@ let mut _0: !; let _1: &Never; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const {0x1 as &Never}; } bb0: { diff --git a/tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.64bit.diff index d44b087203569..12846d892b260 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.64bit.diff @@ -5,7 +5,8 @@ let mut _0: !; let _1: &Never; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const {0x1 as &Never}; } bb0: { diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-abort.diff index 01d86ce8717d1..015b2a47879fc 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-abort.diff @@ -7,7 +7,8 @@ let _2: (); let mut _3: (u32, u32); scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const (1_u32, 2_u32); } bb0: { diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-unwind.diff index bd7d494212ce6..c91329c138062 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-unwind.diff @@ -7,7 +7,8 @@ let _2: (); let mut _3: (u32, u32); scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const (1_u32, 2_u32); } bb0: { diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff index 2c89670dcf7d7..e59dc42f1b8e2 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff @@ -16,12 +16,13 @@ scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { - let mut _6: std::num::NonZero; + let _6: std::ptr::Alignment; + let mut _7: std::num::NonZero; scope 6 { scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _7: *const [bool; 0]; + let _8: *const [bool; 0]; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -45,10 +46,13 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); - _6 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + _6 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); StorageLive(_7); - _7 = const {0x1 as *const [bool; 0]}; + _7 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + StorageLive(_8); + _8 = const {0x1 as *const [bool; 0]}; _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_8); StorageDead(_7); StorageDead(_6); _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff index 8fecfe224cc69..cfa9b622b70bd 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff @@ -16,12 +16,13 @@ scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { - let mut _6: std::num::NonZero; + let _6: std::ptr::Alignment; + let mut _7: std::num::NonZero; scope 6 { scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _7: *const [bool; 0]; + let _8: *const [bool; 0]; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -45,10 +46,13 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); - _6 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + _6 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); StorageLive(_7); - _7 = const {0x1 as *const [bool; 0]}; + _7 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + StorageLive(_8); + _8 = const {0x1 as *const [bool; 0]}; _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_8); StorageDead(_7); StorageDead(_6); _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff index 976ea252c2f89..db36b4737a760 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff @@ -16,12 +16,13 @@ scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { - let mut _6: std::num::NonZero; + let _6: std::ptr::Alignment; + let mut _7: std::num::NonZero; scope 6 { scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _7: *const [bool; 0]; + let _8: *const [bool; 0]; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -45,10 +46,13 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); - _6 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + _6 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); StorageLive(_7); - _7 = const {0x1 as *const [bool; 0]}; + _7 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + StorageLive(_8); + _8 = const {0x1 as *const [bool; 0]}; _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_8); StorageDead(_7); StorageDead(_6); _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff index 6c59f5e3e2e86..c4ce4d7b85824 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff @@ -16,12 +16,13 @@ scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { - let mut _6: std::num::NonZero; + let _6: std::ptr::Alignment; + let mut _7: std::num::NonZero; scope 6 { scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _7: *const [bool; 0]; + let _8: *const [bool; 0]; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -45,10 +46,13 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); - _6 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + _6 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); StorageLive(_7); - _7 = const {0x1 as *const [bool; 0]}; + _7 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + StorageLive(_8); + _8 = const {0x1 as *const [bool; 0]}; _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_8); StorageDead(_7); StorageDead(_6); _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff index 1f9cf6d6aca83..9dc32a4e72ca6 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff @@ -16,12 +16,13 @@ scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { - let mut _6: std::num::NonZero; + let _6: std::ptr::Alignment; + let mut _7: std::num::NonZero; scope 6 { scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _7: *const [bool; 0]; + let _8: *const [bool; 0]; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -45,13 +46,17 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); -- _6 = const std::ptr::Alignment::of::<[bool; 0]>::{constant#0} as std::num::NonZero (Transmute); -+ _6 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); +- _6 = const std::ptr::Alignment::of::<[bool; 0]>::{constant#0}; ++ _6 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); StorageLive(_7); -- _7 = copy _6 as *const [bool; 0] (Transmute); -- _5 = NonNull::<[bool; 0]> { pointer: copy _7 }; -+ _7 = const {0x1 as *const [bool; 0]}; +- _7 = copy _6 as std::num::NonZero (Transmute); ++ _7 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + StorageLive(_8); +- _8 = copy _7 as *const [bool; 0] (Transmute); +- _5 = NonNull::<[bool; 0]> { pointer: copy _8 }; ++ _8 = const {0x1 as *const [bool; 0]}; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_8); StorageDead(_7); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff index a8760285fac11..fc03e58430e78 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff @@ -16,12 +16,13 @@ scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { - let mut _6: std::num::NonZero; + let _6: std::ptr::Alignment; + let mut _7: std::num::NonZero; scope 6 { scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _7: *const [bool; 0]; + let _8: *const [bool; 0]; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -45,13 +46,17 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); -- _6 = const std::ptr::Alignment::of::<[bool; 0]>::{constant#0} as std::num::NonZero (Transmute); -+ _6 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); +- _6 = const std::ptr::Alignment::of::<[bool; 0]>::{constant#0}; ++ _6 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); StorageLive(_7); -- _7 = copy _6 as *const [bool; 0] (Transmute); -- _5 = NonNull::<[bool; 0]> { pointer: copy _7 }; -+ _7 = const {0x1 as *const [bool; 0]}; +- _7 = copy _6 as std::num::NonZero (Transmute); ++ _7 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + StorageLive(_8); +- _8 = copy _7 as *const [bool; 0] (Transmute); +- _5 = NonNull::<[bool; 0]> { pointer: copy _8 }; ++ _8 = const {0x1 as *const [bool; 0]}; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_8); StorageDead(_7); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff index c398ae70a1a3e..91191289e4346 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff @@ -16,12 +16,13 @@ scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { - let mut _6: std::num::NonZero; + let _6: std::ptr::Alignment; + let mut _7: std::num::NonZero; scope 6 { scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _7: *const [bool; 0]; + let _8: *const [bool; 0]; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -45,13 +46,17 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); -- _6 = const std::ptr::Alignment::of::<[bool; 0]>::{constant#0} as std::num::NonZero (Transmute); -+ _6 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); +- _6 = const std::ptr::Alignment::of::<[bool; 0]>::{constant#0}; ++ _6 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); StorageLive(_7); -- _7 = copy _6 as *const [bool; 0] (Transmute); -- _5 = NonNull::<[bool; 0]> { pointer: copy _7 }; -+ _7 = const {0x1 as *const [bool; 0]}; +- _7 = copy _6 as std::num::NonZero (Transmute); ++ _7 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + StorageLive(_8); +- _8 = copy _7 as *const [bool; 0] (Transmute); +- _5 = NonNull::<[bool; 0]> { pointer: copy _8 }; ++ _8 = const {0x1 as *const [bool; 0]}; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_8); StorageDead(_7); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff index 02934c02587d2..5612d560524c1 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff @@ -16,12 +16,13 @@ scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { - let mut _6: std::num::NonZero; + let _6: std::ptr::Alignment; + let mut _7: std::num::NonZero; scope 6 { scope 8 (inlined std::ptr::Alignment::as_nonzero) { } scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) { - let _7: *const [bool; 0]; + let _8: *const [bool; 0]; scope 10 { } scope 11 (inlined NonZero::::get) { @@ -45,13 +46,17 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); -- _6 = const std::ptr::Alignment::of::<[bool; 0]>::{constant#0} as std::num::NonZero (Transmute); -+ _6 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); +- _6 = const std::ptr::Alignment::of::<[bool; 0]>::{constant#0}; ++ _6 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); StorageLive(_7); -- _7 = copy _6 as *const [bool; 0] (Transmute); -- _5 = NonNull::<[bool; 0]> { pointer: copy _7 }; -+ _7 = const {0x1 as *const [bool; 0]}; +- _7 = copy _6 as std::num::NonZero (Transmute); ++ _7 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); + StorageLive(_8); +- _8 = copy _7 as *const [bool; 0] (Transmute); +- _5 = NonNull::<[bool; 0]> { pointer: copy _8 }; ++ _8 = const {0x1 as *const [bool; 0]}; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + StorageDead(_8); StorageDead(_7); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff index f203b80e4776c..031a1c8f76430 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff @@ -10,7 +10,7 @@ let mut _8: *const [()]; let mut _9: std::boxed::Box<()>; let mut _10: *const (); - let mut _23: usize; + let mut _24: usize; scope 1 { debug vp_ctx => _1; let _4: *const (); @@ -43,11 +43,12 @@ let mut _18: !; scope 7 { let _17: std::ptr::NonNull<[u8]>; + let mut _19: &std::alloc::Global; scope 8 { scope 11 (inlined NonNull::<[u8]>::as_mut_ptr) { scope 12 (inlined NonNull::<[u8]>::as_non_null_ptr) { scope 13 (inlined NonNull::<[u8]>::cast::) { - let mut _22: *mut [u8]; + let mut _23: *mut [u8]; scope 14 (inlined NonNull::<[u8]>::as_ptr) { } } @@ -60,9 +61,9 @@ } } scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) { - let mut _19: bool; - let _20: (); - let mut _21: std::ptr::Alignment; + let mut _20: bool; + let _21: (); + let mut _22: std::ptr::Alignment; } } } @@ -82,8 +83,9 @@ StorageLive(_16); StorageLive(_17); StorageLive(_19); - _19 = const false; -- switchInt(move _19) -> [0: bb6, otherwise: bb5]; + StorageLive(_20); + _20 = const false; +- switchInt(move _20) -> [0: bb6, otherwise: bb5]; + switchInt(const false) -> [0: bb6, otherwise: bb5]; } @@ -104,11 +106,12 @@ bb4: { _17 = copy ((_15 as Ok).0: std::ptr::NonNull<[u8]>); - StorageLive(_22); - _22 = copy _17 as *mut [u8] (Transmute); - _13 = copy _22 as *mut u8 (PtrToPtr); - StorageDead(_22); + StorageLive(_23); + _23 = copy _17 as *mut [u8] (Transmute); + _13 = copy _23 as *mut u8 (PtrToPtr); + StorageDead(_23); StorageDead(_15); + StorageDead(_19); StorageDead(_17); StorageDead(_16); StorageDead(_14); @@ -129,11 +132,11 @@ StorageLive(_6); - _6 = copy _4; + _6 = copy _10; - StorageLive(_23); - _23 = const 1_usize; -- _5 = *const [()] from (copy _6, copy _23); + StorageLive(_24); + _24 = const 1_usize; +- _5 = *const [()] from (copy _6, copy _24); + _5 = *const [()] from (copy _10, const 1_usize); - StorageDead(_23); + StorageDead(_24); StorageDead(_6); StorageLive(_7); StorageLive(_8); @@ -149,21 +152,22 @@ } bb5: { -- _20 = Layout::from_size_align_unchecked::precondition_check(copy _11, copy _12) -> [return: bb6, unwind unreachable]; -+ _20 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; +- _21 = Layout::from_size_align_unchecked::precondition_check(copy _11, copy _12) -> [return: bb6, unwind unreachable]; ++ _21 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; } bb6: { - StorageDead(_19); - StorageLive(_21); -- _21 = copy _12 as std::ptr::Alignment (Transmute); -- _14 = Layout { size: copy _11, align: move _21 }; -+ _21 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); + StorageDead(_20); + StorageLive(_22); +- _22 = copy _12 as std::ptr::Alignment (Transmute); +- _14 = Layout { size: copy _11, align: move _22 }; ++ _22 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); + _14 = const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}; - StorageDead(_21); + StorageDead(_22); StorageLive(_15); -- _15 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], copy _14, const false) -> [return: bb7, unwind unreachable]; -+ _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]; + _19 = const alloc::alloc::exchange_malloc::promoted[0]; +- _15 = std::alloc::Global::alloc_impl(move _19, copy _14, const false) -> [return: bb7, unwind unreachable]; ++ _15 = std::alloc::Global::alloc_impl(move _19, const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}, const false) -> [return: bb7, unwind unreachable]; } bb7: { diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff index f072eb6ef8bf6..1d53df73f5bfb 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff @@ -10,7 +10,7 @@ let mut _8: *const [()]; let mut _9: std::boxed::Box<()>; let mut _10: *const (); - let mut _23: usize; + let mut _24: usize; scope 1 { debug vp_ctx => _1; let _4: *const (); @@ -43,11 +43,12 @@ let mut _18: !; scope 7 { let _17: std::ptr::NonNull<[u8]>; + let mut _19: &std::alloc::Global; scope 8 { scope 11 (inlined NonNull::<[u8]>::as_mut_ptr) { scope 12 (inlined NonNull::<[u8]>::as_non_null_ptr) { scope 13 (inlined NonNull::<[u8]>::cast::) { - let mut _22: *mut [u8]; + let mut _23: *mut [u8]; scope 14 (inlined NonNull::<[u8]>::as_ptr) { } } @@ -60,9 +61,9 @@ } } scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) { - let mut _19: bool; - let _20: (); - let mut _21: std::ptr::Alignment; + let mut _20: bool; + let _21: (); + let mut _22: std::ptr::Alignment; } } } @@ -82,8 +83,9 @@ StorageLive(_16); StorageLive(_17); StorageLive(_19); - _19 = const false; -- switchInt(move _19) -> [0: bb6, otherwise: bb5]; + StorageLive(_20); + _20 = const false; +- switchInt(move _20) -> [0: bb6, otherwise: bb5]; + switchInt(const false) -> [0: bb6, otherwise: bb5]; } @@ -104,11 +106,12 @@ bb4: { _17 = copy ((_15 as Ok).0: std::ptr::NonNull<[u8]>); - StorageLive(_22); - _22 = copy _17 as *mut [u8] (Transmute); - _13 = copy _22 as *mut u8 (PtrToPtr); - StorageDead(_22); + StorageLive(_23); + _23 = copy _17 as *mut [u8] (Transmute); + _13 = copy _23 as *mut u8 (PtrToPtr); + StorageDead(_23); StorageDead(_15); + StorageDead(_19); StorageDead(_17); StorageDead(_16); StorageDead(_14); @@ -129,11 +132,11 @@ StorageLive(_6); - _6 = copy _4; + _6 = copy _10; - StorageLive(_23); - _23 = const 1_usize; -- _5 = *const [()] from (copy _6, copy _23); + StorageLive(_24); + _24 = const 1_usize; +- _5 = *const [()] from (copy _6, copy _24); + _5 = *const [()] from (copy _10, const 1_usize); - StorageDead(_23); + StorageDead(_24); StorageDead(_6); StorageLive(_7); StorageLive(_8); @@ -149,21 +152,22 @@ } bb5: { -- _20 = Layout::from_size_align_unchecked::precondition_check(copy _11, copy _12) -> [return: bb6, unwind unreachable]; -+ _20 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; +- _21 = Layout::from_size_align_unchecked::precondition_check(copy _11, copy _12) -> [return: bb6, unwind unreachable]; ++ _21 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; } bb6: { - StorageDead(_19); - StorageLive(_21); -- _21 = copy _12 as std::ptr::Alignment (Transmute); -- _14 = Layout { size: copy _11, align: move _21 }; -+ _21 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); + StorageDead(_20); + StorageLive(_22); +- _22 = copy _12 as std::ptr::Alignment (Transmute); +- _14 = Layout { size: copy _11, align: move _22 }; ++ _22 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); + _14 = const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}; - StorageDead(_21); + StorageDead(_22); StorageLive(_15); -- _15 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], copy _14, const false) -> [return: bb7, unwind unreachable]; -+ _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]; + _19 = const alloc::alloc::exchange_malloc::promoted[0]; +- _15 = std::alloc::Global::alloc_impl(move _19, copy _14, const false) -> [return: bb7, unwind unreachable]; ++ _15 = std::alloc::Global::alloc_impl(move _19, const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}, const false) -> [return: bb7, unwind unreachable]; } bb7: { diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff index 6baa902b6f4bd..40630e7ad9712 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-abort.diff @@ -47,7 +47,7 @@ StorageLive(_20); StorageLive(_21); _21 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32); - _20 = BitAnd(move _21, const core::fmt::flags::SIGN_PLUS_FLAG); + _20 = BitAnd(move _21, const 2097152_u32); StorageDead(_21); _4 = Ne(move _20, const 0_u32); StorageDead(_20); @@ -72,7 +72,7 @@ StorageLive(_22); StorageLive(_23); _23 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32); - _22 = BitAnd(move _23, const core::fmt::flags::PRECISION_FLAG); + _22 = BitAnd(move _23, const 268435456_u32); StorageDead(_23); switchInt(move _22) -> [0: bb10, otherwise: bb11]; } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff index 36540e038654f..29a5b06ae7ec8 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.32bit.panic-unwind.diff @@ -47,7 +47,7 @@ StorageLive(_20); StorageLive(_21); _21 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32); - _20 = BitAnd(move _21, const core::fmt::flags::SIGN_PLUS_FLAG); + _20 = BitAnd(move _21, const 2097152_u32); StorageDead(_21); _4 = Ne(move _20, const 0_u32); StorageDead(_20); @@ -72,7 +72,7 @@ StorageLive(_22); StorageLive(_23); _23 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32); - _22 = BitAnd(move _23, const core::fmt::flags::PRECISION_FLAG); + _22 = BitAnd(move _23, const 268435456_u32); StorageDead(_23); switchInt(move _22) -> [0: bb10, otherwise: bb11]; } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff index 41c350f3eaeb5..56e08fcce8082 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-abort.diff @@ -47,7 +47,7 @@ StorageLive(_20); StorageLive(_21); _21 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32); - _20 = BitAnd(move _21, const core::fmt::flags::SIGN_PLUS_FLAG); + _20 = BitAnd(move _21, const 2097152_u32); StorageDead(_21); _4 = Ne(move _20, const 0_u32); StorageDead(_20); @@ -72,7 +72,7 @@ StorageLive(_22); StorageLive(_23); _23 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32); - _22 = BitAnd(move _23, const core::fmt::flags::PRECISION_FLAG); + _22 = BitAnd(move _23, const 268435456_u32); StorageDead(_23); switchInt(move _22) -> [0: bb10, otherwise: bb11]; } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff index b839bf81eaf45..dd4c5cf5d65d6 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.64bit.panic-unwind.diff @@ -47,7 +47,7 @@ StorageLive(_20); StorageLive(_21); _21 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32); - _20 = BitAnd(move _21, const core::fmt::flags::SIGN_PLUS_FLAG); + _20 = BitAnd(move _21, const 2097152_u32); StorageDead(_21); _4 = Ne(move _20, const 0_u32); StorageDead(_20); @@ -72,7 +72,7 @@ StorageLive(_22); StorageLive(_23); _23 = copy (((*_1).0: std::fmt::FormattingOptions).0: u32); - _22 = BitAnd(move _23, const core::fmt::flags::PRECISION_FLAG); + _22 = BitAnd(move _23, const 268435456_u32); StorageDead(_23); switchInt(move _22) -> [0: bb10, otherwise: bb11]; } diff --git a/tests/mir-opt/gvn.cast.GVN.panic-abort.diff b/tests/mir-opt/gvn.cast.GVN.panic-abort.diff index 1d523d22ca646..a79761a828b78 100644 --- a/tests/mir-opt/gvn.cast.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.cast.GVN.panic-abort.diff @@ -92,13 +92,16 @@ let _89: (); let mut _90: f64; scope 1 { - debug i => _1; +- debug i => _1; ++ debug i => const 1_i64; let _2: u64; scope 2 { - debug u => _2; +- debug u => _2; ++ debug u => const 1_u64; let _3: f64; scope 3 { - debug f => _3; +- debug f => _3; ++ debug f => const 1f64; } } } diff --git a/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff b/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff index 3541c10da6437..62f3025268bfc 100644 --- a/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff @@ -92,13 +92,16 @@ let _89: (); let mut _90: f64; scope 1 { - debug i => _1; +- debug i => _1; ++ debug i => const 1_i64; let _2: u64; scope 2 { - debug u => _2; +- debug u => _2; ++ debug u => const 1_u64; let _3: f64; scope 3 { - debug f => _3; +- debug f => _3; ++ debug f => const 1f64; } } } diff --git a/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-abort.diff b/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-abort.diff index 183b4d2599f53..d9868b1408d8e 100644 --- a/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-abort.diff @@ -17,7 +17,8 @@ let mut _13: bool; let mut _14: T; scope 1 { - debug a => _2; +- debug a => _2; ++ debug a => const usize::MAX; let _3: T; scope 2 { debug b => _3; diff --git a/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-unwind.diff b/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-unwind.diff index 03e8aa3bd9b98..2731fd760da5d 100644 --- a/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-unwind.diff @@ -17,7 +17,8 @@ let mut _13: bool; let mut _14: T; scope 1 { - debug a => _2; +- debug a => _2; ++ debug a => const usize::MAX; let _3: T; scope 2 { debug b => _3; diff --git a/tests/mir-opt/gvn.dereference_indexing.GVN.panic-abort.diff b/tests/mir-opt/gvn.dereference_indexing.GVN.panic-abort.diff index 9bdcc2f108a6a..1a07638cbafea 100644 --- a/tests/mir-opt/gvn.dereference_indexing.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.dereference_indexing.GVN.panic-abort.diff @@ -43,7 +43,8 @@ + nop; StorageLive(_8); StorageLive(_9); - _9 = copy (*_3); +- _9 = copy (*_3); ++ _9 = copy _1[_4]; _8 = opaque::(move _9) -> [return: bb2, unwind unreachable]; } diff --git a/tests/mir-opt/gvn.dereference_indexing.GVN.panic-unwind.diff b/tests/mir-opt/gvn.dereference_indexing.GVN.panic-unwind.diff index f38bc51adc480..6e67b66e783c4 100644 --- a/tests/mir-opt/gvn.dereference_indexing.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.dereference_indexing.GVN.panic-unwind.diff @@ -43,7 +43,8 @@ + nop; StorageLive(_8); StorageLive(_9); - _9 = copy (*_3); +- _9 = copy (*_3); ++ _9 = copy _1[_4]; _8 = opaque::(move _9) -> [return: bb2, unwind continue]; } diff --git a/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff b/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff index f3f631956374d..de43f5ea7ccd5 100644 --- a/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff @@ -21,7 +21,8 @@ debug g => _4; let _7: {closure@$DIR/gvn.rs:617:19: 617:21}; scope 3 { - debug closure => _7; +- debug closure => _7; ++ debug closure => const ZeroSized: {closure@$DIR/gvn.rs:617:19: 617:21}; let _8: fn(); scope 4 { debug cf => _8; diff --git a/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff b/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff index 029e736a97952..f0826cea45165 100644 --- a/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff @@ -21,7 +21,8 @@ debug g => _4; let _7: {closure@$DIR/gvn.rs:617:19: 617:21}; scope 3 { - debug closure => _7; +- debug closure => _7; ++ debug closure => const ZeroSized: {closure@$DIR/gvn.rs:617:19: 617:21}; let _8: fn(); scope 4 { debug cf => _8; diff --git a/tests/mir-opt/gvn.repeat.GVN.panic-abort.diff b/tests/mir-opt/gvn.repeat.GVN.panic-abort.diff index ef2eb1a66779d..39aa1672fd30f 100644 --- a/tests/mir-opt/gvn.repeat.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.repeat.GVN.panic-abort.diff @@ -15,7 +15,8 @@ let mut _11: i32; let mut _12: i32; scope 1 { - debug val => _1; +- debug val => _1; ++ debug val => const 5_i32; let _2: [i32; 10]; scope 2 { debug array => _2; diff --git a/tests/mir-opt/gvn.repeat.GVN.panic-unwind.diff b/tests/mir-opt/gvn.repeat.GVN.panic-unwind.diff index ef2eb1a66779d..39aa1672fd30f 100644 --- a/tests/mir-opt/gvn.repeat.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.repeat.GVN.panic-unwind.diff @@ -15,7 +15,8 @@ let mut _11: i32; let mut _12: i32; scope 1 { - debug val => _1; +- debug val => _1; ++ debug val => const 5_i32; let _2: [i32; 10]; scope 2 { debug array => _2; diff --git a/tests/mir-opt/gvn.rs b/tests/mir-opt/gvn.rs index 98f94fbf0b146..604aeb94e0dd3 100644 --- a/tests/mir-opt/gvn.rs +++ b/tests/mir-opt/gvn.rs @@ -640,11 +640,10 @@ fn indirect_static() { /// Verify that having constant index `u64::MAX` does not yield to an overflow in rustc. fn constant_index_overflow(x: &[T]) { // CHECK-LABEL: fn constant_index_overflow( - // CHECK: debug a => [[a:_.*]]; + // CHECK: debug a => const usize::MAX; // CHECK: debug b => [[b:_.*]]; - // CHECK: [[a]] = const usize::MAX; // CHECK-NOT: = (*_1)[{{.*}} of 0]; - // CHECK: [[b]] = copy (*_1)[[[a]]]; + // CHECK: [[b]] = copy (*_1)[[[a:_.*]]]; // CHECK-NOT: = (*_1)[{{.*}} of 0]; // CHECK: [[b]] = copy (*_1)[0 of 1]; // CHECK-NOT: = (*_1)[{{.*}} of 0]; @@ -709,8 +708,8 @@ fn wide_ptr_same_provenance() { /// Check that we do simplify when there is no provenance, and do not ICE. fn wide_ptr_integer() { // CHECK-LABEL: fn wide_ptr_integer( - // CHECK: debug a => [[a:_.*]]; - // CHECK: debug b => [[b:_.*]]; + // CHECK: debug a => const Indirect + // CHECK: debug b => const Indirect let a: *const [u8] = unsafe { transmute((1usize, 1usize)) }; let b: *const [u8] = unsafe { transmute((1usize, 2usize)) }; @@ -1065,8 +1064,8 @@ fn dereference_indexing(array: [u8; 2], index: usize) { &array[i] }; - // CHECK-NOT: [{{.*}}] - // CHECK: [[tmp:_.*]] = copy (*[[a]]); + // CHECK-NOT: StorageDead([[i]]); + // CHECK: [[tmp:_.*]] = copy _1[[[i]]]; // CHECK: opaque::(move [[tmp]]) opaque(*a); } diff --git a/tests/mir-opt/gvn.slice_const_length.GVN.panic-abort.diff b/tests/mir-opt/gvn.slice_const_length.GVN.panic-abort.diff index 1a6204e4ac8ae..e473be14e6171 100644 --- a/tests/mir-opt/gvn.slice_const_length.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.slice_const_length.GVN.panic-abort.diff @@ -12,7 +12,8 @@ debug ptr => _2; let _4: usize; scope 2 { - debug len => _4; +- debug len => _4; ++ debug len => const 123_usize; } } diff --git a/tests/mir-opt/gvn.slice_const_length.GVN.panic-unwind.diff b/tests/mir-opt/gvn.slice_const_length.GVN.panic-unwind.diff index 62d57b0fe2831..e046b18edf99d 100644 --- a/tests/mir-opt/gvn.slice_const_length.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.slice_const_length.GVN.panic-unwind.diff @@ -12,7 +12,8 @@ debug ptr => _2; let _4: usize; scope 2 { - debug len => _4; +- debug len => _4; ++ debug len => const 123_usize; } } diff --git a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff index 091c3bd5c7b2a..5994e47dcd980 100644 --- a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff @@ -50,10 +50,12 @@ let _53: &*const u8; let mut _54: std::option::Option>; scope 1 { - debug s => _1; +- debug s => _1; ++ debug s => const "my favourite slice"; let _4: &str; scope 2 { - debug t => _4; +- debug t => _4; ++ debug t => const "my favourite slice"; let _15: &*const u8; let _16: &*const u8; let _29: &[u8]; @@ -62,7 +64,8 @@ debug right_val => _16; let _21: core::panicking::AssertKind; scope 4 { - debug kind => _21; +- debug kind => _21; ++ debug kind => const core::panicking::AssertKind::Eq; } } scope 5 { @@ -74,7 +77,8 @@ debug right_val => _42; let _47: core::panicking::AssertKind; scope 7 { - debug kind => _47; +- debug kind => _47; ++ debug kind => const core::panicking::AssertKind::Eq; } } } diff --git a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff index 9768956c9c870..5c6affb0797c3 100644 --- a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff @@ -50,10 +50,12 @@ let _53: &*const u8; let mut _54: std::option::Option>; scope 1 { - debug s => _1; +- debug s => _1; ++ debug s => const "my favourite slice"; let _4: &str; scope 2 { - debug t => _4; +- debug t => _4; ++ debug t => const "my favourite slice"; let _15: &*const u8; let _16: &*const u8; let _29: &[u8]; @@ -62,7 +64,8 @@ debug right_val => _16; let _21: core::panicking::AssertKind; scope 4 { - debug kind => _21; +- debug kind => _21; ++ debug kind => const core::panicking::AssertKind::Eq; } } scope 5 { @@ -74,7 +77,8 @@ debug right_val => _42; let _47: core::panicking::AssertKind; scope 7 { - debug kind => _47; +- debug kind => _47; ++ debug kind => const core::panicking::AssertKind::Eq; } } } diff --git a/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-abort.diff b/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-abort.diff index bb938f3ba6a9a..9aea74926e994 100644 --- a/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-abort.diff @@ -31,10 +31,12 @@ let mut _27: *const [u8]; let mut _28: *const [u8]; scope 1 { - debug a => _1; +- debug a => _1; ++ debug a => const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; let _3: *const [u8]; scope 2 { - debug b => _3; +- debug b => _3; ++ debug b => const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; } } diff --git a/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-unwind.diff b/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-unwind.diff index 81432d687eb32..0ebff8eca55df 100644 --- a/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-unwind.diff @@ -31,10 +31,12 @@ let mut _27: *const [u8]; let mut _28: *const [u8]; scope 1 { - debug a => _1; +- debug a => _1; ++ debug a => const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; let _3: *const [u8]; scope 2 { - debug b => _3; +- debug b => _3; ++ debug b => const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; } } diff --git a/tests/mir-opt/gvn_const_eval_polymorphic.no_optimize.GVN.diff b/tests/mir-opt/gvn_const_eval_polymorphic.no_optimize.GVN.diff index a91561ba304b8..92158682c9993 100644 --- a/tests/mir-opt/gvn_const_eval_polymorphic.no_optimize.GVN.diff +++ b/tests/mir-opt/gvn_const_eval_polymorphic.no_optimize.GVN.diff @@ -5,7 +5,8 @@ let mut _0: bool; bb0: { - _0 = Eq(const no_optimize::::{constant#0}, const no_optimize::::{constant#1}); +- _0 = Eq(const no_optimize::::{constant#0}, const no_optimize::::{constant#1}); ++ _0 = Eq(const no_optimize::::{constant#0}, const true); return; } } diff --git a/tests/mir-opt/gvn_const_eval_polymorphic.rs b/tests/mir-opt/gvn_const_eval_polymorphic.rs index 7320ad947ff2e..722720b2a6f07 100644 --- a/tests/mir-opt/gvn_const_eval_polymorphic.rs +++ b/tests/mir-opt/gvn_const_eval_polymorphic.rs @@ -51,7 +51,7 @@ fn optimize_false() -> bool { // EMIT_MIR gvn_const_eval_polymorphic.no_optimize.GVN.diff fn no_optimize() -> bool { // CHECK-LABEL: fn no_optimize( - // CHECK: _0 = Eq(const no_optimize::::{constant#0}, const no_optimize::::{constant#1}); + // CHECK: _0 = Eq(const no_optimize::::{constant#0}, const true); // CHECK-NEXT: return; (const { type_name_contains_i32(&generic::) }) == const { true } } diff --git a/tests/mir-opt/gvn_on_unsafe_binder.propagate.GVN.diff b/tests/mir-opt/gvn_on_unsafe_binder.propagate.GVN.diff index e28d04f1d5885..7d925eea2a96c 100644 --- a/tests/mir-opt/gvn_on_unsafe_binder.propagate.GVN.diff +++ b/tests/mir-opt/gvn_on_unsafe_binder.propagate.GVN.diff @@ -6,10 +6,12 @@ let _1: i32; let mut _3: i32; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 1_i32; let _2: unsafe i32; scope 2 { - debug binder => _2; +- debug binder => _2; ++ debug binder => const {transmute(0x00000001): unsafe i32}; } } diff --git a/tests/mir-opt/gvn_on_unsafe_binder.test.GVN.diff b/tests/mir-opt/gvn_on_unsafe_binder.test.GVN.diff index 33814fb34f3d2..6576d5e566a52 100644 --- a/tests/mir-opt/gvn_on_unsafe_binder.test.GVN.diff +++ b/tests/mir-opt/gvn_on_unsafe_binder.test.GVN.diff @@ -6,7 +6,8 @@ let _1: i32; let mut _3: &i32; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 1_i32; let _2: unsafe<'a> &'a i32; scope 2 { debug binder => _2; diff --git a/tests/mir-opt/gvn_ptr_eq_with_constant.main.GVN.diff b/tests/mir-opt/gvn_ptr_eq_with_constant.main.GVN.diff index f56af33ea603f..b31d58614372c 100644 --- a/tests/mir-opt/gvn_ptr_eq_with_constant.main.GVN.diff +++ b/tests/mir-opt/gvn_ptr_eq_with_constant.main.GVN.diff @@ -7,7 +7,8 @@ let mut _2: *mut u8; scope 1 (inlined dangling_mut::) { scope 2 (inlined NonNull::::dangling) { - let mut _3: std::num::NonZero; + let _3: std::ptr::Alignment; + let mut _4: std::num::NonZero; scope 3 { scope 5 (inlined std::ptr::Alignment::as_nonzero) { } @@ -29,9 +30,9 @@ } } scope 12 (inlined Foo::::cmp_ptr) { - let mut _4: *const u8; - let mut _5: *mut u8; - let mut _6: *const u8; + let mut _5: *const u8; + let mut _6: *mut u8; + let mut _7: *const u8; scope 13 (inlined std::ptr::eq::) { } } @@ -39,26 +40,30 @@ bb0: { StorageLive(_1); StorageLive(_2); + StorageLive(_4); StorageLive(_3); -- _3 = const std::ptr::Alignment::of::::{constant#0} as std::num::NonZero (Transmute); -- _2 = copy _3 as *mut u8 (Transmute); -+ _3 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); -+ _2 = const {0x1 as *mut u8}; +- _3 = const std::ptr::Alignment::of::::{constant#0}; +- _4 = copy _3 as std::num::NonZero (Transmute); ++ _3 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); ++ _4 = const NonZero::(core::num::niche_types::NonZeroUsizeInner(1_usize)); StorageDead(_3); - StorageLive(_4); +- _2 = copy _4 as *mut u8 (Transmute); ++ _2 = const {0x1 as *mut u8}; + StorageDead(_4); StorageLive(_5); -- _5 = copy _2; -- _4 = copy _2 as *const u8 (PtrToPtr); -+ _5 = const {0x1 as *mut u8}; -+ _4 = const {0x1 as *const u8}; - StorageDead(_5); StorageLive(_6); -- _6 = const Foo::::SENTINEL as *const u8 (PtrToPtr); -- _1 = Eq(copy _4, copy _6); -+ _6 = const {0x1 as *const u8}; -+ _1 = const true; +- _6 = copy _2; +- _5 = copy _2 as *const u8 (PtrToPtr); ++ _6 = const {0x1 as *mut u8}; ++ _5 = const {0x1 as *const u8}; StorageDead(_6); - StorageDead(_4); + StorageLive(_7); +- _7 = const Foo::::SENTINEL as *const u8 (PtrToPtr); +- _1 = Eq(copy _5, copy _7); ++ _7 = const {0x1 as *const u8}; ++ _1 = const true; + StorageDead(_7); + StorageDead(_5); StorageDead(_2); StorageDead(_1); _0 = const (); diff --git a/tests/mir-opt/gvn_repeat.index_place.GVN.diff b/tests/mir-opt/gvn_repeat.index_place.GVN.diff new file mode 100644 index 0000000000000..1eb7e9015cc3f --- /dev/null +++ b/tests/mir-opt/gvn_repeat.index_place.GVN.diff @@ -0,0 +1,15 @@ +- // MIR for `index_place` before GVN ++ // MIR for `index_place` after GVN + + fn index_place(_1: usize, _2: usize, _3: [i32; 5]) -> i32 { + let mut _0: i32; + let mut _4: &i32; + + bb0: { + _4 = &_3[_1]; + _1 = copy _2; + _0 = copy (*_4); + return; + } + } + diff --git a/tests/mir-opt/gvn_repeat.repeat_local.GVN.diff b/tests/mir-opt/gvn_repeat.repeat_local.GVN.diff index fd04782528117..eb3f885b8665b 100644 --- a/tests/mir-opt/gvn_repeat.repeat_local.GVN.diff +++ b/tests/mir-opt/gvn_repeat.repeat_local.GVN.diff @@ -10,8 +10,7 @@ _4 = [copy _3; 5]; _5 = &_4[_1]; _1 = copy _2; -- _0 = copy (*_5); -+ _0 = copy _3; + _0 = copy (*_5); return; } } diff --git a/tests/mir-opt/gvn_repeat.rs b/tests/mir-opt/gvn_repeat.rs index bbbb2a7ccbaf5..49364c6bfd232 100644 --- a/tests/mir-opt/gvn_repeat.rs +++ b/tests/mir-opt/gvn_repeat.rs @@ -6,6 +6,23 @@ use std::intrinsics::mir::*; +// EMIT_MIR gvn_repeat.index_place.GVN.diff +#[custom_mir(dialect = "runtime")] +pub fn index_place(mut idx1: usize, idx2: usize, array: [i32; 5]) -> i32 { + // CHECK-LABEL: fn index_place( + // CHECK: let mut [[ELEM:.*]]: &i32; + // CHECK: _0 = copy (*[[ELEM]]) + mir! { + let elem; + { + elem = &array[idx1]; + idx1 = idx2; + RET = *elem; + Return() + } + } +} + // EMIT_MIR gvn_repeat.repeat_place.GVN.diff #[custom_mir(dialect = "runtime")] pub fn repeat_place(mut idx1: usize, idx2: usize, val: &i32) -> i32 { @@ -29,7 +46,8 @@ pub fn repeat_place(mut idx1: usize, idx2: usize, val: &i32) -> i32 { #[custom_mir(dialect = "runtime")] pub fn repeat_local(mut idx1: usize, idx2: usize, val: i32) -> i32 { // CHECK-LABEL: fn repeat_local( - // CHECK: _0 = copy _3 + // CHECK: let mut [[ELEM:.*]]: &i32; + // CHECK: _0 = copy (*[[ELEM]]); mir! { let array; let elem; @@ -44,6 +62,7 @@ pub fn repeat_local(mut idx1: usize, idx2: usize, val: i32) -> i32 { } fn main() { + assert_eq!(index_place(0, 5, [0; 5]), 0); assert_eq!(repeat_place(0, 5, &0), 0); assert_eq!(repeat_local(0, 5, 0), 0); } diff --git a/tests/mir-opt/gvn_uninhabited.f.GVN.panic-abort.diff b/tests/mir-opt/gvn_uninhabited.f.GVN.panic-abort.diff index a3e4796d088e4..d377f35ee1c50 100644 --- a/tests/mir-opt/gvn_uninhabited.f.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn_uninhabited.f.GVN.panic-abort.diff @@ -9,7 +9,8 @@ let _4: U; let mut _5: &U; scope 1 { - debug i => _1; +- debug i => _1; ++ debug i => const 0_u32; } bb0: { diff --git a/tests/mir-opt/gvn_uninhabited.f.GVN.panic-unwind.diff b/tests/mir-opt/gvn_uninhabited.f.GVN.panic-unwind.diff index a3e4796d088e4..d377f35ee1c50 100644 --- a/tests/mir-opt/gvn_uninhabited.f.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn_uninhabited.f.GVN.panic-unwind.diff @@ -9,7 +9,8 @@ let _4: U; let mut _5: &U; scope 1 { - debug i => _1; +- debug i => _1; ++ debug i => const 0_u32; } bb0: { diff --git a/tests/mir-opt/optimize_none.rs b/tests/mir-opt/optimize_none.rs index a5b541bd2b628..030f74e5ec243 100644 --- a/tests/mir-opt/optimize_none.rs +++ b/tests/mir-opt/optimize_none.rs @@ -15,7 +15,8 @@ pub fn add_noopt() -> i32 { #[optimize(none)] pub fn const_branch() -> i32 { // CHECK-LABEL: fn const_branch( - // CHECK: switchInt(const true) -> [0: [[FALSE:bb[0-9]+]], otherwise: [[TRUE:bb[0-9]+]]]; + // CHECK: _1 = const true; + // CHECK: switchInt(move _1) -> [0: [[FALSE:bb[0-9]+]], otherwise: [[TRUE:bb[0-9]+]]]; // CHECK-NEXT: } // CHECK: [[FALSE]]: { // CHECK-NEXT: _0 = const 0 diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir index 18eeb8e4d3b61..c97c9b45d6ad5 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir @@ -17,7 +17,7 @@ fn checked_shl(_1: u32, _2: u32) -> Option { bb0: { StorageLive(_3); - _3 = Lt(copy _2, const core::num::::BITS); + _3 = Lt(copy _2, const 32_u32); switchInt(move _3) -> [0: bb1, otherwise: bb2]; } diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir index 18eeb8e4d3b61..c97c9b45d6ad5 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir @@ -17,7 +17,7 @@ fn checked_shl(_1: u32, _2: u32) -> Option { bb0: { StorageLive(_3); - _3 = Lt(copy _2, const core::num::::BITS); + _3 = Lt(copy _2, const 32_u32); switchInt(move _3) -> [0: bb1, otherwise: bb2]; } diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir index 83478e60b5d4e..7b681946bee1e 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir @@ -72,7 +72,7 @@ fn step_forward(_1: u16, _2: usize) -> u16 { } bb6: { - assert(!const true, "attempt to compute `{} + {}`, which would overflow", const core::num::::MAX, const 1_u16) -> [success: bb7, unwind unreachable]; + assert(!const true, "attempt to compute `{} + {}`, which would overflow", const u16::MAX, const 1_u16) -> [success: bb7, unwind unreachable]; } bb7: { diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir index ac7a6e0445191..a0137b23ec4f4 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir @@ -72,7 +72,7 @@ fn step_forward(_1: u16, _2: usize) -> u16 { } bb6: { - assert(!const true, "attempt to compute `{} + {}`, which would overflow", const core::num::::MAX, const 1_u16) -> [success: bb7, unwind continue]; + assert(!const true, "attempt to compute `{} + {}`, which would overflow", const u16::MAX, const 1_u16) -> [success: bb7, unwind continue]; } bb7: { diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff index 3f854b6cbcfbd..35315b6881e78 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff @@ -12,7 +12,8 @@ let mut _7: &std::alloc::Global; let mut _8: std::alloc::Layout; scope 1 { - debug layout => _1; +- debug layout => _1; ++ debug layout => const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}; let mut _9: &std::alloc::Global; scope 2 { debug ptr => _3; diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff index 15a9d9e39c491..1bd19409a2bfd 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff @@ -12,7 +12,8 @@ let mut _7: &std::alloc::Global; let mut _8: std::alloc::Layout; scope 1 { - debug layout => _1; +- debug layout => _1; ++ debug layout => const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}; let mut _9: &std::alloc::Global; scope 2 { debug ptr => _3; diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff index 1dbe9394e7094..48f227e5c3318 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff @@ -12,7 +12,8 @@ let mut _7: &std::alloc::Global; let mut _8: std::alloc::Layout; scope 1 { - debug layout => _1; +- debug layout => _1; ++ debug layout => const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}; let mut _9: &std::alloc::Global; scope 2 { debug ptr => _3; diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff index df008ececae30..06291947a453c 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff @@ -12,7 +12,8 @@ let mut _7: &std::alloc::Global; let mut _8: std::alloc::Layout; scope 1 { - debug layout => _1; +- debug layout => _1; ++ debug layout => const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}; let mut _9: &std::alloc::Global; scope 2 { debug ptr => _3; diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff index 5b39e45806e33..efaffb247f6d5 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff @@ -10,13 +10,16 @@ let mut _6: bool; let mut _8: u32; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 4_i32; let _3: i32; scope 2 { - debug y => _3; +- debug y => _3; ++ debug y => const 3_i32; let _7: u32; scope 3 { - debug z => _7; +- debug z => _7; ++ debug z => const 42_u32; } } } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff index ea2742a6471a1..5b4e7aeafa921 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff @@ -10,13 +10,16 @@ let mut _6: bool; let mut _8: u32; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 4_i32; let _3: i32; scope 2 { - debug y => _3; +- debug y => _3; ++ debug y => const 3_i32; let _7: u32; scope 3 { - debug z => _7; +- debug z => _7; ++ debug z => const 42_u32; } } } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff index 5b39e45806e33..efaffb247f6d5 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff @@ -10,13 +10,16 @@ let mut _6: bool; let mut _8: u32; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 4_i32; let _3: i32; scope 2 { - debug y => _3; +- debug y => _3; ++ debug y => const 3_i32; let _7: u32; scope 3 { - debug z => _7; +- debug z => _7; ++ debug z => const 42_u32; } } } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff index ea2742a6471a1..5b4e7aeafa921 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff @@ -10,13 +10,16 @@ let mut _6: bool; let mut _8: u32; scope 1 { - debug x => _1; +- debug x => _1; ++ debug x => const 4_i32; let _3: i32; scope 2 { - debug y => _3; +- debug y => _3; ++ debug y => const 3_i32; let _7: u32; scope 3 { - debug z => _7; +- debug z => _7; ++ debug z => const 42_u32; } } } diff --git a/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff b/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff index 9e798cbcac0c1..2f5ba3d616c0b 100644 --- a/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff +++ b/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff @@ -6,7 +6,8 @@ let mut _1: bool; let _2: bool; scope 1 { - debug x => _2; +- debug x => _2; ++ debug x => const false; } bb0: { diff --git a/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff b/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff index e243ff45ab0b2..fc4a64d921786 100644 --- a/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff @@ -6,7 +6,8 @@ let mut _1: bool; let _2: bool; scope 1 { - debug x => _2; +- debug x => _2; ++ debug x => const false; } bb0: { diff --git a/tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts.panic-abort.diff b/tests/mir-opt/single_use_consts.assign_const_to_return.GVN.panic-abort.diff similarity index 57% rename from tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts.panic-abort.diff rename to tests/mir-opt/single_use_consts.assign_const_to_return.GVN.panic-abort.diff index 8818c891e94b1..c3b880713b46a 100644 --- a/tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts.panic-abort.diff +++ b/tests/mir-opt/single_use_consts.assign_const_to_return.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `assign_const_to_return` before SingleUseConsts -+ // MIR for `assign_const_to_return` after SingleUseConsts +- // MIR for `assign_const_to_return` before GVN ++ // MIR for `assign_const_to_return` after GVN fn assign_const_to_return() -> bool { let mut _0: bool; diff --git a/tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts.panic-unwind.diff b/tests/mir-opt/single_use_consts.assign_const_to_return.GVN.panic-unwind.diff similarity index 57% rename from tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts.panic-unwind.diff rename to tests/mir-opt/single_use_consts.assign_const_to_return.GVN.panic-unwind.diff index 8818c891e94b1..c3b880713b46a 100644 --- a/tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts.panic-unwind.diff +++ b/tests/mir-opt/single_use_consts.assign_const_to_return.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `assign_const_to_return` before SingleUseConsts -+ // MIR for `assign_const_to_return` after SingleUseConsts +- // MIR for `assign_const_to_return` before GVN ++ // MIR for `assign_const_to_return` after GVN fn assign_const_to_return() -> bool { let mut _0: bool; diff --git a/tests/mir-opt/single_use_consts.if_const.SingleUseConsts.panic-abort.diff b/tests/mir-opt/single_use_consts.if_const.GVN.panic-abort.diff similarity index 75% rename from tests/mir-opt/single_use_consts.if_const.SingleUseConsts.panic-abort.diff rename to tests/mir-opt/single_use_consts.if_const.GVN.panic-abort.diff index 468076e5ee3ce..06fb7bee321a9 100644 --- a/tests/mir-opt/single_use_consts.if_const.SingleUseConsts.panic-abort.diff +++ b/tests/mir-opt/single_use_consts.if_const.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `if_const` before SingleUseConsts -+ // MIR for `if_const` after SingleUseConsts +- // MIR for `if_const` before GVN ++ // MIR for `if_const` after GVN fn if_const() -> i32 { let mut _0: i32; @@ -7,9 +7,8 @@ bb0: { StorageLive(_1); -- _1 = const ::ASSOC_BOOL; + _1 = const ::ASSOC_BOOL; - switchInt(move _1) -> [0: bb2, otherwise: bb1]; -+ nop; + switchInt(const ::ASSOC_BOOL) -> [0: bb2, otherwise: bb1]; } diff --git a/tests/mir-opt/single_use_consts.if_const.SingleUseConsts.panic-unwind.diff b/tests/mir-opt/single_use_consts.if_const.GVN.panic-unwind.diff similarity index 75% rename from tests/mir-opt/single_use_consts.if_const.SingleUseConsts.panic-unwind.diff rename to tests/mir-opt/single_use_consts.if_const.GVN.panic-unwind.diff index 468076e5ee3ce..06fb7bee321a9 100644 --- a/tests/mir-opt/single_use_consts.if_const.SingleUseConsts.panic-unwind.diff +++ b/tests/mir-opt/single_use_consts.if_const.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `if_const` before SingleUseConsts -+ // MIR for `if_const` after SingleUseConsts +- // MIR for `if_const` before GVN ++ // MIR for `if_const` after GVN fn if_const() -> i32 { let mut _0: i32; @@ -7,9 +7,8 @@ bb0: { StorageLive(_1); -- _1 = const ::ASSOC_BOOL; + _1 = const ::ASSOC_BOOL; - switchInt(move _1) -> [0: bb2, otherwise: bb1]; -+ nop; + switchInt(const ::ASSOC_BOOL) -> [0: bb2, otherwise: bb1]; } diff --git a/tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts.panic-abort.diff b/tests/mir-opt/single_use_consts.if_const_debug.GVN.panic-abort.diff similarity index 68% rename from tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts.panic-abort.diff rename to tests/mir-opt/single_use_consts.if_const_debug.GVN.panic-abort.diff index 0269c2cba202d..931edfdc683bf 100644 --- a/tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts.panic-abort.diff +++ b/tests/mir-opt/single_use_consts.if_const_debug.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `if_const_debug` before SingleUseConsts -+ // MIR for `if_const_debug` after SingleUseConsts +- // MIR for `if_const_debug` before GVN ++ // MIR for `if_const_debug` after GVN fn if_const_debug() -> i32 { let mut _0: i32; @@ -12,9 +12,9 @@ } bb0: { - StorageLive(_1); -- _1 = const ::ASSOC_BOOL; +- StorageLive(_1); + nop; + _1 = const ::ASSOC_BOOL; StorageLive(_2); _2 = do_whatever() -> [return: bb1, unwind unreachable]; } @@ -23,8 +23,9 @@ StorageDead(_2); StorageLive(_3); - _3 = copy _1; +- switchInt(move _3) -> [0: bb3, otherwise: bb2]; + _3 = const ::ASSOC_BOOL; - switchInt(move _3) -> [0: bb3, otherwise: bb2]; ++ switchInt(const ::ASSOC_BOOL) -> [0: bb3, otherwise: bb2]; } bb2: { @@ -39,7 +40,8 @@ bb4: { StorageDead(_3); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts.panic-unwind.diff b/tests/mir-opt/single_use_consts.if_const_debug.GVN.panic-unwind.diff similarity index 68% rename from tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts.panic-unwind.diff rename to tests/mir-opt/single_use_consts.if_const_debug.GVN.panic-unwind.diff index 1285b8b33ba2d..8105a484abe55 100644 --- a/tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts.panic-unwind.diff +++ b/tests/mir-opt/single_use_consts.if_const_debug.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `if_const_debug` before SingleUseConsts -+ // MIR for `if_const_debug` after SingleUseConsts +- // MIR for `if_const_debug` before GVN ++ // MIR for `if_const_debug` after GVN fn if_const_debug() -> i32 { let mut _0: i32; @@ -12,9 +12,9 @@ } bb0: { - StorageLive(_1); -- _1 = const ::ASSOC_BOOL; +- StorageLive(_1); + nop; + _1 = const ::ASSOC_BOOL; StorageLive(_2); _2 = do_whatever() -> [return: bb1, unwind continue]; } @@ -23,8 +23,9 @@ StorageDead(_2); StorageLive(_3); - _3 = copy _1; +- switchInt(move _3) -> [0: bb3, otherwise: bb2]; + _3 = const ::ASSOC_BOOL; - switchInt(move _3) -> [0: bb3, otherwise: bb2]; ++ switchInt(const ::ASSOC_BOOL) -> [0: bb3, otherwise: bb2]; } bb2: { @@ -39,7 +40,8 @@ bb4: { StorageDead(_3); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts.panic-abort.diff b/tests/mir-opt/single_use_consts.keep_parameter.GVN.panic-abort.diff similarity index 66% rename from tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts.panic-abort.diff rename to tests/mir-opt/single_use_consts.keep_parameter.GVN.panic-abort.diff index f7d823af9e3d7..5eb75bc5d0267 100644 --- a/tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts.panic-abort.diff +++ b/tests/mir-opt/single_use_consts.keep_parameter.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `keep_parameter` before SingleUseConsts -+ // MIR for `keep_parameter` after SingleUseConsts +- // MIR for `keep_parameter` before GVN ++ // MIR for `keep_parameter` after GVN fn keep_parameter(_1: i32) -> () { debug other => _1; diff --git a/tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts.panic-unwind.diff b/tests/mir-opt/single_use_consts.keep_parameter.GVN.panic-unwind.diff similarity index 66% rename from tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts.panic-unwind.diff rename to tests/mir-opt/single_use_consts.keep_parameter.GVN.panic-unwind.diff index f7d823af9e3d7..5eb75bc5d0267 100644 --- a/tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts.panic-unwind.diff +++ b/tests/mir-opt/single_use_consts.keep_parameter.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `keep_parameter` before SingleUseConsts -+ // MIR for `keep_parameter` after SingleUseConsts +- // MIR for `keep_parameter` before GVN ++ // MIR for `keep_parameter` after GVN fn keep_parameter(_1: i32) -> () { debug other => _1; diff --git a/tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-abort.diff b/tests/mir-opt/single_use_consts.match_const.GVN.panic-abort.diff similarity index 84% rename from tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-abort.diff rename to tests/mir-opt/single_use_consts.match_const.GVN.panic-abort.diff index 1ba5e47b81b65..22d574eb23e99 100644 --- a/tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-abort.diff +++ b/tests/mir-opt/single_use_consts.match_const.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `match_const` before SingleUseConsts -+ // MIR for `match_const` after SingleUseConsts +- // MIR for `match_const` before GVN ++ // MIR for `match_const` after GVN fn match_const() -> &str { let mut _0: &str; @@ -7,9 +7,8 @@ bb0: { StorageLive(_1); -- _1 = const ::ASSOC_INT; + _1 = const ::ASSOC_INT; - switchInt(copy _1) -> [7: bb3, 42: bb2, otherwise: bb1]; -+ nop; + switchInt(const ::ASSOC_INT) -> [7: bb3, 42: bb2, otherwise: bb1]; } diff --git a/tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-unwind.diff b/tests/mir-opt/single_use_consts.match_const.GVN.panic-unwind.diff similarity index 84% rename from tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-unwind.diff rename to tests/mir-opt/single_use_consts.match_const.GVN.panic-unwind.diff index 1ba5e47b81b65..22d574eb23e99 100644 --- a/tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-unwind.diff +++ b/tests/mir-opt/single_use_consts.match_const.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `match_const` before SingleUseConsts -+ // MIR for `match_const` after SingleUseConsts +- // MIR for `match_const` before GVN ++ // MIR for `match_const` after GVN fn match_const() -> &str { let mut _0: &str; @@ -7,9 +7,8 @@ bb0: { StorageLive(_1); -- _1 = const ::ASSOC_INT; + _1 = const ::ASSOC_INT; - switchInt(copy _1) -> [7: bb3, 42: bb2, otherwise: bb1]; -+ nop; + switchInt(const ::ASSOC_INT) -> [7: bb3, 42: bb2, otherwise: bb1]; } diff --git a/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-abort.diff b/tests/mir-opt/single_use_consts.match_const_debug.GVN.panic-abort.diff similarity index 87% rename from tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-abort.diff rename to tests/mir-opt/single_use_consts.match_const_debug.GVN.panic-abort.diff index e0fabe5a90e47..10c7f8fd7f38e 100644 --- a/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-abort.diff +++ b/tests/mir-opt/single_use_consts.match_const_debug.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `match_const_debug` before SingleUseConsts -+ // MIR for `match_const_debug` after SingleUseConsts +- // MIR for `match_const_debug` before GVN ++ // MIR for `match_const_debug` after GVN fn match_const_debug() -> &str { let mut _0: &str; @@ -12,8 +12,7 @@ bb0: { StorageLive(_1); -- _1 = const ::ASSOC_INT; -+ nop; + _1 = const ::ASSOC_INT; StorageLive(_2); _2 = do_whatever() -> [return: bb1, unwind unreachable]; } diff --git a/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-unwind.diff b/tests/mir-opt/single_use_consts.match_const_debug.GVN.panic-unwind.diff similarity index 87% rename from tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-unwind.diff rename to tests/mir-opt/single_use_consts.match_const_debug.GVN.panic-unwind.diff index 26799ae662938..b6936d5fe4e52 100644 --- a/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-unwind.diff +++ b/tests/mir-opt/single_use_consts.match_const_debug.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `match_const_debug` before SingleUseConsts -+ // MIR for `match_const_debug` after SingleUseConsts +- // MIR for `match_const_debug` before GVN ++ // MIR for `match_const_debug` after GVN fn match_const_debug() -> &str { let mut _0: &str; @@ -12,8 +12,7 @@ bb0: { StorageLive(_1); -- _1 = const ::ASSOC_INT; -+ nop; + _1 = const ::ASSOC_INT; StorageLive(_2); _2 = do_whatever() -> [return: bb1, unwind continue]; } diff --git a/tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts.panic-abort.diff b/tests/mir-opt/single_use_consts.never_used_debug.GVN.panic-abort.diff similarity index 64% rename from tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts.panic-abort.diff rename to tests/mir-opt/single_use_consts.never_used_debug.GVN.panic-abort.diff index 8ef94a790a343..f5f877414cb49 100644 --- a/tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts.panic-abort.diff +++ b/tests/mir-opt/single_use_consts.never_used_debug.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `never_used_debug` before SingleUseConsts -+ // MIR for `never_used_debug` after SingleUseConsts +- // MIR for `never_used_debug` before GVN ++ // MIR for `never_used_debug` after GVN fn never_used_debug() -> () { let mut _0: (); @@ -11,8 +11,7 @@ bb0: { StorageLive(_1); -- _1 = const ::ASSOC_INT; -+ nop; + _1 = const ::ASSOC_INT; _0 = const (); StorageDead(_1); return; diff --git a/tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts.panic-unwind.diff b/tests/mir-opt/single_use_consts.never_used_debug.GVN.panic-unwind.diff similarity index 64% rename from tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts.panic-unwind.diff rename to tests/mir-opt/single_use_consts.never_used_debug.GVN.panic-unwind.diff index 8ef94a790a343..f5f877414cb49 100644 --- a/tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts.panic-unwind.diff +++ b/tests/mir-opt/single_use_consts.never_used_debug.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `never_used_debug` before SingleUseConsts -+ // MIR for `never_used_debug` after SingleUseConsts +- // MIR for `never_used_debug` before GVN ++ // MIR for `never_used_debug` after GVN fn never_used_debug() -> () { let mut _0: (); @@ -11,8 +11,7 @@ bb0: { StorageLive(_1); -- _1 = const ::ASSOC_INT; -+ nop; + _1 = const ::ASSOC_INT; _0 = const (); StorageDead(_1); return; diff --git a/tests/mir-opt/single_use_consts.rs b/tests/mir-opt/single_use_consts.rs index ecb602c647a50..a4bf9a721d2f5 100644 --- a/tests/mir-opt/single_use_consts.rs +++ b/tests/mir-opt/single_use_consts.rs @@ -1,4 +1,4 @@ -//@ test-mir-pass: SingleUseConsts +//@ test-mir-pass: GVN //@ compile-flags: -C debuginfo=full // EMIT_MIR_FOR_EACH_PANIC_STRATEGY @@ -7,14 +7,14 @@ trait MyTrait { const ASSOC_INT: i32; } -// EMIT_MIR single_use_consts.if_const.SingleUseConsts.diff +// EMIT_MIR single_use_consts.if_const.GVN.diff fn if_const() -> i32 { // CHECK-LABEL: fn if_const( // CHECK: switchInt(const ::ASSOC_BOOL) if T::ASSOC_BOOL { 7 } else { 42 } } -// EMIT_MIR single_use_consts.match_const.SingleUseConsts.diff +// EMIT_MIR single_use_consts.match_const.GVN.diff fn match_const() -> &'static str { // CHECK-LABEL: fn match_const( // CHECK: switchInt(const ::ASSOC_INT) @@ -25,22 +25,20 @@ fn match_const() -> &'static str { } } -// EMIT_MIR single_use_consts.if_const_debug.SingleUseConsts.diff +// EMIT_MIR single_use_consts.if_const_debug.GVN.diff fn if_const_debug() -> i32 { // CHECK-LABEL: fn if_const_debug( - // CHECK: my_bool => const ::ASSOC_BOOL; - // FIXME: `if` forces a temporary (unlike `match`), so the const isn't direct - // CHECK: _3 = const ::ASSOC_BOOL; - // CHECK: switchInt(move _3) + // CHECK: debug my_bool => const ::ASSOC_BOOL; + // CHECK: switchInt(const ::ASSOC_BOOL) let my_bool = T::ASSOC_BOOL; do_whatever(); if my_bool { 7 } else { 42 } } -// EMIT_MIR single_use_consts.match_const_debug.SingleUseConsts.diff +// EMIT_MIR single_use_consts.match_const_debug.GVN.diff fn match_const_debug() -> &'static str { // CHECK-LABEL: fn match_const_debug( - // CHECK: my_int => const ::ASSOC_INT; + // CHECK: debug my_int => const ::ASSOC_INT; // CHECK: switchInt(const ::ASSOC_INT) let my_int = T::ASSOC_INT; do_whatever(); @@ -51,25 +49,22 @@ fn match_const_debug() -> &'static str { } } -// EMIT_MIR single_use_consts.never_used_debug.SingleUseConsts.diff +// EMIT_MIR single_use_consts.never_used_debug.GVN.diff #[allow(unused_variables)] fn never_used_debug() { // CHECK-LABEL: fn never_used_debug( - // CHECK: my_int => const ::ASSOC_INT; - // CHECK-NOT: ASSOC_INT - // CHECK: nop - // CHECK-NOT: ASSOC_INT + // CHECK: debug my_int => const ::ASSOC_INT; let my_int = T::ASSOC_INT; } -// EMIT_MIR single_use_consts.assign_const_to_return.SingleUseConsts.diff +// EMIT_MIR single_use_consts.assign_const_to_return.GVN.diff fn assign_const_to_return() -> bool { // CHECK-LABEL: fn assign_const_to_return( // CHECK: _0 = const ::ASSOC_BOOL; T::ASSOC_BOOL } -// EMIT_MIR single_use_consts.keep_parameter.SingleUseConsts.diff +// EMIT_MIR single_use_consts.keep_parameter.GVN.diff fn keep_parameter(mut other: i32) { // CHECK-LABEL: fn keep_parameter( // CHECK: _1 = const ::ASSOC_INT;

AltStyle によって変換されたページ (->オリジナル) /