diff --git a/src/librustc_mir/interpret/intern.rs b/src/librustc_mir/interpret/intern.rs index 02a7f24a1e351..4c1cf1b56ae66 100644 --- a/src/librustc_mir/interpret/intern.rs +++ b/src/librustc_mir/interpret/intern.rs @@ -294,7 +294,6 @@ pub enum InternKind { Static(hir::Mutability), Constant, Promoted, - ConstProp, } /// Intern `ret` and everything it references. @@ -315,9 +314,7 @@ pub fn intern_const_alloc_recursive>( let base_intern_mode = match intern_kind { InternKind::Static(mutbl) => InternMode::Static(mutbl), // FIXME: what about array lengths, array initializers? - InternKind::Constant | InternKind::ConstProp | InternKind::Promoted => { - InternMode::ConstBase - } + InternKind::Constant | InternKind::Promoted => InternMode::ConstBase, }; // Type based interning. @@ -359,7 +356,10 @@ pub fn intern_const_alloc_recursive>( Err(error) => { ecx.tcx.sess.delay_span_bug( ecx.tcx.span, - "error during interning should later cause validation failure", + &format!( + "error during interning should later cause validation failure: {}", + error + ), ); // Some errors shouldn't come up because creating them causes // an allocation, which we should avoid. When that happens, @@ -400,7 +400,7 @@ pub fn intern_const_alloc_recursive>( // immutability is so important. alloc.mutability = Mutability::Not; } - InternKind::Constant | InternKind::ConstProp => { + InternKind::Constant => { // If it's a constant, we should not have any "leftovers" as everything // is tracked by const-checking. // FIXME: downgrade this to a warning? It rejects some legitimate consts, diff --git a/src/librustc_mir/interpret/step.rs b/src/librustc_mir/interpret/step.rs index bd4df788057e2..0e96f782e3c5e 100644 --- a/src/librustc_mir/interpret/step.rs +++ b/src/librustc_mir/interpret/step.rs @@ -74,7 +74,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { Ok(true) } - fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> { + crate fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> { info!("{:?}", stmt); self.set_span(stmt.source_info.span); diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 92000e6411354..43ae5bc33f947 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -27,9 +27,9 @@ use rustc_trait_selection::traits; use crate::const_eval::error_to_const_error; use crate::interpret::{ - self, compile_time_machine, intern_const_alloc_recursive, AllocId, Allocation, Frame, ImmTy, - Immediate, InternKind, InterpCx, LocalState, LocalValue, Memory, MemoryKind, OpTy, - Operand as InterpOperand, PlaceTy, Pointer, ScalarMaybeUninit, StackPopCleanup, + self, compile_time_machine, AllocId, Allocation, Frame, ImmTy, Immediate, InterpCx, LocalState, + LocalValue, Memory, MemoryKind, OpTy, Operand as InterpOperand, PlaceTy, Pointer, + ScalarMaybeUninit, StackPopCleanup, }; use crate::transform::{MirPass, MirSource}; @@ -381,6 +381,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { match f(self) { Ok(val) => Some(val), Err(error) => { + trace!("InterpCx operation failed: {:?}", error); // Some errors shouldn't come up because creating them causes // an allocation, which we should avoid. When that happens, // dedicated error variants should be introduced instead. @@ -707,11 +708,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { ScalarMaybeUninit::Scalar(l), ScalarMaybeUninit::Scalar(r), )) => l.is_bits() && r.is_bits(), - interpret::Operand::Indirect(_) if mir_opt_level >= 2 => { - let mplace = op.assert_mem_place(&self.ecx); - intern_const_alloc_recursive(&mut self.ecx, InternKind::ConstProp, mplace, false); - true - } + interpret::Operand::Indirect(_) if mir_opt_level >= 2 => true, _ => false, } } @@ -793,10 +790,11 @@ impl<'tcx> Visitor<'tcx> for CanConstProp { // end of the block anyway, and inside the block we overwrite previous // states as applicable. ConstPropMode::OnlyInsideOwnBlock => {} + mode @ ConstPropMode::FullConstProp => *mode = ConstPropMode::OnlyInsideOwnBlock, other => { trace!( - "local {:?} can't be propagated because of multiple assignments", - local, + "local {:?} can't be propagated because of multiple assignments. Previous state: {:?}", + local, other, ); *other = ConstPropMode::NoPropagation; } @@ -909,6 +907,9 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> { } } else { match statement.kind { + StatementKind::SetDiscriminant { .. } => { + self.use_ecx(|this| this.ecx.statement(statement)); + } StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => { let frame = self.ecx.frame_mut(); frame.locals[local].value = diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index 26725a2ac02d5..d99f29ebf8a2e 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -318,6 +318,9 @@ fn run_optimization_passes<'tcx>( // but before optimizations begin. &add_retag::AddRetag, &simplify::SimplifyCfg::new("elaborate-drops"), + // `Deaggregator` is conceptually part of MIR building, some backends rely on it happening + // and it can help optimizations. + &deaggregator::Deaggregator, // No lifetime analysis based on borrowing can be done from here on out. ]; @@ -334,11 +337,6 @@ fn run_optimization_passes<'tcx>( &instcombine::InstCombine, &const_prop::ConstProp, &simplify_branches::SimplifyBranches::new("after-const-prop"), - // Run deaggregation here because: - // 1. Some codegen backends require it - // 2. It creates additional possibilities for some MIR optimizations to trigger - // FIXME(#70073): Why is this done here and not in `post_borrowck_cleanup`? - &deaggregator::Deaggregator, &simplify_try::SimplifyArmIdentity, &simplify_try::SimplifyBranchSame, ©_prop::CopyPropagation, @@ -355,9 +353,6 @@ fn run_optimization_passes<'tcx>( &generator::StateTransform, // FIXME(#70073): This pass is responsible for both optimization as well as some lints. &const_prop::ConstProp, - // Even if we don't do optimizations, still run deaggregation because some backends assume - // that deaggregation always occurs. - &deaggregator::Deaggregator, ]; let pre_codegen_cleanup: &[&dyn MirPass<'tcx>] = &[ diff --git a/src/test/codegen/consts.rs b/src/test/codegen/consts.rs index ed93af2f993d3..318f9b0eec3a9 100644 --- a/src/test/codegen/consts.rs +++ b/src/test/codegen/consts.rs @@ -10,11 +10,11 @@ // CHECK: @STATIC = {{.*}}, align 4 // This checks the constants from inline_enum_const -// CHECK: @alloc7 = {{.*}}, align 2 +// CHECK: @alloc8 = {{.*}}, align 2 // This checks the constants from {low,high}_align_const, they share the same // constant, but the alignment differs, so the higher one should be used -// CHECK: [[LOW_HIGH:@[0-9]+]] = {{.*}} getelementptr inbounds (<{ [8 x i8] }>, <{ [8 x i8] }>* @alloc19, i32 0, i32 0, i32 0), {{.*}} +// CHECK: [[LOW_HIGH:@[0-9]+]] = {{.*}} getelementptr inbounds (<{ [8 x i8] }>, <{ [8 x i8] }>* @alloc20, i32 0, i32 0, i32 0), {{.*}} #[derive(Copy, Clone)] // repr(i16) is required for the {low,high}_align_const test diff --git a/src/test/mir-opt/const_prop/aggregate/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/aggregate/rustc.main.ConstProp.diff index f4b6c7db444e5..501131bd597e4 100644 --- a/src/test/mir-opt/const_prop/aggregate/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/aggregate/rustc.main.ConstProp.diff @@ -14,19 +14,21 @@ StorageLive(_1); // scope 0 at $DIR/aggregate.rs:5:9: 5:10 StorageLive(_2); // scope 0 at $DIR/aggregate.rs:5:13: 5:24 StorageLive(_3); // scope 0 at $DIR/aggregate.rs:5:13: 5:22 - _3 = (const 0i32, const 1i32, const 2i32); // scope 0 at $DIR/aggregate.rs:5:13: 5:22 + (_3.0: i32) = const 0i32; // scope 0 at $DIR/aggregate.rs:5:13: 5:22 // ty::Const // + ty: i32 // + val: Value(Scalar(0x00000000)) // mir::Constant // + span: $DIR/aggregate.rs:5:14: 5:15 // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + (_3.1: i32) = const 1i32; // scope 0 at $DIR/aggregate.rs:5:13: 5:22 // ty::Const // + ty: i32 // + val: Value(Scalar(0x00000001)) // mir::Constant // + span: $DIR/aggregate.rs:5:17: 5:18 // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + (_3.2: i32) = const 2i32; // scope 0 at $DIR/aggregate.rs:5:13: 5:22 // ty::Const // + ty: i32 // + val: Value(Scalar(0x00000002)) diff --git a/src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff index 9979ea9549891..250647811580f 100644 --- a/src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff @@ -15,19 +15,16 @@ StorageLive(_1); // scope 0 at $DIR/discriminant.rs:6:9: 6:10 StorageLive(_2); // scope 0 at $DIR/discriminant.rs:6:13: 6:64 StorageLive(_3); // scope 0 at $DIR/discriminant.rs:6:34: 6:44 -- _3 = std::option::Option::::Some(const true); // scope 0 at $DIR/discriminant.rs:6:34: 6:44 -+ _3 = const std::option::Option::::Some(true); // scope 0 at $DIR/discriminant.rs:6:34: 6:44 + ((_3 as Some).0: bool) = const true; // scope 0 at $DIR/discriminant.rs:6:34: 6:44 // ty::Const -- // + ty: bool -+ // + ty: std::option::Option + // + ty: bool // + val: Value(Scalar(0x01)) // mir::Constant -- // + span: $DIR/discriminant.rs:6:39: 6:43 -- // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + // + span: $DIR/discriminant.rs:6:39: 6:43 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + discriminant(_3) = 1; // scope 0 at $DIR/discriminant.rs:6:34: 6:44 - _4 = discriminant(_3); // scope 0 at $DIR/discriminant.rs:6:21: 6:31 - switchInt(move _4) -> [1isize: bb2, otherwise: bb1]; // scope 0 at $DIR/discriminant.rs:6:21: 6:31 -+ // + span: $DIR/discriminant.rs:6:34: 6:44 -+ // + literal: Const { ty: std::option::Option, val: Value(Scalar(0x01)) } + _4 = const 1isize; // scope 0 at $DIR/discriminant.rs:6:21: 6:31 + // ty::Const + // + ty: isize @@ -56,14 +53,7 @@ } bb2: { -- switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:6:26: 6:30 -+ switchInt(const true) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:6:26: 6:30 -+ // ty::Const -+ // + ty: bool -+ // + val: Value(Scalar(0x01)) -+ // mir::Constant -+ // + span: $DIR/discriminant.rs:6:26: 6:30 -+ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:6:26: 6:30 } bb3: { diff --git a/src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff index ec0341e3de251..13008c439f3f4 100644 --- a/src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff @@ -15,19 +15,16 @@ StorageLive(_1); // scope 0 at $DIR/discriminant.rs:6:9: 6:10 StorageLive(_2); // scope 0 at $DIR/discriminant.rs:6:13: 6:64 StorageLive(_3); // scope 0 at $DIR/discriminant.rs:6:34: 6:44 -- _3 = std::option::Option::::Some(const true); // scope 0 at $DIR/discriminant.rs:6:34: 6:44 -+ _3 = const std::option::Option::::Some(true); // scope 0 at $DIR/discriminant.rs:6:34: 6:44 + ((_3 as Some).0: bool) = const true; // scope 0 at $DIR/discriminant.rs:6:34: 6:44 // ty::Const -- // + ty: bool -+ // + ty: std::option::Option + // + ty: bool // + val: Value(Scalar(0x01)) // mir::Constant -- // + span: $DIR/discriminant.rs:6:39: 6:43 -- // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + // + span: $DIR/discriminant.rs:6:39: 6:43 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + discriminant(_3) = 1; // scope 0 at $DIR/discriminant.rs:6:34: 6:44 - _4 = discriminant(_3); // scope 0 at $DIR/discriminant.rs:6:21: 6:31 - switchInt(move _4) -> [1isize: bb2, otherwise: bb1]; // scope 0 at $DIR/discriminant.rs:6:21: 6:31 -+ // + span: $DIR/discriminant.rs:6:34: 6:44 -+ // + literal: Const { ty: std::option::Option, val: Value(Scalar(0x01)) } + _4 = const 1isize; // scope 0 at $DIR/discriminant.rs:6:21: 6:31 + // ty::Const + // + ty: isize @@ -56,14 +53,7 @@ } bb2: { -- switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:6:26: 6:30 -+ switchInt(const true) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:6:26: 6:30 -+ // ty::Const -+ // + ty: bool -+ // + val: Value(Scalar(0x01)) -+ // mir::Constant -+ // + span: $DIR/discriminant.rs:6:26: 6:30 -+ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:6:26: 6:30 } bb3: { diff --git a/src/test/mir-opt/const_prop/issue-66971/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/issue-66971/rustc.main.ConstProp.diff index c26494bdc1042..f3088cd34eac0 100644 --- a/src/test/mir-opt/const_prop/issue-66971/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/issue-66971/rustc.main.ConstProp.diff @@ -11,21 +11,22 @@ StorageLive(_1); // scope 0 at $DIR/issue-66971.rs:16:5: 16:23 StorageLive(_2); // scope 0 at $DIR/issue-66971.rs:16:12: 16:22 StorageLive(_3); // scope 0 at $DIR/issue-66971.rs:16:13: 16:15 -- _3 = (); // scope 0 at $DIR/issue-66971.rs:16:13: 16:15 -+ _3 = const (); // scope 0 at $DIR/issue-66971.rs:16:13: 16:15 +- (_2.0: ()) = move _3; // scope 0 at $DIR/issue-66971.rs:16:12: 16:22 ++ (_2.0: ()) = const (); // scope 0 at $DIR/issue-66971.rs:16:12: 16:22 + // ty::Const + // + ty: () + // + val: Value(Scalar()) + // mir::Constant -+ // + span: $DIR/issue-66971.rs:16:13: 16:15 ++ // + span: $DIR/issue-66971.rs:16:12: 16:22 + // + literal: Const { ty: (), val: Value(Scalar()) } - _2 = (move _3, const 0u8, const 0u8); // scope 0 at $DIR/issue-66971.rs:16:12: 16:22 + (_2.1: u8) = const 0u8; // scope 0 at $DIR/issue-66971.rs:16:12: 16:22 // ty::Const // + ty: u8 // + val: Value(Scalar(0x00)) // mir::Constant // + span: $DIR/issue-66971.rs:16:17: 16:18 // + literal: Const { ty: u8, val: Value(Scalar(0x00)) } + (_2.2: u8) = const 0u8; // scope 0 at $DIR/issue-66971.rs:16:12: 16:22 // ty::Const // + ty: u8 // + val: Value(Scalar(0x00)) diff --git a/src/test/mir-opt/const_prop/issue-67019/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/issue-67019/rustc.main.ConstProp.diff index e328febb407ae..aa53d3055c3c7 100644 --- a/src/test/mir-opt/const_prop/issue-67019/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/issue-67019/rustc.main.ConstProp.diff @@ -11,22 +11,34 @@ StorageLive(_1); // scope 0 at $DIR/issue-67019.rs:11:5: 11:20 StorageLive(_2); // scope 0 at $DIR/issue-67019.rs:11:10: 11:19 StorageLive(_3); // scope 0 at $DIR/issue-67019.rs:11:11: 11:17 - _3 = (const 1u8, const 2u8); // scope 0 at $DIR/issue-67019.rs:11:11: 11:17 + (_3.0: u8) = const 1u8; // scope 0 at $DIR/issue-67019.rs:11:11: 11:17 // ty::Const // + ty: u8 // + val: Value(Scalar(0x01)) // mir::Constant -- // + span: $DIR/issue-67019.rs:11:12: 11:13 -+ // + span: $DIR/issue-67019.rs:11:11: 11:17 + // + span: $DIR/issue-67019.rs:11:12: 11:13 // + literal: Const { ty: u8, val: Value(Scalar(0x01)) } + (_3.1: u8) = const 2u8; // scope 0 at $DIR/issue-67019.rs:11:11: 11:17 // ty::Const // + ty: u8 // + val: Value(Scalar(0x02)) // mir::Constant -- // + span: $DIR/issue-67019.rs:11:15: 11:16 -+ // + span: $DIR/issue-67019.rs:11:11: 11:17 + // + span: $DIR/issue-67019.rs:11:15: 11:16 // + literal: Const { ty: u8, val: Value(Scalar(0x02)) } - _2 = (move _3,); // scope 0 at $DIR/issue-67019.rs:11:10: 11:19 +- (_2.0: (u8, u8)) = move _3; // scope 0 at $DIR/issue-67019.rs:11:10: 11:19 ++ (_2.0: (u8, u8)) = (const 1u8, const 2u8); // scope 0 at $DIR/issue-67019.rs:11:10: 11:19 ++ // ty::Const ++ // + ty: u8 ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/issue-67019.rs:11:10: 11:19 ++ // + literal: Const { ty: u8, val: Value(Scalar(0x01)) } ++ // ty::Const ++ // + ty: u8 ++ // + val: Value(Scalar(0x02)) ++ // mir::Constant ++ // + span: $DIR/issue-67019.rs:11:10: 11:19 ++ // + literal: Const { ty: u8, val: Value(Scalar(0x02)) } StorageDead(_3); // scope 0 at $DIR/issue-67019.rs:11:18: 11:19 _1 = const test(move _2) -> bb1; // scope 0 at $DIR/issue-67019.rs:11:5: 11:20 // ty::Const diff --git a/src/test/mir-opt/const_prop/mutable_variable_aggregate/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_aggregate/rustc.main.ConstProp.diff index cf432b2acc1c5..7a1e21fcdb575 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_aggregate/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_aggregate/rustc.main.ConstProp.diff @@ -14,20 +14,19 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:5:9: 5:14 - _1 = (const 42i32, const 43i32); // scope 0 at $DIR/mutable_variable_aggregate.rs:5:17: 5:25 + (_1.0: i32) = const 42i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:5:17: 5:25 // ty::Const // + ty: i32 // + val: Value(Scalar(0x0000002a)) // mir::Constant -- // + span: $DIR/mutable_variable_aggregate.rs:5:18: 5:20 -+ // + span: $DIR/mutable_variable_aggregate.rs:5:17: 5:25 + // + span: $DIR/mutable_variable_aggregate.rs:5:18: 5:20 // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) } + (_1.1: i32) = const 43i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:5:17: 5:25 // ty::Const // + ty: i32 // + val: Value(Scalar(0x0000002b)) // mir::Constant -- // + span: $DIR/mutable_variable_aggregate.rs:5:22: 5:24 -+ // + span: $DIR/mutable_variable_aggregate.rs:5:17: 5:25 + // + span: $DIR/mutable_variable_aggregate.rs:5:22: 5:24 // + literal: Const { ty: i32, val: Value(Scalar(0x0000002b)) } (_1.1: i32) = const 99i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:6:5: 6:13 // ty::Const diff --git a/src/test/mir-opt/const_prop/mutable_variable_aggregate_mut_ref/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_aggregate_mut_ref/rustc.main.ConstProp.diff index 44203ac327ab1..44c330212d37b 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_aggregate_mut_ref/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_aggregate_mut_ref/rustc.main.ConstProp.diff @@ -18,13 +18,14 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:5:9: 5:14 - _1 = (const 42i32, const 43i32); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:5:17: 5:25 + (_1.0: i32) = const 42i32; // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:5:17: 5:25 // ty::Const // + ty: i32 // + val: Value(Scalar(0x0000002a)) // mir::Constant // + span: $DIR/mutable_variable_aggregate_mut_ref.rs:5:18: 5:20 // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) } + (_1.1: i32) = const 43i32; // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:5:17: 5:25 // ty::Const // + ty: i32 // + val: Value(Scalar(0x0000002b)) diff --git a/src/test/mir-opt/const_prop/mutable_variable_unprop_assign/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_unprop_assign/rustc.main.ConstProp.diff index e0b9fbe04c387..09f282e1ea315 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_unprop_assign/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_unprop_assign/rustc.main.ConstProp.diff @@ -34,20 +34,19 @@ bb1: { StorageLive(_2); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:6:9: 6:14 - _2 = (const 1i32, const 2i32); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:6:29: 6:35 + (_2.0: i32) = const 1i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:6:29: 6:35 // ty::Const // + ty: i32 // + val: Value(Scalar(0x00000001)) // mir::Constant -- // + span: $DIR/mutable_variable_unprop_assign.rs:6:30: 6:31 -+ // + span: $DIR/mutable_variable_unprop_assign.rs:6:29: 6:35 + // + span: $DIR/mutable_variable_unprop_assign.rs:6:30: 6:31 // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + (_2.1: i32) = const 2i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:6:29: 6:35 // ty::Const // + ty: i32 // + val: Value(Scalar(0x00000002)) // mir::Constant -- // + span: $DIR/mutable_variable_unprop_assign.rs:6:33: 6:34 -+ // + span: $DIR/mutable_variable_unprop_assign.rs:6:29: 6:35 + // + span: $DIR/mutable_variable_unprop_assign.rs:6:33: 6:34 // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } StorageLive(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:7:11: 7:12 _3 = _1; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:7:11: 7:12 diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.ConstProp.diff index 9bd9bfa9f2796..c8097758b6d69 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.ConstProp.diff @@ -149,13 +149,14 @@ StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35 StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36 - _9 = Point { x: const 12u32, y: const 42u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36 + (_9.0: u32) = const 12u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36 // ty::Const // + ty: u32 // + val: Value(Scalar(0x0000000c)) // mir::Constant // + span: $DIR/optimizes_into_variable.rs:14:25: 14:27 // + literal: Const { ty: u32, val: Value(Scalar(0x0000000c)) } + (_9.1: u32) = const 42u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36 // ty::Const // + ty: u32 // + val: Value(Scalar(0x0000002a)) diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.ConstProp.diff index 1da763ec9558a..cea6ad7d318a4 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.ConstProp.diff @@ -149,13 +149,14 @@ StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35 StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36 - _9 = Point { x: const 12u32, y: const 42u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36 + (_9.0: u32) = const 12u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36 // ty::Const // + ty: u32 // + val: Value(Scalar(0x0000000c)) // mir::Constant // + span: $DIR/optimizes_into_variable.rs:14:25: 14:27 // + literal: Const { ty: u32, val: Value(Scalar(0x0000000c)) } + (_9.1: u32) = const 42u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36 // ty::Const // + ty: u32 // + val: Value(Scalar(0x0000002a)) diff --git a/src/test/mir-opt/const_prop/tuple_literal_propagation/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/tuple_literal_propagation/rustc.main.ConstProp.diff index 1511b361f587f..450e8bb511599 100644 --- a/src/test/mir-opt/const_prop/tuple_literal_propagation/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/tuple_literal_propagation/rustc.main.ConstProp.diff @@ -12,20 +12,19 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:3:9: 3:10 - _1 = (const 1u32, const 2u32); // scope 0 at $DIR/tuple_literal_propagation.rs:3:13: 3:19 + (_1.0: u32) = const 1u32; // scope 0 at $DIR/tuple_literal_propagation.rs:3:13: 3:19 // ty::Const // + ty: u32 // + val: Value(Scalar(0x00000001)) // mir::Constant -- // + span: $DIR/tuple_literal_propagation.rs:3:14: 3:15 -+ // + span: $DIR/tuple_literal_propagation.rs:3:13: 3:19 + // + span: $DIR/tuple_literal_propagation.rs:3:14: 3:15 // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + (_1.1: u32) = const 2u32; // scope 0 at $DIR/tuple_literal_propagation.rs:3:13: 3:19 // ty::Const // + ty: u32 // + val: Value(Scalar(0x00000002)) // mir::Constant -- // + span: $DIR/tuple_literal_propagation.rs:3:17: 3:18 -+ // + span: $DIR/tuple_literal_propagation.rs:3:13: 3:19 + // + span: $DIR/tuple_literal_propagation.rs:3:17: 3:18 // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } StorageLive(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:5:5: 5:15 StorageLive(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:5:13: 5:14 diff --git a/src/test/mir-opt/generator-storage-dead-unwind/rustc.main-{{closure}}.StateTransform.before.mir b/src/test/mir-opt/generator-storage-dead-unwind/rustc.main-{{closure}}.StateTransform.before.mir index e9e977a611b19..acf0029791947 100644 --- a/src/test/mir-opt/generator-storage-dead-unwind/rustc.main-{{closure}}.StateTransform.before.mir +++ b/src/test/mir-opt/generator-storage-dead-unwind/rustc.main-{{closure}}.StateTransform.before.mir @@ -21,7 +21,7 @@ yields () bb0: { StorageLive(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:23:13: 23:14 - _3 = Foo(const 5i32); // scope 0 at $DIR/generator-storage-dead-unwind.rs:23:17: 23:23 + (_3.0: i32) = const 5i32; // scope 0 at $DIR/generator-storage-dead-unwind.rs:23:17: 23:23 // ty::Const // + ty: i32 // + val: Value(Scalar(0x00000005)) @@ -29,7 +29,7 @@ yields () // + span: $DIR/generator-storage-dead-unwind.rs:23:21: 23:22 // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) } StorageLive(_4); // scope 1 at $DIR/generator-storage-dead-unwind.rs:24:13: 24:14 - _4 = Bar(const 6i32); // scope 1 at $DIR/generator-storage-dead-unwind.rs:24:17: 24:23 + (_4.0: i32) = const 6i32; // scope 1 at $DIR/generator-storage-dead-unwind.rs:24:17: 24:23 // ty::Const // + ty: i32 // + val: Value(Scalar(0x00000006)) @@ -38,7 +38,6 @@ yields () // + literal: Const { ty: i32, val: Value(Scalar(0x00000006)) } StorageLive(_5); // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14 StorageLive(_6); // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14 - _6 = (); // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14 _5 = yield(move _6) -> [resume: bb1, drop: bb5]; // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14 } diff --git a/src/test/mir-opt/generator-tiny/rustc.main-{{closure}}.generator_resume.0.mir b/src/test/mir-opt/generator-tiny/rustc.main-{{closure}}.generator_resume.0.mir index c73dea5f8fde6..c777a03524b17 100644 --- a/src/test/mir-opt/generator-tiny/rustc.main-{{closure}}.generator_resume.0.mir +++ b/src/test/mir-opt/generator-tiny/rustc.main-{{closure}}.generator_resume.0.mir @@ -1,5 +1,5 @@ // MIR for `main::{{closure}}#0` 0 generator_resume -// generator_layout = GeneratorLayout { field_tys: [HasDrop], variant_fields: [[], [], [], [_0]], storage_conflicts: BitMatrix { num_rows: 1, num_columns: 1, words: [1], marker: PhantomData } } +// generator_layout = GeneratorLayout { field_tys: [], variant_fields: [[], [], [], []], storage_conflicts: BitMatrix { num_rows: 0, num_columns: 0, words: [], marker: PhantomData } } fn main::{{closure}}#0(_1: std::pin::Pin<&mut [generator@$DIR/generator-tiny.rs:19:16: 25:6 {u8, HasDrop, ()}]>, _2: u8) -> std::ops::GeneratorState<(), ()> { debug _x => _10; // in scope 0 at $DIR/generator-tiny.rs:19:17: 19:19 @@ -14,7 +14,7 @@ fn main::{{closure}}#0(_1: std::pin::Pin<&mut [generator@$DIR/generator-tiny.rs: let _10: u8; // in scope 0 at $DIR/generator-tiny.rs:19:17: 19:19 let mut _11: u32; // in scope 0 at $DIR/generator-tiny.rs:19:16: 25:6 scope 1 { - debug _d => (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6 {u8, HasDrop, ()}])) as variant#3).0: HasDrop); // in scope 1 at $DIR/generator-tiny.rs:20:13: 20:15 + debug _d => _3; // in scope 1 at $DIR/generator-tiny.rs:20:13: 20:15 } bb0: { @@ -24,8 +24,7 @@ fn main::{{closure}}#0(_1: std::pin::Pin<&mut [generator@$DIR/generator-tiny.rs: bb1: { _10 = move _2; // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6 - nop; // scope 0 at $DIR/generator-tiny.rs:20:13: 20:15 - (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6 {u8, HasDrop, ()}])) as variant#3).0: HasDrop) = HasDrop; // scope 0 at $DIR/generator-tiny.rs:20:18: 20:25 + StorageLive(_3); // scope 0 at $DIR/generator-tiny.rs:20:13: 20:15 StorageLive(_4); // scope 1 at $DIR/generator-tiny.rs:21:9: 24:10 goto -> bb2; // scope 1 at $DIR/generator-tiny.rs:21:9: 24:10 } @@ -33,7 +32,6 @@ fn main::{{closure}}#0(_1: std::pin::Pin<&mut [generator@$DIR/generator-tiny.rs: bb2: { StorageLive(_6); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18 StorageLive(_7); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18 - _7 = (); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18 _0 = std::ops::GeneratorState::<(), ()>::Yielded(move _7); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18 discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6 {u8, HasDrop, ()}]))) = 3; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18 return; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18 @@ -65,6 +63,7 @@ fn main::{{closure}}#0(_1: std::pin::Pin<&mut [generator@$DIR/generator-tiny.rs: } bb5: { + StorageLive(_3); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6 StorageLive(_4); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6 StorageLive(_6); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6 StorageLive(_7); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6 diff --git a/src/test/mir-opt/inline/inline-closure-borrows-arg/rustc.foo.Inline.after.mir b/src/test/mir-opt/inline/inline-closure-borrows-arg/rustc.foo.Inline.after.mir index cea3c59a3e479..f6dd741364039 100644 --- a/src/test/mir-opt/inline/inline-closure-borrows-arg/rustc.foo.Inline.after.mir +++ b/src/test/mir-opt/inline/inline-closure-borrows-arg/rustc.foo.Inline.after.mir @@ -24,15 +24,6 @@ fn foo(_1: T, _2: &i32) -> i32 { bb0: { StorageLive(_3); // scope 0 at $DIR/inline-closure-borrows-arg.rs:12:9: 12:10 - _3 = [closure@foo::::{{closure}}#0]; // scope 0 at $DIR/inline-closure-borrows-arg.rs:12:13: 15:6 - // closure - // + def_id: DefId(0:6 ~ inline_closure_borrows_arg[317d]::foo[0]::{{closure}}[0]) - // + substs: [ - // T, - // i8, - // for<'r, 's> extern "rust-call" fn((&'r i32, &'s i32)) -> i32, - // (), - // ] StorageLive(_4); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6 _4 = &_3; // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6 StorageLive(_5); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 @@ -40,7 +31,8 @@ fn foo(_1: T, _2: &i32) -> i32 { _6 = &(*_2); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:7: 16:8 StorageLive(_7); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11 _7 = &(*_2); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11 - _5 = (move _6, move _7); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + (_5.0: &i32) = move _6; // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + (_5.1: &i32) = move _7; // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 _8 = move (_5.0: &i32); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 _9 = move (_5.1: &i32); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 _0 = (*_8); // scope 3 at $DIR/inline-closure-borrows-arg.rs:14:9: 14:18 diff --git a/src/test/mir-opt/inline/inline-closure-captures/rustc.foo.Inline.after.mir b/src/test/mir-opt/inline/inline-closure-captures/rustc.foo.Inline.after.mir index eeff914ccffb9..e2b5d6567c299 100644 --- a/src/test/mir-opt/inline/inline-closure-captures/rustc.foo.Inline.after.mir +++ b/src/test/mir-opt/inline/inline-closure-captures/rustc.foo.Inline.after.mir @@ -28,15 +28,8 @@ fn foo(_1: T, _2: i32) -> (i32, T) { _4 = &_2; // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 StorageLive(_5); // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 _5 = &_1; // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 - _3 = [closure@foo::::{{closure}}#0] { q: move _4, t: move _5 }; // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 - // closure - // + def_id: DefId(0:6 ~ inline_closure_captures[317d]::foo[0]::{{closure}}[0]) - // + substs: [ - // T, - // i8, - // extern "rust-call" fn((i32,)) -> (i32, T), - // (&i32, &T), - // ] + (_3.0: &i32) = move _4; // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + (_3.1: &T) = move _5; // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 StorageDead(_5); // scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24 StorageDead(_4); // scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24 StorageLive(_6); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:6 @@ -44,7 +37,7 @@ fn foo(_1: T, _2: i32) -> (i32, T) { StorageLive(_7); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 StorageLive(_8); // scope 1 at $DIR/inline-closure-captures.rs:12:7: 12:8 _8 = _2; // scope 1 at $DIR/inline-closure-captures.rs:12:7: 12:8 - _7 = (move _8,); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 + (_7.0: i32) = move _8; // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 _11 = move (_7.0: i32); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 StorageLive(_9); // scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20 _9 = (*((*_6).0: &i32)); // scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20 diff --git a/src/test/mir-opt/inline/inline-closure/rustc.foo.Inline.after.mir b/src/test/mir-opt/inline/inline-closure/rustc.foo.Inline.after.mir index bd0ec8c7ddbd5..b40a8047c4185 100644 --- a/src/test/mir-opt/inline/inline-closure/rustc.foo.Inline.after.mir +++ b/src/test/mir-opt/inline/inline-closure/rustc.foo.Inline.after.mir @@ -21,15 +21,6 @@ fn foo(_1: T, _2: i32) -> i32 { bb0: { StorageLive(_3); // scope 0 at $DIR/inline-closure.rs:11:9: 11:10 - _3 = [closure@foo::::{{closure}}#0]; // scope 0 at $DIR/inline-closure.rs:11:13: 11:24 - // closure - // + def_id: DefId(0:6 ~ inline_closure[317d]::foo[0]::{{closure}}[0]) - // + substs: [ - // T, - // i8, - // extern "rust-call" fn((i32, i32)) -> i32, - // (), - // ] StorageLive(_4); // scope 1 at $DIR/inline-closure.rs:12:5: 12:6 _4 = &_3; // scope 1 at $DIR/inline-closure.rs:12:5: 12:6 StorageLive(_5); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12 @@ -37,7 +28,8 @@ fn foo(_1: T, _2: i32) -> i32 { _6 = _2; // scope 1 at $DIR/inline-closure.rs:12:7: 12:8 StorageLive(_7); // scope 1 at $DIR/inline-closure.rs:12:10: 12:11 _7 = _2; // scope 1 at $DIR/inline-closure.rs:12:10: 12:11 - _5 = (move _6, move _7); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12 + (_5.0: i32) = move _6; // scope 1 at $DIR/inline-closure.rs:12:5: 12:12 + (_5.1: i32) = move _7; // scope 1 at $DIR/inline-closure.rs:12:5: 12:12 _8 = move (_5.0: i32); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12 _9 = move (_5.1: i32); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12 _0 = _8; // scope 2 at $DIR/inline-closure.rs:11:22: 11:24 diff --git a/src/test/mir-opt/simplify-arm-identity/32bit/rustc.main.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify-arm-identity/32bit/rustc.main.SimplifyArmIdentity.diff index dfd6d6f0f2ecd..955f4c2f6d768 100644 --- a/src/test/mir-opt/simplify-arm-identity/32bit/rustc.main.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify-arm-identity/32bit/rustc.main.SimplifyArmIdentity.diff @@ -28,14 +28,8 @@ // + literal: Const { ty: u8, val: Value(Scalar(0x00)) } discriminant(_1) = 0; // scope 0 at $DIR/simplify-arm-identity.rs:18:18: 18:29 StorageLive(_2); // scope 1 at $DIR/simplify-arm-identity.rs:19:18: 22:6 - _3 = const 0isize; // scope 1 at $DIR/simplify-arm-identity.rs:20:9: 20:20 - // ty::Const - // + ty: isize - // + val: Value(Scalar(0x00000000)) - // mir::Constant - // + span: $DIR/simplify-arm-identity.rs:20:9: 20:20 - // + literal: Const { ty: isize, val: Value(Scalar(0x00000000)) } - goto -> bb3; // scope 1 at $DIR/simplify-arm-identity.rs:20:9: 20:20 + _3 = discriminant(_1); // scope 1 at $DIR/simplify-arm-identity.rs:20:9: 20:20 + switchInt(move _3) -> [0isize: bb3, 1isize: bb1, otherwise: bb2]; // scope 1 at $DIR/simplify-arm-identity.rs:20:9: 20:20 } bb1: { diff --git a/src/test/mir-opt/simplify-locals-removes-unused-consts/rustc.main.SimplifyLocals.diff b/src/test/mir-opt/simplify-locals-removes-unused-consts/rustc.main.SimplifyLocals.diff index 0bd4ba97b3ca0..5a02c11b698d0 100644 --- a/src/test/mir-opt/simplify-locals-removes-unused-consts/rustc.main.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify-locals-removes-unused-consts/rustc.main.SimplifyLocals.diff @@ -22,58 +22,44 @@ bb0: { - StorageLive(_1); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28 - StorageLive(_2); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23 -- _2 = const (); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23 +- StorageLive(_3); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27 +- (_1.0: ()) = const (); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28 + StorageLive(_1); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22 + _1 = const use_zst(const ((), ())) -> bb1; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22 // ty::Const - // + ty: () - // + val: Value(Scalar()) - // mir::Constant -- // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23 +- // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28 - // + literal: Const { ty: (), val: Value(Scalar()) } -- StorageLive(_3); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27 -- _3 = const (); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27 +- (_1.1: ()) = const (); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28 - // ty::Const - // + ty: () - // + val: Value(Scalar()) - // mir::Constant -- // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27 -- // + literal: Const { ty: (), val: Value(Scalar()) } -- _1 = const ((), ()); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28 -- // ty::Const -- // + ty: ((), ()) -- // + val: Value(Scalar()) -- // mir::Constant - // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28 -- // + literal: Const { ty: ((), ()), val: Value(Scalar()) } +- // + literal: Const { ty: (), val: Value(Scalar()) } - StorageDead(_3); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:27: 13:28 - StorageDead(_2); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:27: 13:28 - StorageDead(_1); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:28: 13:29 - StorageLive(_4); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22 - StorageLive(_5); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21 - StorageLive(_6); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16 -- _6 = const (); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16 -- // ty::Const -- // + ty: () -- // + val: Value(Scalar()) -- // mir::Constant -- // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16 -- // + literal: Const { ty: (), val: Value(Scalar()) } - StorageLive(_7); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20 -- _7 = const (); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20 +- (_5.0: ()) = const (); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21 - // ty::Const - // + ty: () - // + val: Value(Scalar()) - // mir::Constant -- // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20 +- // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21 - // + literal: Const { ty: (), val: Value(Scalar()) } -- _5 = const ((), ()); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21 +- (_5.1: ()) = const (); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21 - // ty::Const -- // + ty: ((), ()) +- // + ty: () - // + val: Value(Scalar()) - // mir::Constant - // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21 -- // + literal: Const { ty: ((), ()), val: Value(Scalar()) } +- // + literal: Const { ty: (), val: Value(Scalar()) } - StorageDead(_7); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:20: 14:21 - StorageDead(_6); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:20: 14:21 - _4 = const use_zst(const ((), ())) -> bb1; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22 @@ -98,16 +84,16 @@ - StorageLive(_9); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:34 - StorageLive(_10); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:30 - StorageLive(_11); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28 -- _11 = const Temp { x: 40u8 }; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28 +- (_11.0: u8) = const 40u8; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28 + StorageDead(_1); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:22: 14:23 + StorageLive(_2); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35 + _2 = const use_u8(const 42u8) -> bb2; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35 // ty::Const -- // + ty: Temp +- // + ty: u8 - // + val: Value(Scalar(0x28)) - // mir::Constant -- // + span: $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28 -- // + literal: Const { ty: Temp, val: Value(Scalar(0x28)) } +- // + span: $DIR/simplify-locals-removes-unused-consts.rs:16:23: 16:25 +- // + literal: Const { ty: u8, val: Value(Scalar(0x28)) } - _10 = const 40u8; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:30 - // ty::Const - // + ty: u8 diff --git a/src/test/mir-opt/uninhabited_enum_branching/rustc.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir b/src/test/mir-opt/uninhabited_enum_branching/rustc.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir index df6c90fc7fb37..7785237bed935 100644 --- a/src/test/mir-opt/uninhabited_enum_branching/rustc.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir +++ b/src/test/mir-opt/uninhabited_enum_branching/rustc.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir @@ -15,7 +15,7 @@ fn main() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6 StorageLive(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19 - _2 = Test1::C; // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19 + discriminant(_2) = 2; // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19 _3 = discriminant(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20 StorageLive(_5); // scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24 _5 = const "C"; // scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24 @@ -31,7 +31,7 @@ fn main() -> () { StorageDead(_1); // scope 0 at $DIR/uninhabited_enum_branching.rs:24:6: 24:7 StorageLive(_6); // scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6 StorageLive(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19 - _7 = Test2::D; // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19 + discriminant(_7) = 0; // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19 _8 = discriminant(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17 switchInt(move _8) -> [4isize: bb2, otherwise: bb1]; // scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17 } diff --git a/src/test/mir-opt/uninhabited_enum_branching/rustc.main.UninhabitedEnumBranching.diff b/src/test/mir-opt/uninhabited_enum_branching/rustc.main.UninhabitedEnumBranching.diff index fa1474aa049de..681ae21eb1fe3 100644 --- a/src/test/mir-opt/uninhabited_enum_branching/rustc.main.UninhabitedEnumBranching.diff +++ b/src/test/mir-opt/uninhabited_enum_branching/rustc.main.UninhabitedEnumBranching.diff @@ -16,7 +16,7 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6 StorageLive(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19 - _2 = Test1::C; // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19 + discriminant(_2) = 2; // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19 _3 = discriminant(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20 - switchInt(move _3) -> [0isize: bb2, 1isize: bb3, otherwise: bb1]; // scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20 + switchInt(move _3) -> bb1; // scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20 @@ -66,7 +66,7 @@ StorageDead(_1); // scope 0 at $DIR/uninhabited_enum_branching.rs:24:6: 24:7 StorageLive(_6); // scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6 StorageLive(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19 - _7 = Test2::D; // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19 + discriminant(_7) = 0; // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19 _8 = discriminant(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17 switchInt(move _8) -> [4isize: bb6, otherwise: bb5]; // scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17 } diff --git a/src/test/mir-opt/while_let_loops.rs b/src/test/mir-opt/while_let_loops.rs new file mode 100644 index 0000000000000..a278bab02a7ab --- /dev/null +++ b/src/test/mir-opt/while_let_loops.rs @@ -0,0 +1,14 @@ + + +// EMIT_MIR rustc.change_loop_body.PreCodegen.after.mir +pub fn change_loop_body() { + let mut _x = 0; + while let Some(0u32) = None { + _x = 1; + break; + } +} + +fn main() { + change_loop_body(); +} diff --git a/src/test/mir-opt/while_let_loops/rustc.change_loop_body.PreCodegen.after.mir b/src/test/mir-opt/while_let_loops/rustc.change_loop_body.PreCodegen.after.mir new file mode 100644 index 0000000000000..0cf5f60672e23 --- /dev/null +++ b/src/test/mir-opt/while_let_loops/rustc.change_loop_body.PreCodegen.after.mir @@ -0,0 +1,33 @@ +// MIR for `change_loop_body` after PreCodegen + +fn change_loop_body() -> () { + let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:4:27: 4:27 + let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:5:9: 5:15 + let mut _2: std::option::Option; // in scope 0 at $DIR/while_let_loops.rs:6:28: 6:32 + scope 1 { + debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:5:9: 5:15 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:5:9: 5:15 + _1 = const 0i32; // scope 0 at $DIR/while_let_loops.rs:5:18: 5:19 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/while_let_loops.rs:5:18: 5:19 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + StorageLive(_2); // scope 1 at $DIR/while_let_loops.rs:6:28: 6:32 + discriminant(_2) = 0; // scope 1 at $DIR/while_let_loops.rs:6:28: 6:32 + _0 = const (); // scope 1 at $DIR/while_let_loops.rs:6:5: 9:6 + // ty::Const + // + ty: () + // + val: Value(Scalar()) + // mir::Constant + // + span: $DIR/while_let_loops.rs:6:5: 9:6 + // + literal: Const { ty: (), val: Value(Scalar()) } + StorageDead(_2); // scope 1 at $DIR/while_let_loops.rs:9:5: 9:6 + StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:10:1: 10:2 + return; // scope 0 at $DIR/while_let_loops.rs:10:2: 10:2 + } +}