diff --git a/compiler/rustc_mir_build/src/builder/cfg.rs b/compiler/rustc_mir_build/src/builder/cfg.rs index 020858d427712..75377f761f401 100644 --- a/compiler/rustc_mir_build/src/builder/cfg.rs +++ b/compiler/rustc_mir_build/src/builder/cfg.rs @@ -75,11 +75,7 @@ impl<'tcx> CFG<'tcx> { source_info, place, Rvalue::Use( - Operand::Constant(Box::new(ConstOperand { - span: source_info.span, - user_ty: None, - const_: Const::zero_sized(tcx.types.unit), - })), + Operand::zero_sized_constant(tcx.types.unit, source_info.span), WithRetag::Yes, ), ); diff --git a/compiler/rustc_mir_build/src/builder/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/builder/expr/as_rvalue.rs index 09c76d6beb4a1..da8cbb0dc9d97 100644 --- a/compiler/rustc_mir_build/src/builder/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/builder/expr/as_rvalue.rs @@ -348,11 +348,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ExprKind::Assign { .. } | ExprKind::AssignOp { .. } => { block = this.stmt_expr(block, expr_id, None).into_block(); block.and(Rvalue::Use( - Operand::Constant(Box::new(ConstOperand { - span: expr_span, - user_ty: None, - const_: Const::zero_sized(this.tcx.types.unit), - })), + Operand::zero_sized_constant(this.tcx.types.unit, expr_span), WithRetag::Yes, )) } diff --git a/compiler/rustc_mir_build/src/builder/expr/into.rs b/compiler/rustc_mir_build/src/builder/expr/into.rs index 167bedfc2101e..86f781f35f60d 100644 --- a/compiler/rustc_mir_build/src/builder/expr/into.rs +++ b/compiler/rustc_mir_build/src/builder/expr/into.rs @@ -418,8 +418,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { sym::write_via_move => { // `write_via_move(ptr, val)` becomes `*ptr = val` but without any dropping. - // The destination must have unit type (so we don't actually have to store anything - // into it). + // The destination must have unit type. assert!(destination.ty(&this.local_decls, this.tcx).ty.is_unit()); // Compile this to an assignment of the argument into the destination. @@ -431,7 +430,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { span_bug!(expr_span, "invalid write_via_move call") }; let ptr_deref = ptr.project_deeper(&[ProjectionElem::Deref], this.tcx); - this.expr_into_dest(ptr_deref, block, val) + unpack!(block = this.expr_into_dest(ptr_deref, block, val)); + this.cfg.push_assign_unit(block, source_info, destination, this.tcx); + block.unit() } sym::write_box_via_move => { // The signature is: diff --git a/compiler/rustc_mir_transform/src/coroutine/drop.rs b/compiler/rustc_mir_transform/src/coroutine/drop.rs index aea2992bbce21..b444bf8e1df91 100644 --- a/compiler/rustc_mir_transform/src/coroutine/drop.rs +++ b/compiler/rustc_mir_transform/src/coroutine/drop.rs @@ -208,8 +208,18 @@ pub(super) fn create_coroutine_drop_shim<'tcx>( } } - // Replace the return variable + // Replace the return variable and initialize it once for all return paths. body.local_decls[RETURN_PLACE] = LocalDecl::with_source_info(tcx.types.unit, source_info); + body.basic_blocks_mut()[START_BLOCK].statements.push(Statement::new( + source_info, + StatementKind::Assign(Box::new(( + Place::return_place(), + Rvalue::Use( + Operand::zero_sized_constant(tcx.types.unit, source_info.span), + WithRetag::Yes, + ), + ))), + )); make_coroutine_state_argument_indirect(tcx, &mut body); diff --git a/compiler/rustc_mir_transform/src/coroutine/mod.rs b/compiler/rustc_mir_transform/src/coroutine/mod.rs index d21414296bc94..607de9394778c 100644 --- a/compiler/rustc_mir_transform/src/coroutine/mod.rs +++ b/compiler/rustc_mir_transform/src/coroutine/mod.rs @@ -749,11 +749,7 @@ fn return_poll_ready_assign<'tcx>(tcx: TyCtxt<'tcx>, source_info: SourceInfo) -> // Poll::Ready(()) let poll_def_id = tcx.require_lang_item(LangItem::Poll, source_info.span); let args = tcx.mk_args(&[tcx.types.unit.into()]); - let val = Operand::Constant(Box::new(ConstOperand { - span: source_info.span, - user_ty: None, - const_: Const::zero_sized(tcx.types.unit), - })); + let val = Operand::zero_sized_constant(tcx.types.unit, source_info.span); let ready_val = Rvalue::Aggregate( Box::new(AggregateKind::Adt(poll_def_id, VariantIdx::from_usize(0), args, None, None)), indexvec![val], @@ -911,6 +907,25 @@ fn create_coroutine_resume_function<'tcx>( } } + // Iterator::next has no resume argument, so initialize the unit resume + // local at the start of each invocation. + if let CoroutineKind::Desugared(CoroutineDesugaring::Gen, _) = transform.coroutine_kind { + let source_info = SourceInfo::outermost(body.span); + body.basic_blocks_mut()[START_BLOCK].statements.insert( + 0, + Statement::new( + source_info, + StatementKind::Assign(Box::new(( + CTX_ARG.into(), + Rvalue::Use( + Operand::zero_sized_constant(tcx.types.unit, source_info.span), + WithRetag::Yes, + ), + ))), + ), + ); + } + // Make sure we remove dead blocks to remove // unrelated code from the drop part of the function simplify::remove_dead_blocks(body); diff --git a/compiler/rustc_mir_transform/src/cost_checker.rs b/compiler/rustc_mir_transform/src/cost_checker.rs index 32eef00812436..c9420b7b116fe 100644 --- a/compiler/rustc_mir_transform/src/cost_checker.rs +++ b/compiler/rustc_mir_transform/src/cost_checker.rs @@ -89,6 +89,11 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> { NonDivergingIntrinsic::CopyNonOverlapping(..) => CALL_PENALTY, }; } + StatementKind::Assign((_, Rvalue::Use(Operand::Constant(ref constant), _))) + if matches!(constant.const_, Const::Val(ConstValue::ZeroSized, _)) => + { + // Assigning a ZST constant emits no code. + } StatementKind::Assign(..) => self.penalty += INSTR_COST, _ => {} } diff --git a/compiler/rustc_mir_transform/src/instsimplify.rs b/compiler/rustc_mir_transform/src/instsimplify.rs index eaedb7c9aca3d..7e5b4841fc4f1 100644 --- a/compiler/rustc_mir_transform/src/instsimplify.rs +++ b/compiler/rustc_mir_transform/src/instsimplify.rs @@ -59,7 +59,7 @@ impl<'tcx> crate::MirPass<'tcx> for InstSimplify { ctx.simplify_primitive_clone(terminator, &mut block.statements); ctx.simplify_size_or_align_of_val(terminator, &mut block.statements); ctx.simplify_raw_eq(terminator, &mut block.statements); - ctx.simplify_intrinsic_assert(terminator); + ctx.simplify_intrinsic_assert(terminator, &mut block.statements); ctx.simplify_nounwind_call(terminator); simplify_duplicate_switch_targets(terminator); } @@ -397,9 +397,17 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> { } } - fn simplify_intrinsic_assert(&self, terminator: &mut Terminator<'tcx>) { - let TerminatorKind::Call { ref func, target: ref mut target @ Some(target_block), .. } = - terminator.kind + fn simplify_intrinsic_assert( + &self, + terminator: &mut Terminator<'tcx>, + statements: &mut Vec>, + ) { + let TerminatorKind::Call { + ref func, + destination, + target: ref mut target @ Some(target_block), + .. + } = terminator.kind else { return; }; @@ -420,7 +428,21 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> { *target = None; } Some(false) => { - // If we know the assert does not panic, turn the call into a Goto + // If we know the assert does not panic, turn the call into a Goto. We still need to + // initialize its unit result. + statements.push(Statement::new( + terminator.source_info, + StatementKind::Assign(Box::new(( + destination, + Rvalue::Use( + Operand::zero_sized_constant( + self.tcx.types.unit, + terminator.source_info.span, + ), + WithRetag::Yes, + ), + ))), + )); terminator.kind = TerminatorKind::goto(target_block); } } diff --git a/compiler/rustc_mir_transform/src/lower_intrinsics.rs b/compiler/rustc_mir_transform/src/lower_intrinsics.rs index 3ee8c405a1d77..369ef0a6849bc 100644 --- a/compiler/rustc_mir_transform/src/lower_intrinsics.rs +++ b/compiler/rustc_mir_transform/src/lower_intrinsics.rs @@ -47,11 +47,10 @@ impl<'tcx> crate::MirPass<'tcx> for LowerIntrinsics { StatementKind::Assign(Box::new(( *destination, Rvalue::Use( - Operand::Constant(Box::new(ConstOperand { - span: terminator.source_info.span, - user_ty: None, - const_: Const::zero_sized(tcx.types.unit), - })), + Operand::zero_sized_constant( + tcx.types.unit, + terminator.source_info.span, + ), WithRetag::Yes, ), ))), @@ -61,20 +60,31 @@ impl<'tcx> crate::MirPass<'tcx> for LowerIntrinsics { sym::copy_nonoverlapping => { let target = target.unwrap(); let Ok([src, dst, count]) = take_array(args) else { - bug!("Wrong arguments for copy_non_overlapping intrinsic"); + bug!("Wrong arguments for copy_nonoverlapping intrinsic"); }; block.statements.push(Statement::new( terminator.source_info, StatementKind::Intrinsic(Box::new( - NonDivergingIntrinsic::CopyNonOverlapping( - rustc_middle::mir::CopyNonOverlapping { - src: src.node, - dst: dst.node, - count: count.node, - }, - ), + NonDivergingIntrinsic::CopyNonOverlapping(CopyNonOverlapping { + src: src.node, + dst: dst.node, + count: count.node, + }), )), )); + block.statements.push(Statement::new( + terminator.source_info, + StatementKind::Assign(Box::new(( + *destination, + Rvalue::Use( + Operand::zero_sized_constant( + tcx.types.unit, + terminator.source_info.span, + ), + WithRetag::Yes, + ), + ))), + )); terminator.kind = TerminatorKind::goto(target); } sym::assume => { @@ -88,6 +98,19 @@ impl<'tcx> crate::MirPass<'tcx> for LowerIntrinsics { arg.node, ))), )); + block.statements.push(Statement::new( + terminator.source_info, + StatementKind::Assign(Box::new(( + *destination, + Rvalue::Use( + Operand::zero_sized_constant( + tcx.types.unit, + terminator.source_info.span, + ), + WithRetag::Yes, + ), + ))), + )); terminator.kind = TerminatorKind::goto(target); } sym::wrapping_add diff --git a/compiler/rustc_mir_transform/src/match_branches.rs b/compiler/rustc_mir_transform/src/match_branches.rs index 48a0caa4979bb..c06f6a89a434a 100644 --- a/compiler/rustc_mir_transform/src/match_branches.rs +++ b/compiler/rustc_mir_transform/src/match_branches.rs @@ -65,9 +65,10 @@ impl<'tcx, 'a> SimplifyMatch<'tcx, 'a> { otherwise: Option<&ConstOperand<'tcx>>, ) -> Option> { let (_, first_const, mut others) = split_first_case(consts, otherwise); - let first_scalar_int = first_const.const_.try_eval_scalar_int(self.tcx, self.typing_env)?; + let first_value = + first_const.const_.eval(self.tcx, self.typing_env, first_const.span).ok()?; if others.all(|const_| { - const_.const_.try_eval_scalar_int(self.tcx, self.typing_env) == Some(first_scalar_int) + const_.const_.eval(self.tcx, self.typing_env, const_.span).ok() == Some(first_value) }) { Some(StatementKind::Assign(Box::new(( dest, diff --git a/compiler/rustc_mir_transform/src/promote_consts.rs b/compiler/rustc_mir_transform/src/promote_consts.rs index b490ebb3a9392..5a3769072da3d 100644 --- a/compiler/rustc_mir_transform/src/promote_consts.rs +++ b/compiler/rustc_mir_transform/src/promote_consts.rs @@ -815,11 +815,10 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> { rhs.clone() } else { let unit = Rvalue::Use( - Operand::Constant(Box::new(ConstOperand { - span: statement.source_info.span, - user_ty: None, - const_: Const::zero_sized(self.tcx.types.unit), - })), + Operand::zero_sized_constant( + self.tcx.types.unit, + statement.source_info.span, + ), WithRetag::Yes, ); mem::replace(rhs, unit) diff --git a/compiler/rustc_mir_transform/src/remove_zsts.rs b/compiler/rustc_mir_transform/src/remove_zsts.rs index 98f4009c15665..92fd1dda004fa 100644 --- a/compiler/rustc_mir_transform/src/remove_zsts.rs +++ b/compiler/rustc_mir_transform/src/remove_zsts.rs @@ -127,7 +127,10 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> { Some(place) } StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => { - Some(local.into()) + if self.known_to_be_zst(self.local_decls[local].ty) { + statement.make_nop(true); + } + return; } StatementKind::Coverage(_) | StatementKind::Intrinsic(_) @@ -135,9 +138,13 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> { | StatementKind::BackwardIncompatibleDropHint { .. } | StatementKind::ConstEvalCounter => None, }; + // Under move-elimination semantics, direct ZST writes still serve to + // allocate the base local and give it an address. Genuinely unused + // assignments are later deleted by DSE. if let Some(place_for_ty) = place_for_ty && let ty = place_for_ty.ty(self.local_decls, self.tcx).ty && self.known_to_be_zst(ty) + && place_for_ty.is_indirect() { statement.make_nop(true); } else { diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index f1d85166653ff..b436e73686a9e 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -278,13 +278,20 @@ pub fn build_drop_shim<'tcx>( let return_block = BasicBlock::new(1); let mut blocks = IndexVec::with_capacity(2); - let block = |blocks: &mut IndexVec<_, _>, kind| { + let block = |blocks: &mut IndexVec<_, _>, kind| -> BasicBlock { blocks.push(BasicBlockData::new(Some(Terminator { source_info, kind }), false)) }; if ty.is_some() { block(&mut blocks, TerminatorKind::goto(return_block)); } - block(&mut blocks, TerminatorKind::Return); + let ret = block(&mut blocks, TerminatorKind::Return); + blocks[ret].statements.push(Statement::new( + source_info, + StatementKind::Assign(Box::new(( + Place::return_place(), + Rvalue::Use(Operand::zero_sized_constant(tcx.types.unit, span), WithRetag::Yes), + ))), + )); let source = MirSource::from_shim(ty::ShimKind::DropGlue(def_id, ty)); let mut body = @@ -699,10 +706,18 @@ impl<'tcx> CloneShimBuilder<'tcx> { unwind } - fn tuple_like_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, tys: I) - where - I: IntoIterator>, - { + fn tuple_like_shim( + &mut self, + dest: Place<'tcx>, + src: Place<'tcx>, + tys: &'tcx ty::List>, + ) { + if tys.is_empty() { + // With no fields to clone, initialize the return local directly. + self.copy_shim(); + return; + } + self.block(vec![], TerminatorKind::goto(self.block_index_offset(3)), false); let unwind = self.block(vec![], TerminatorKind::UnwindResume, true); let target = self.block(vec![], TerminatorKind::Return, false); diff --git a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs index 7530716e8cf39..60a918e6854e1 100644 --- a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs +++ b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs @@ -84,7 +84,7 @@ pub(super) fn build_async_drop_shim<'tcx>( let return_block = BasicBlock::new(1); let mut blocks = IndexVec::with_capacity(2); - let block = |blocks: &mut IndexVec<_, _>, kind| { + let block = |blocks: &mut IndexVec<_, _>, kind| -> BasicBlock { blocks.push(BasicBlockData::new(Some(Terminator { source_info, kind }), false)) }; block( @@ -101,7 +101,14 @@ pub(super) fn build_async_drop_shim<'tcx>( TerminatorKind::goto(return_block) }, ); - block(&mut blocks, TerminatorKind::Return); + let ret = block(&mut blocks, TerminatorKind::Return); + blocks[ret].statements.push(Statement::new( + source_info, + StatementKind::Assign(Box::new(( + Place::return_place(), + Rvalue::Use(Operand::zero_sized_constant(tcx.types.unit, span), WithRetag::Yes), + ))), + )); let source = MirSource::from_shim(ty::ShimKind::AsyncDropGlue(def_id, ty)); let mut body = diff --git a/tests/codegen-llvm/hint/cold_path-target_feature.rs b/tests/codegen-llvm/hint/cold_path-target_feature.rs index 9e06fd0ceafa1..899f8765ab17b 100644 --- a/tests/codegen-llvm/hint/cold_path-target_feature.rs +++ b/tests/codegen-llvm/hint/cold_path-target_feature.rs @@ -28,10 +28,10 @@ pub fn test1(x: bool) { } // CHECK-LABEL: @test1( - // CHECK: br i1 %x, label %bb1, label %bb2, !prof ![[NUM:[0-9]+]] - // CHECK: bb2: + // CHECK: br i1 %x, label %[[TRUE:bb[0-9]+]], label %[[FALSE:bb[0-9]+]], !prof ![[NUM:[0-9]+]] + // CHECK: [[FALSE]]: // CHECK: path_b - // CHECK: bb1: + // CHECK: [[TRUE]]: // CHECK: path_a } @@ -46,10 +46,10 @@ pub fn with_target_feature(x: bool) { } // CHECK-LABEL: @with_target_feature( - // CHECK: br i1 %x, label %bb1, label %bb2, !prof ![[NUM]] - // CHECK: bb2: + // CHECK: br i1 %x, label %[[TRUE:bb[0-9]+]], label %[[FALSE:bb[0-9]+]], !prof ![[NUM]] + // CHECK: [[FALSE]]: // CHECK: path_b - // CHECK: bb1: + // CHECK: [[TRUE]]: // CHECK: path_a } diff --git a/tests/codegen-llvm/hint/cold_path.rs b/tests/codegen-llvm/hint/cold_path.rs index e6e7379322ddf..c8da7af840790 100644 --- a/tests/codegen-llvm/hint/cold_path.rs +++ b/tests/codegen-llvm/hint/cold_path.rs @@ -25,10 +25,10 @@ pub fn test1(x: bool) { } // CHECK-LABEL: @test1( - // CHECK: br i1 %x, label %bb1, label %bb2, !prof ![[NUM:[0-9]+]] - // CHECK: bb2: + // CHECK: br i1 %x, label %[[TRUE:bb[0-9]+]], label %[[FALSE:bb[0-9]+]], !prof ![[NUM:[0-9]+]] + // CHECK: [[FALSE]]: // CHECK: path_b - // CHECK: bb1: + // CHECK: [[TRUE]]: // CHECK: path_a } @@ -43,10 +43,10 @@ pub fn test2(x: i32) { } // CHECK-LABEL: @test2( - // CHECK: br i1 %_2, label %bb2, label %bb1, !prof ![[NUM]] - // CHECK: bb1: + // CHECK: br i1 %_2, label %[[TRUE:bb[0-9]+]], label %[[FALSE:bb[0-9]+]], !prof ![[NUM]] + // CHECK: [[FALSE]]: // CHECK: path_b - // CHECK: bb2: + // CHECK: [[TRUE]]: // CHECK: path_a } diff --git a/tests/codegen-llvm/hint/likely.rs b/tests/codegen-llvm/hint/likely.rs index 75f9e7aae367d..3f1b2bfbb8091 100644 --- a/tests/codegen-llvm/hint/likely.rs +++ b/tests/codegen-llvm/hint/likely.rs @@ -25,10 +25,10 @@ pub fn test1(x: bool) { } // CHECK-LABEL: @test1( - // CHECK: br i1 %x, label %bb2, label %bb3, !prof ![[NUM:[0-9]+]] - // CHECK: bb3: + // CHECK: br i1 %x, label %[[TRUE:bb[0-9]+]], label %[[FALSE:bb[0-9]+]], !prof ![[NUM:[0-9]+]] + // CHECK: [[FALSE]]: // CHECK: path_b - // CHECK: bb2: + // CHECK: [[TRUE]]: // CHECK: path_a } @@ -40,10 +40,10 @@ pub fn test2(x: i32) { } // CHECK-LABEL: @test2( - // CHECK: br i1 %_2, label %bb2, label %bb3, !prof ![[NUM]] - // CHECK: bb3: + // CHECK: br i1 %_2, label %[[TRUE:bb[0-9]+]], label %[[FALSE:bb[0-9]+]], !prof ![[NUM]] + // CHECK: [[FALSE]]: // CHECK: path_b - // CHECK: bb2: + // CHECK: [[TRUE]]: // CHECK: path_a } @@ -55,10 +55,10 @@ pub fn test3(x: i8) { } // CHECK-LABEL: @test3( - // CHECK: br i1 %_2, label %bb2, label %bb3, !prof ![[NUM]] - // CHECK: bb3: + // CHECK: br i1 %_2, label %[[TRUE:bb[0-9]+]], label %[[FALSE:bb[0-9]+]], !prof ![[NUM]] + // CHECK: [[FALSE]]: // CHECK: path_b - // CHECK: bb2: + // CHECK: [[TRUE]]: // CHECK: path_a } @@ -70,10 +70,10 @@ pub fn test4(x: u64) { } // CHECK-LABEL: @test4( - // CHECK: br i1 %0, label %bb3, label %bb2, !prof ![[NUM2:[0-9]+]] - // CHECK: bb3: + // CHECK: br i1 %0, label %[[TRUE:bb[0-9]+]], label %[[FALSE:bb[0-9]+]], !prof ![[NUM2:[0-9]+]] + // CHECK: [[TRUE]]: // CHECK: path_a - // CHECK: bb2: + // CHECK: [[FALSE]]: // CHECK: path_b } diff --git a/tests/codegen-llvm/hint/unlikely.rs b/tests/codegen-llvm/hint/unlikely.rs index 248b1e2537e96..0376e2ebb23f4 100644 --- a/tests/codegen-llvm/hint/unlikely.rs +++ b/tests/codegen-llvm/hint/unlikely.rs @@ -25,10 +25,10 @@ pub fn test1(x: bool) { } // CHECK-LABEL: @test1( - // CHECK: br i1 %x, label %bb2, label %bb4, !prof ![[NUM:[0-9]+]] - // CHECK: bb4: + // CHECK: br i1 %x, label %[[TRUE:bb[0-9]+]], label %[[FALSE:bb[0-9]+]], !prof ![[NUM:[0-9]+]] + // CHECK: [[FALSE]]: // CHECK: path_b - // CHECK: bb2: + // CHECK: [[TRUE]]: // CHECK: path_a } @@ -40,10 +40,10 @@ pub fn test2(x: i32) { } // CHECK-LABEL: @test2( - // CHECK: br i1 %_2, label %bb2, label %bb4, !prof ![[NUM]] - // CHECK: bb4: + // CHECK: br i1 %_2, label %[[TRUE:bb[0-9]+]], label %[[FALSE:bb[0-9]+]], !prof ![[NUM]] + // CHECK: [[FALSE]]: // CHECK: path_b - // CHECK: bb2: + // CHECK: [[TRUE]]: // CHECK: path_a } @@ -55,10 +55,10 @@ pub fn test3(x: i8) { } // CHECK-LABEL: @test3( - // CHECK: br i1 %_2, label %bb2, label %bb4, !prof ![[NUM]] - // CHECK: bb4: + // CHECK: br i1 %_2, label %[[TRUE:bb[0-9]+]], label %[[FALSE:bb[0-9]+]], !prof ![[NUM]] + // CHECK: [[FALSE]]: // CHECK: path_b - // CHECK: bb2: + // CHECK: [[TRUE]]: // CHECK: path_a } @@ -70,10 +70,10 @@ pub fn test4(x: u64) { } // CHECK-LABEL: @test4( - // CHECK: br i1 %0, label %bb4, label %bb2, !prof ![[NUM2:[0-9]+]] - // CHECK: bb4: + // CHECK: br i1 %0, label %[[TRUE:bb[0-9]+]], label %[[FALSE:bb[0-9]+]], !prof ![[NUM2:[0-9]+]] + // CHECK: [[TRUE]]: // CHECK: path_a - // CHECK: bb2: + // CHECK: [[FALSE]]: // CHECK: path_b } diff --git a/tests/codegen-llvm/intrinsics/cold_path2.rs b/tests/codegen-llvm/intrinsics/cold_path2.rs index 0891c878fd9c5..e22bdbb96437b 100644 --- a/tests/codegen-llvm/intrinsics/cold_path2.rs +++ b/tests/codegen-llvm/intrinsics/cold_path2.rs @@ -27,10 +27,10 @@ pub fn test(x: Option) { // CHECK-LABEL: void @test(i8{{.+}}%x) // CHECK: %[[IS_NONE:.+]] = icmp eq i8 %x, 2 - // CHECK: br i1 %[[IS_NONE]], label %bb2, label %bb1, !prof ![[NUM:[0-9]+]] - // CHECK: bb1: + // CHECK: br i1 %[[IS_NONE]], label %[[TRUE:bb[0-9]+]], label %[[FALSE:bb[0-9]+]], !prof ![[NUM:[0-9]+]] + // CHECK: [[FALSE]]: // CHECK: path_a - // CHECK: bb2: + // CHECK: [[TRUE]]: // CHECK: path_b } diff --git a/tests/codegen-llvm/intrinsics/likely.rs b/tests/codegen-llvm/intrinsics/likely.rs index c5e3c466f4525..72fbe0c1b4b56 100644 --- a/tests/codegen-llvm/intrinsics/likely.rs +++ b/tests/codegen-llvm/intrinsics/likely.rs @@ -26,10 +26,10 @@ pub fn test_likely(x: bool) { } // CHECK-LABEL: @test_likely( -// CHECK: br i1 %x, label %bb2, label %bb3, !prof ![[NUM:[0-9]+]] -// CHECK: bb3: +// CHECK: br i1 %x, label %[[TRUE:bb[0-9]+]], label %[[FALSE:bb[0-9]+]], !prof ![[NUM:[0-9]+]] +// CHECK: [[FALSE]]: // CHECK-NOT: cold_path // CHECK: path_b -// CHECK: bb2: +// CHECK: [[TRUE]]: // CHECK: path_a // CHECK: ![[NUM]] = !{!"branch_weights", {{(!"expected", )?}}i32 2000, i32 1} diff --git a/tests/codegen-llvm/intrinsics/unlikely.rs b/tests/codegen-llvm/intrinsics/unlikely.rs index 90ebf070d2700..6a95476e626dc 100644 --- a/tests/codegen-llvm/intrinsics/unlikely.rs +++ b/tests/codegen-llvm/intrinsics/unlikely.rs @@ -26,10 +26,10 @@ pub fn test_unlikely(x: bool) { } // CHECK-LABEL: @test_unlikely( -// CHECK: br i1 %x, label %bb2, label %bb4, !prof ![[NUM:[0-9]+]] -// CHECK: bb4: +// CHECK: br i1 %x, label %[[TRUE:bb[0-9]+]], label %[[FALSE:bb[0-9]+]], !prof ![[NUM:[0-9]+]] +// CHECK: [[FALSE]]: // CHECK: path_b -// CHECK: bb2: +// CHECK: [[TRUE]]: // CHECK-NOT: cold_path // CHECK: path_a // CHECK: ![[NUM]] = !{!"branch_weights", {{(!"expected", )?}}i32 1, i32 2000} diff --git a/tests/incremental/hashes/loop_expressions.rs b/tests/incremental/hashes/loop_expressions.rs index cb21fca7579be..c85748d89f356 100644 --- a/tests/incremental/hashes/loop_expressions.rs +++ b/tests/incremental/hashes/loop_expressions.rs @@ -106,7 +106,7 @@ pub fn add_loop_label_to_break() { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2", except="hir_owner")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner")] +#[rustc_clean(cfg="bpass5", except="hir_owner,optimized_mir")] #[rustc_clean(cfg="bpass6")] pub fn add_loop_label_to_break() { let mut _x = 0; diff --git a/tests/incremental/hashes/trait_impls.rs b/tests/incremental/hashes/trait_impls.rs index 9698ec0473c4b..3bb1e12ed6677 100644 --- a/tests/incremental/hashes/trait_impls.rs +++ b/tests/incremental/hashes/trait_impls.rs @@ -81,7 +81,7 @@ impl ChangeMethodBodyTrait for Foo { impl ChangeMethodBodyTrait for Foo { #[rustc_clean(except="hir_owner,typeck_root", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] - #[rustc_clean(except="hir_owner,typeck_root", cfg="bpass5")] + #[rustc_clean(except="hir_owner,typeck_root,optimized_mir", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] fn method_name() { () diff --git a/tests/incremental/hashes/while_let_loops.rs b/tests/incremental/hashes/while_let_loops.rs index 780775b51930f..18cc32296fa92 100644 --- a/tests/incremental/hashes/while_let_loops.rs +++ b/tests/incremental/hashes/while_let_loops.rs @@ -31,7 +31,7 @@ pub fn change_loop_body() { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2", except="hir_owner")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner")] +#[rustc_clean(cfg="bpass5", except="hir_owner,optimized_mir")] #[rustc_clean(cfg="bpass6")] pub fn change_loop_body() { let mut _x = 0; @@ -56,7 +56,7 @@ pub fn change_loop_condition() { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2", except="hir_owner")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner")] +#[rustc_clean(cfg="bpass5", except="hir_owner,optimized_mir")] #[rustc_clean(cfg="bpass6")] pub fn change_loop_condition() { let mut _x = 0; @@ -81,7 +81,7 @@ pub fn add_break() { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2", except="hir_owner, typeck_root")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner, typeck_root")] +#[rustc_clean(cfg="bpass5", except="hir_owner, typeck_root, optimized_mir")] #[rustc_clean(cfg="bpass6")] pub fn add_break() { let mut _x = 0; @@ -106,7 +106,7 @@ pub fn add_loop_label() { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2", except="hir_owner")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner")] +#[rustc_clean(cfg="bpass5", except="hir_owner,optimized_mir")] #[rustc_clean(cfg="bpass6")] pub fn add_loop_label() { let mut _x = 0; @@ -131,7 +131,7 @@ pub fn add_loop_label_to_break() { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2", except="hir_owner")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner")] +#[rustc_clean(cfg="bpass5", except="hir_owner,optimized_mir")] #[rustc_clean(cfg="bpass6")] pub fn add_loop_label_to_break() { let mut _x = 0; @@ -158,7 +158,7 @@ pub fn change_break_label() { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2", except="hir_owner")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner")] +#[rustc_clean(cfg="bpass5", except="hir_owner,optimized_mir")] #[rustc_clean(cfg="bpass6")] pub fn change_break_label() { let mut _x = 0; @@ -183,7 +183,7 @@ pub fn add_loop_label_to_continue() { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2", except="hir_owner")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner")] +#[rustc_clean(cfg="bpass5", except="hir_owner,optimized_mir")] #[rustc_clean(cfg="bpass6")] pub fn add_loop_label_to_continue() { let mut _x = 0; @@ -210,7 +210,7 @@ pub fn change_continue_label() { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2", except="hir_owner")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner")] +#[rustc_clean(cfg="bpass5", except="hir_owner,optimized_mir")] #[rustc_clean(cfg="bpass6")] pub fn change_continue_label() { let mut _x = 0; @@ -237,7 +237,7 @@ pub fn change_continue_to_break() { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2", except="hir_owner")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner")] +#[rustc_clean(cfg="bpass5", except="hir_owner,optimized_mir")] #[rustc_clean(cfg="bpass6")] pub fn change_continue_to_break() { let mut _x = 0; diff --git a/tests/incremental/hashes/while_loops.rs b/tests/incremental/hashes/while_loops.rs index 4b5af798c0efa..903e1017bd2a4 100644 --- a/tests/incremental/hashes/while_loops.rs +++ b/tests/incremental/hashes/while_loops.rs @@ -131,7 +131,7 @@ pub fn add_loop_label_to_break() { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2", except="hir_owner")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner")] +#[rustc_clean(cfg="bpass5", except="hir_owner,optimized_mir")] #[rustc_clean(cfg="bpass6")] pub fn add_loop_label_to_break() { let mut _x = 0; diff --git a/tests/mir-opt/building/write_via_move.box_new.CleanupPostBorrowck.after.mir b/tests/mir-opt/building/write_via_move.box_new.CleanupPostBorrowck.after.mir index 6a6e984023b75..7a13128131664 100644 --- a/tests/mir-opt/building/write_via_move.box_new.CleanupPostBorrowck.after.mir +++ b/tests/mir-opt/building/write_via_move.box_new.CleanupPostBorrowck.after.mir @@ -44,6 +44,7 @@ fn box_new(_1: T) -> Box<[T; 1024]> { _8 = copy _1; (*_7) = [move _8; 1024]; StorageDead(_8); + _6 = const (); StorageDead(_7); StorageDead(_6); StorageLive(_9); diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-abort.diff b/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-abort.diff index 2ecf41638125e..0c257693d4bc3 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-abort.diff @@ -14,6 +14,7 @@ } bb2: { + _0 = const (); return; } } diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-unwind.diff index 06287b670dd4f..4be6f1d3ed90a 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-unwind.diff @@ -14,6 +14,7 @@ } bb2: { + _0 = const (); return; } } diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.runtime-optimized.after.panic-abort.mir b/tests/mir-opt/const_prop/control_flow_simplification.hello.runtime-optimized.after.panic-abort.mir index 86eda4942a7cb..b27b099456e47 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.runtime-optimized.after.panic-abort.mir +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.runtime-optimized.after.panic-abort.mir @@ -4,6 +4,7 @@ fn hello() -> () { let mut _0: (); bb0: { + _0 = const (); return; } } diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.runtime-optimized.after.panic-unwind.mir b/tests/mir-opt/const_prop/control_flow_simplification.hello.runtime-optimized.after.panic-unwind.mir index 86eda4942a7cb..b27b099456e47 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.runtime-optimized.after.panic-unwind.mir +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.runtime-optimized.after.panic-unwind.mir @@ -4,6 +4,7 @@ fn hello() -> () { let mut _0: (); bb0: { + _0 = const (); return; } } diff --git a/tests/mir-opt/const_prop/control_flow_simplification.rs b/tests/mir-opt/const_prop/control_flow_simplification.rs index 640579a3ebeca..9865c626aaed5 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.rs +++ b/tests/mir-opt/const_prop/control_flow_simplification.rs @@ -13,6 +13,7 @@ impl NeedsDrop for This {} fn hello() { // CHECK-LABEL: fn hello( // CHECK: bb0: + // CHECK-NEXT: _0 = const (); // CHECK-NEXT: return; if ::NEEDS { panic!() diff --git a/tests/mir-opt/const_prop/invalid_constant.main.GVN.diff b/tests/mir-opt/const_prop/invalid_constant.main.GVN.diff index 3dc6fc9e3f65b..71e63d852ca0c 100644 --- a/tests/mir-opt/const_prop/invalid_constant.main.GVN.diff +++ b/tests/mir-opt/const_prop/invalid_constant.main.GVN.diff @@ -49,12 +49,13 @@ StorageLive(_8); - _8 = NoVariants { int: const 0_u32 }; + _8 = const NoVariants {{ int: 0_u32, empty: ZeroSized: Empty }}; - nop; - nop; + _7 = const ZeroSized: Empty; +- _6 = [const ZeroSized: Empty]; ++ _6 = const [ZeroSized: Empty]; nop; StorageDead(_8); nop; - nop; + _0 = const (); nop; nop; StorageDead(_3); diff --git a/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff b/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff index c16cbaf4c0f27..3f0d1de0da83d 100644 --- a/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff +++ b/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff @@ -50,17 +50,16 @@ - _7 = copy (_8.1: Empty); - _6 = [move _7]; - StorageDead(_7); -+ nop; -+ nop; ++ _7 = const ZeroSized: Empty; ++ _6 = [const ZeroSized: Empty]; + nop; StorageDead(_8); - StorageLive(_9); -- _0 = const (); ++ nop; + _0 = const (); - StorageDead(_9); - StorageDead(_6); + nop; -+ nop; -+ nop; + nop; StorageDead(_3); StorageDead(_1); diff --git a/tests/mir-opt/const_prop/union.main.GVN.diff b/tests/mir-opt/const_prop/union.main.GVN.diff index 4c3e0bb68fd43..06eb1710921b4 100644 --- a/tests/mir-opt/const_prop/union.main.GVN.diff +++ b/tests/mir-opt/const_prop/union.main.GVN.diff @@ -26,6 +26,7 @@ StorageLive(_4); - _4 = copy (_1.0: u32); + _4 = const 1_u32; + _3 = const (); StorageDead(_4); StorageDead(_3); _0 = const (); diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncEnum.MentionedItems.after.mir b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncEnum.MentionedItems.after.mir index 0041816abd0ff..1932bd634b7b1 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncEnum.MentionedItems.after.mir +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncEnum.MentionedItems.after.mir @@ -59,6 +59,7 @@ yields () } bb1: { + _0 = const (); return; } diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncEnum.StateTransform.diff b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncEnum.StateTransform.diff index 8e6c68598e311..a558009584a82 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncEnum.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncEnum.StateTransform.diff @@ -97,6 +97,8 @@ } bb1: { +- _0 = const (); ++ _51 = const (); + _0 = Poll::<()>::Ready(move _51); + discriminant((*_53)) = 1; return; diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncInt.MentionedItems.after.mir b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncInt.MentionedItems.after.mir index 533dc2634ff2a..c086325336db3 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncInt.MentionedItems.after.mir +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncInt.MentionedItems.after.mir @@ -29,6 +29,7 @@ yields () } bb1: { + _0 = const (); return; } diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncInt.StateTransform.diff b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncInt.StateTransform.diff index 015c275b529f5..57794b4318a5e 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncInt.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncInt.StateTransform.diff @@ -54,6 +54,8 @@ } bb1: { +- _0 = const (); ++ _21 = const (); + _0 = Poll::<()>::Ready(move _21); + discriminant((*_23)) = 1; return; diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncReference_'__.MentionedItems.after.mir b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncReference_'__.MentionedItems.after.mir index fe1e2d66c2cbf..04426e8b66dfe 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncReference_'__.MentionedItems.after.mir +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncReference_'__.MentionedItems.after.mir @@ -29,6 +29,7 @@ yields () } bb1: { + _0 = const (); return; } diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncReference_'__.StateTransform.diff b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncReference_'__.StateTransform.diff index 93b76ad125bb3..c75cf831f9179 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncReference_'__.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncReference_'__.StateTransform.diff @@ -54,6 +54,8 @@ } bb1: { +- _0 = const (); ++ _21 = const (); + _0 = Poll::<()>::Ready(move _21); + discriminant((*_23)) = 1; return; diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncStruct.MentionedItems.after.mir b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncStruct.MentionedItems.after.mir index dcb038b587155..f86d2baa056b0 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncStruct.MentionedItems.after.mir +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncStruct.MentionedItems.after.mir @@ -83,6 +83,7 @@ yields () } bb1: { + _0 = const (); return; } diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncStruct.StateTransform.diff b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncStruct.StateTransform.diff index 339661ef2ce1d..a1de1f8949e74 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncStruct.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.AsyncStruct.StateTransform.diff @@ -124,6 +124,8 @@ } bb1: { +- _0 = const (); ++ _75 = const (); + _0 = Poll::<()>::Ready(move _75); + discriminant((*_77)) = 1; return; diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.Int.MentionedItems.after.mir b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.Int.MentionedItems.after.mir index 7823a862bbded..13d5e10d2855a 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.Int.MentionedItems.after.mir +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.Int.MentionedItems.after.mir @@ -10,6 +10,7 @@ yields () } bb1: { + _0 = const (); return; } } diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.Int.StateTransform.diff b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.Int.StateTransform.diff index be51f11489222..0e2b6b46a91f7 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.Int.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.Int.StateTransform.diff @@ -22,6 +22,7 @@ + let mut _7: std::ptr::NonNull>; bb0: { +- _0 = const (); + _7 = move _2 as std::ptr::NonNull> (Transmute); + _6 = std::future::ResumeTy(move _7); + _5 = copy (_1.0: &mut {async fn body of std::future::async_drop_in_place()}); @@ -39,6 +40,7 @@ + } + + bb3: { ++ _3 = const (); + _0 = Poll::<()>::Ready(move _3); + discriminant((*_5)) = 1; return; diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncInt.MentionedItems.after.mir b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncInt.MentionedItems.after.mir index b958b843c6df0..91efeec1a5977 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncInt.MentionedItems.after.mir +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncInt.MentionedItems.after.mir @@ -12,6 +12,7 @@ yields () } bb1: { + _0 = const (); return; } } diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncInt.StateTransform.diff b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncInt.StateTransform.diff index 2d127c495aba2..cc759752b575b 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncInt.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncInt.StateTransform.diff @@ -33,6 +33,8 @@ } bb1: { +- _0 = const (); ++ _4 = const (); + _0 = Poll::<()>::Ready(move _4); + discriminant((*_6)) = 1; return; diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncThenAsync.MentionedItems.after.mir b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncThenAsync.MentionedItems.after.mir index ad37224d34f9b..4e3b967186dab 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncThenAsync.MentionedItems.after.mir +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncThenAsync.MentionedItems.after.mir @@ -68,6 +68,7 @@ yields () } bb1: { + _0 = const (); return; } diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncThenAsync.StateTransform.diff b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncThenAsync.StateTransform.diff index 6a7ad149f1e82..985870f7e9576 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncThenAsync.StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.SyncThenAsync.StateTransform.diff @@ -106,6 +106,8 @@ } bb1: { +- _0 = const (); ++ _60 = const (); + _0 = Poll::<()>::Ready(move _60); + discriminant((*_62)) = 1; return; diff --git a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.[AsyncInt;2].StateTransform.diff b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.[AsyncInt;2].StateTransform.diff index 7718554895afd..6bcef9a331526 100644 --- a/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.[AsyncInt;2].StateTransform.diff +++ b/tests/mir-opt/coroutine/async_drop.core.future-async_drop-async_drop_in_place-{closure#0}.[AsyncInt;2].StateTransform.diff @@ -84,6 +84,8 @@ } bb1: { +- _0 = const (); ++ _41 = const (); + _0 = Poll::<()>::Ready(move _41); + discriminant((*_43)) = 1; return; diff --git a/tests/mir-opt/coroutine/async_drop_mir_pin.core.future-async_drop-async_drop_in_place-{closure#0}.[Foo;1].MentionedItems.after.mir b/tests/mir-opt/coroutine/async_drop_mir_pin.core.future-async_drop-async_drop_in_place-{closure#0}.[Foo;1].MentionedItems.after.mir index e06189e941211..e9036bf114b03 100644 --- a/tests/mir-opt/coroutine/async_drop_mir_pin.core.future-async_drop-async_drop_in_place-{closure#0}.[Foo;1].MentionedItems.after.mir +++ b/tests/mir-opt/coroutine/async_drop_mir_pin.core.future-async_drop-async_drop_in_place-{closure#0}.[Foo;1].MentionedItems.after.mir @@ -49,6 +49,7 @@ yields () } bb1: { + _0 = const (); return; } diff --git a/tests/mir-opt/coroutine/async_fn.add-{closure#0}-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.add-{closure#0}-{closure#0}.coroutine_drop.0.mir index 4dec40924719b..ff2b0a4812478 100644 --- a/tests/mir-opt/coroutine/async_fn.add-{closure#0}-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.add-{closure#0}-{closure#0}.coroutine_drop.0.mir @@ -15,6 +15,7 @@ fn add::{closure#0}::{closure#0}(_1: &mut {async block@$DIR/async_fn.rs:34:13: 3 bb0: { _8 = discriminant((*_1)); + _0 = const (); switchInt(move _8) -> [0: bb2, otherwise: bb3]; } diff --git a/tests/mir-opt/coroutine/async_fn.add-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.add-{closure#0}.coroutine_drop.0.mir index cd2092e97177a..7b7a2469360d2 100644 --- a/tests/mir-opt/coroutine/async_fn.add-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.add-{closure#0}.coroutine_drop.0.mir @@ -48,6 +48,7 @@ fn add::{closure#0}(_1: &mut {async fn body of add()}) -> () { bb0: { _26 = discriminant((*_1)); + _0 = const (); switchInt(move _26) -> [0: bb11, 3: bb12, otherwise: bb13]; } diff --git a/tests/mir-opt/coroutine/async_fn.build_aggregate-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.build_aggregate-{closure#0}.coroutine_drop.0.mir index d107b3a2dbbbd..5ca617278ce67 100644 --- a/tests/mir-opt/coroutine/async_fn.build_aggregate-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.build_aggregate-{closure#0}.coroutine_drop.0.mir @@ -86,6 +86,7 @@ fn build_aggregate::{closure#0}(_1: &mut {async fn body of build_aggregate()}) - bb0: { _50 = discriminant((*_1)); + _0 = const (); switchInt(move _50) -> [0: bb16, 3: bb17, 4: bb18, otherwise: bb19]; } diff --git a/tests/mir-opt/coroutine/async_fn.foo-{closure#0}-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.foo-{closure#0}-{closure#0}.coroutine_drop.0.mir index a098d65cbc084..156649c264646 100644 --- a/tests/mir-opt/coroutine/async_fn.foo-{closure#0}-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.foo-{closure#0}-{closure#0}.coroutine_drop.0.mir @@ -15,6 +15,7 @@ fn foo::{closure#0}::{closure#0}(_1: &mut {async block@$DIR/async_fn.rs:21:13: 2 bb0: { _8 = discriminant((*_1)); + _0 = const (); switchInt(move _8) -> [0: bb2, otherwise: bb3]; } diff --git a/tests/mir-opt/coroutine/async_fn.foo-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.foo-{closure#0}.coroutine_drop.0.mir index d5d9182fb2071..ae051b6b144a0 100644 --- a/tests/mir-opt/coroutine/async_fn.foo-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.foo-{closure#0}.coroutine_drop.0.mir @@ -72,6 +72,7 @@ fn foo::{closure#0}(_1: &mut {async fn body of foo()}) -> () { bb0: { _35 = discriminant((*_1)); + _0 = const (); switchInt(move _35) -> [0: bb9, 3: bb10, otherwise: bb11]; } diff --git a/tests/mir-opt/coroutine/async_fn.hello_world-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.hello_world-{closure#0}.coroutine_drop.0.mir index b32943d88c10f..8cceffbf2f5bb 100644 --- a/tests/mir-opt/coroutine/async_fn.hello_world-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.hello_world-{closure#0}.coroutine_drop.0.mir @@ -54,6 +54,7 @@ fn hello_world::{closure#0}(_1: &mut {async fn body of hello_world()}) -> () { bb0: { _34 = discriminant((*_1)); + _0 = const (); switchInt(move _34) -> [0: bb9, 3: bb10, otherwise: bb11]; } diff --git a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#0}.coroutine_drop.0.mir index 686b4323e0185..a3c8802306e2e 100644 --- a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#0}.coroutine_drop.0.mir @@ -14,6 +14,7 @@ fn includes_never::{closure#0}::{closure#0}(_1: &mut {async block@$DIR/async_fn. bb0: { _8 = discriminant((*_1)); + _0 = const (); switchInt(move _8) -> [0: bb2, otherwise: bb3]; } diff --git a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#1}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#1}.coroutine_drop.0.mir index 3ae5c1dc89643..260d18f89feab 100644 --- a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#1}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}-{closure#1}.coroutine_drop.0.mir @@ -14,6 +14,7 @@ fn includes_never::{closure#0}::{closure#1}(_1: &mut {async block@$DIR/async_fn. bb0: { _8 = discriminant((*_1)); + _0 = const (); switchInt(move _8) -> [0: bb2, otherwise: bb3]; } diff --git a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}.coroutine_drop.0.mir index 97fdec425898f..de0a2475f0458 100644 --- a/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.includes_never-{closure#0}.coroutine_drop.0.mir @@ -82,6 +82,7 @@ fn includes_never::{closure#0}(_1: &mut {async fn body of includes_never()}) -> bb0: { _49 = discriminant((*_1)); + _0 = const (); switchInt(move _49) -> [0: bb9, 3: bb10, otherwise: bb11]; } diff --git a/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}-{closure#0}.coroutine_drop.0.mir index 7a21ec09f8a10..ae14335b22348 100644 --- a/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}-{closure#0}.coroutine_drop.0.mir @@ -14,6 +14,7 @@ fn partial_init::{closure#0}::{closure#0}(_1: &mut {async block@$DIR/async_fn.rs bb0: { _8 = discriminant((*_1)); + _0 = const (); switchInt(move _8) -> [0: bb2, otherwise: bb3]; } diff --git a/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}.coroutine_drop.0.mir index c76b3ca617f76..b808b5f37e6f1 100644 --- a/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.partial_init-{closure#0}.coroutine_drop.0.mir @@ -47,6 +47,7 @@ fn partial_init::{closure#0}(_1: &mut {async fn body of partial_init()}) -> () { bb0: { _27 = discriminant((*_1)); + _0 = const (); switchInt(move _27) -> [0: bb11, 3: bb12, otherwise: bb13]; } diff --git a/tests/mir-opt/coroutine/async_fn.uninhabited_variant-{closure#0}.coroutine_drop.0.mir b/tests/mir-opt/coroutine/async_fn.uninhabited_variant-{closure#0}.coroutine_drop.0.mir index 19cde28ce35fb..e3a25192eb17f 100644 --- a/tests/mir-opt/coroutine/async_fn.uninhabited_variant-{closure#0}.coroutine_drop.0.mir +++ b/tests/mir-opt/coroutine/async_fn.uninhabited_variant-{closure#0}.coroutine_drop.0.mir @@ -68,6 +68,7 @@ fn uninhabited_variant::{closure#0}(_1: &mut {async fn body of uninhabited_varia bb0: { _45 = discriminant((*_1)); + _0 = const (); switchInt(move _45) -> [0: bb22, 3: bb23, 4: bb24, otherwise: bb25]; } diff --git a/tests/mir-opt/coroutine/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-abort.mir b/tests/mir-opt/coroutine/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-abort.mir index e8873e341cc77..ec34b8750cc0e 100644 --- a/tests/mir-opt/coroutine/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-abort.mir +++ b/tests/mir-opt/coroutine/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-abort.mir @@ -14,6 +14,7 @@ fn main::{closure#0}(_1: &mut {coroutine@$DIR/coroutine_drop_cleanup.rs:12:5: 12 bb0: { _7 = discriminant((*_1)); + _0 = const (); switchInt(move _7) -> [0: bb5, 3: bb6, otherwise: bb7]; } diff --git a/tests/mir-opt/coroutine/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-unwind.mir b/tests/mir-opt/coroutine/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-unwind.mir index 9e450d702cc38..7d2f1c309b416 100644 --- a/tests/mir-opt/coroutine/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-unwind.mir +++ b/tests/mir-opt/coroutine/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-unwind.mir @@ -14,6 +14,7 @@ fn main::{closure#0}(_1: &mut {coroutine@$DIR/coroutine_drop_cleanup.rs:12:5: 12 bb0: { _7 = discriminant((*_1)); + _0 = const (); switchInt(move _7) -> [0: bb7, 3: bb8, otherwise: bb9]; } diff --git a/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff index dc0004105a7b7..60d26b422000d 100644 --- a/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff @@ -15,6 +15,7 @@ StorageLive(_1); - _1 = foo() -> [return: bb1, unwind continue]; + StorageLive(_2); ++ _2 = const D; + asm!("", options(MAY_UNWIND)) -> [return: bb2, unwind: bb3]; } @@ -26,6 +27,7 @@ + } + + bb2: { ++ _1 = const (); + drop(_2) -> [return: bb1, unwind continue]; + } + diff --git a/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-abort.diff b/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-abort.diff index 3ffe2ee0c0b94..82c1945bbc71c 100644 --- a/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-abort.diff @@ -56,10 +56,15 @@ + StorageLive(_17); + StorageLive(_18); + StorageLive(_19); -+ _17 = <() as A>::call() -> [return: bb12, unwind unreachable]; ++ _17 = <() as A>::call() -> [return: bb11, unwind unreachable]; } bb1: { ++ _4 = <() as F>::call() -> [return: bb2, unwind unreachable]; ++ } ++ ++ bb2: { ++ _1 = const (); + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); @@ -68,67 +73,68 @@ return; + } + -+ bb2: { -+ _4 = <() as F>::call() -> [return: bb1, unwind unreachable]; ++ bb3: { ++ _7 = <() as E>::call() -> [return: bb4, unwind unreachable]; + } + -+ bb3: { ++ bb4: { ++ _2 = const (); + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); -+ _3 = <() as F>::call() -> [return: bb2, unwind unreachable]; ++ _3 = <() as F>::call() -> [return: bb1, unwind unreachable]; + } + -+ bb4: { -+ _7 = <() as E>::call() -> [return: bb3, unwind unreachable]; ++ bb5: { ++ _10 = <() as D>::call() -> [return: bb6, unwind unreachable]; + } + -+ bb5: { ++ bb6: { ++ _5 = const (); + StorageDead(_10); + StorageDead(_9); + StorageDead(_8); -+ _6 = <() as E>::call() -> [return: bb4, unwind unreachable]; ++ _6 = <() as E>::call() -> [return: bb3, unwind unreachable]; + } + -+ bb6: { -+ _10 = <() as D>::call() -> [return: bb5, unwind unreachable]; ++ bb7: { ++ _13 = <() as C>::call() -> [return: bb8, unwind unreachable]; + } + -+ bb7: { ++ bb8: { ++ _8 = const (); + StorageDead(_13); + StorageDead(_12); + StorageDead(_11); -+ _9 = <() as D>::call() -> [return: bb6, unwind unreachable]; ++ _9 = <() as D>::call() -> [return: bb5, unwind unreachable]; + } + -+ bb8: { -+ _13 = <() as C>::call() -> [return: bb7, unwind unreachable]; ++ bb9: { ++ _16 = <() as B>::call() -> [return: bb10, unwind unreachable]; + } + -+ bb9: { ++ bb10: { ++ _11 = const (); + StorageDead(_16); + StorageDead(_15); + StorageDead(_14); -+ _12 = <() as C>::call() -> [return: bb8, unwind unreachable]; -+ } -+ -+ bb10: { -+ _16 = <() as B>::call() -> [return: bb9, unwind unreachable]; ++ _12 = <() as C>::call() -> [return: bb7, unwind unreachable]; + } + + bb11: { -+ StorageDead(_19); -+ StorageDead(_18); -+ StorageDead(_17); -+ _15 = <() as B>::call() -> [return: bb10, unwind unreachable]; ++ _18 = <() as A>::call() -> [return: bb12, unwind unreachable]; + } + + bb12: { -+ _18 = <() as A>::call() -> [return: bb13, unwind unreachable]; ++ _19 = <() as A>::call() -> [return: bb13, unwind unreachable]; + } + + bb13: { -+ _19 = <() as A>::call() -> [return: bb11, unwind unreachable]; ++ _14 = const (); ++ StorageDead(_19); ++ StorageDead(_18); ++ StorageDead(_17); ++ _15 = <() as B>::call() -> [return: bb9, unwind unreachable]; } } diff --git a/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-unwind.diff index 3f334779e18f8..d3a8d4df681cb 100644 --- a/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-unwind.diff @@ -56,10 +56,15 @@ + StorageLive(_17); + StorageLive(_18); + StorageLive(_19); -+ _17 = <() as A>::call() -> [return: bb12, unwind continue]; ++ _17 = <() as A>::call() -> [return: bb11, unwind continue]; } bb1: { ++ _4 = <() as F>::call() -> [return: bb2, unwind continue]; ++ } ++ ++ bb2: { ++ _1 = const (); + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); @@ -68,67 +73,68 @@ return; + } + -+ bb2: { -+ _4 = <() as F>::call() -> [return: bb1, unwind continue]; ++ bb3: { ++ _7 = <() as E>::call() -> [return: bb4, unwind continue]; + } + -+ bb3: { ++ bb4: { ++ _2 = const (); + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); -+ _3 = <() as F>::call() -> [return: bb2, unwind continue]; ++ _3 = <() as F>::call() -> [return: bb1, unwind continue]; + } + -+ bb4: { -+ _7 = <() as E>::call() -> [return: bb3, unwind continue]; ++ bb5: { ++ _10 = <() as D>::call() -> [return: bb6, unwind continue]; + } + -+ bb5: { ++ bb6: { ++ _5 = const (); + StorageDead(_10); + StorageDead(_9); + StorageDead(_8); -+ _6 = <() as E>::call() -> [return: bb4, unwind continue]; ++ _6 = <() as E>::call() -> [return: bb3, unwind continue]; + } + -+ bb6: { -+ _10 = <() as D>::call() -> [return: bb5, unwind continue]; ++ bb7: { ++ _13 = <() as C>::call() -> [return: bb8, unwind continue]; + } + -+ bb7: { ++ bb8: { ++ _8 = const (); + StorageDead(_13); + StorageDead(_12); + StorageDead(_11); -+ _9 = <() as D>::call() -> [return: bb6, unwind continue]; ++ _9 = <() as D>::call() -> [return: bb5, unwind continue]; + } + -+ bb8: { -+ _13 = <() as C>::call() -> [return: bb7, unwind continue]; ++ bb9: { ++ _16 = <() as B>::call() -> [return: bb10, unwind continue]; + } + -+ bb9: { ++ bb10: { ++ _11 = const (); + StorageDead(_16); + StorageDead(_15); + StorageDead(_14); -+ _12 = <() as C>::call() -> [return: bb8, unwind continue]; -+ } -+ -+ bb10: { -+ _16 = <() as B>::call() -> [return: bb9, unwind continue]; ++ _12 = <() as C>::call() -> [return: bb7, unwind continue]; + } + + bb11: { -+ StorageDead(_19); -+ StorageDead(_18); -+ StorageDead(_17); -+ _15 = <() as B>::call() -> [return: bb10, unwind continue]; ++ _18 = <() as A>::call() -> [return: bb12, unwind continue]; + } + + bb12: { -+ _18 = <() as A>::call() -> [return: bb13, unwind continue]; ++ _19 = <() as A>::call() -> [return: bb13, unwind continue]; + } + + bb13: { -+ _19 = <() as A>::call() -> [return: bb11, unwind continue]; ++ _14 = const (); ++ StorageDead(_19); ++ StorageDead(_18); ++ StorageDead(_17); ++ _15 = <() as B>::call() -> [return: bb9, unwind continue]; } } diff --git a/tests/mir-opt/inline/forced.caller.ForceInline.panic-abort.diff b/tests/mir-opt/inline/forced.caller.ForceInline.panic-abort.diff index f894f06e5a0ab..3e7acb259e35c 100644 --- a/tests/mir-opt/inline/forced.caller.ForceInline.panic-abort.diff +++ b/tests/mir-opt/inline/forced.caller.ForceInline.panic-abort.diff @@ -13,6 +13,7 @@ - } - - bb1: { ++ _1 = const (); StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/inline/forced.caller.ForceInline.panic-unwind.diff b/tests/mir-opt/inline/forced.caller.ForceInline.panic-unwind.diff index 7b70fd665666a..4fa91544345a8 100644 --- a/tests/mir-opt/inline/forced.caller.ForceInline.panic-unwind.diff +++ b/tests/mir-opt/inline/forced.caller.ForceInline.panic-unwind.diff @@ -13,6 +13,7 @@ - } - - bb1: { ++ _1 = const (); StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/inline/forced_closure.caller-{closure#0}.ForceInline.panic-abort.diff b/tests/mir-opt/inline/forced_closure.caller-{closure#0}.ForceInline.panic-abort.diff index def2375efd068..97e06736d72f0 100644 --- a/tests/mir-opt/inline/forced_closure.caller-{closure#0}.ForceInline.panic-abort.diff +++ b/tests/mir-opt/inline/forced_closure.caller-{closure#0}.ForceInline.panic-abort.diff @@ -13,6 +13,7 @@ - } - - bb1: { ++ _2 = const (); StorageDead(_2); _0 = const (); return; diff --git a/tests/mir-opt/inline/forced_closure.caller-{closure#0}.ForceInline.panic-unwind.diff b/tests/mir-opt/inline/forced_closure.caller-{closure#0}.ForceInline.panic-unwind.diff index 8f50c20587d70..ccc33422f7b64 100644 --- a/tests/mir-opt/inline/forced_closure.caller-{closure#0}.ForceInline.panic-unwind.diff +++ b/tests/mir-opt/inline/forced_closure.caller-{closure#0}.ForceInline.panic-unwind.diff @@ -13,6 +13,7 @@ - } - - bb1: { ++ _2 = const (); StorageDead(_2); _0 = const (); return; diff --git a/tests/mir-opt/inline/forced_closure_inherent.caller-{closure#0}.ForceInline.panic-abort.diff b/tests/mir-opt/inline/forced_closure_inherent.caller-{closure#0}.ForceInline.panic-abort.diff index 8e03432c2af2d..43c43a6d8a977 100644 --- a/tests/mir-opt/inline/forced_closure_inherent.caller-{closure#0}.ForceInline.panic-abort.diff +++ b/tests/mir-opt/inline/forced_closure_inherent.caller-{closure#0}.ForceInline.panic-abort.diff @@ -13,6 +13,7 @@ - } - - bb1: { ++ _2 = const (); StorageDead(_2); _0 = const (); return; diff --git a/tests/mir-opt/inline/forced_closure_inherent.caller-{closure#0}.ForceInline.panic-unwind.diff b/tests/mir-opt/inline/forced_closure_inherent.caller-{closure#0}.ForceInline.panic-unwind.diff index 0e41fd89dacf7..b9cc22c72ffe3 100644 --- a/tests/mir-opt/inline/forced_closure_inherent.caller-{closure#0}.ForceInline.panic-unwind.diff +++ b/tests/mir-opt/inline/forced_closure_inherent.caller-{closure#0}.ForceInline.panic-unwind.diff @@ -13,6 +13,7 @@ - } - - bb1: { ++ _2 = const (); StorageDead(_2); _0 = const (); return; diff --git a/tests/mir-opt/inline/forced_dead_code.caller.ForceInline.panic-abort.diff b/tests/mir-opt/inline/forced_dead_code.caller.ForceInline.panic-abort.diff index f894f06e5a0ab..3e7acb259e35c 100644 --- a/tests/mir-opt/inline/forced_dead_code.caller.ForceInline.panic-abort.diff +++ b/tests/mir-opt/inline/forced_dead_code.caller.ForceInline.panic-abort.diff @@ -13,6 +13,7 @@ - } - - bb1: { ++ _1 = const (); StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/inline/forced_dead_code.caller.ForceInline.panic-unwind.diff b/tests/mir-opt/inline/forced_dead_code.caller.ForceInline.panic-unwind.diff index 7b70fd665666a..4fa91544345a8 100644 --- a/tests/mir-opt/inline/forced_dead_code.caller.ForceInline.panic-unwind.diff +++ b/tests/mir-opt/inline/forced_dead_code.caller.ForceInline.panic-unwind.diff @@ -13,6 +13,7 @@ - } - - bb1: { ++ _1 = const (); StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/inline/forced_inherent.caller.ForceInline.panic-abort.diff b/tests/mir-opt/inline/forced_inherent.caller.ForceInline.panic-abort.diff index 6ea1894af9895..06c16e9528b42 100644 --- a/tests/mir-opt/inline/forced_inherent.caller.ForceInline.panic-abort.diff +++ b/tests/mir-opt/inline/forced_inherent.caller.ForceInline.panic-abort.diff @@ -13,6 +13,7 @@ - } - - bb1: { ++ _1 = const (); StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/inline/forced_inherent.caller.ForceInline.panic-unwind.diff b/tests/mir-opt/inline/forced_inherent.caller.ForceInline.panic-unwind.diff index dd91c3387723f..93a7a4b8f7656 100644 --- a/tests/mir-opt/inline/forced_inherent.caller.ForceInline.panic-unwind.diff +++ b/tests/mir-opt/inline/forced_inherent.caller.ForceInline.panic-unwind.diff @@ -13,6 +13,7 @@ - } - - bb1: { ++ _1 = const (); StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/inline/forced_inherent_ambiguous.caller.ForceInline.panic-abort.diff b/tests/mir-opt/inline/forced_inherent_ambiguous.caller.ForceInline.panic-abort.diff index 6ea1894af9895..06c16e9528b42 100644 --- a/tests/mir-opt/inline/forced_inherent_ambiguous.caller.ForceInline.panic-abort.diff +++ b/tests/mir-opt/inline/forced_inherent_ambiguous.caller.ForceInline.panic-abort.diff @@ -13,6 +13,7 @@ - } - - bb1: { ++ _1 = const (); StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/inline/forced_inherent_ambiguous.caller.ForceInline.panic-unwind.diff b/tests/mir-opt/inline/forced_inherent_ambiguous.caller.ForceInline.panic-unwind.diff index dd91c3387723f..93a7a4b8f7656 100644 --- a/tests/mir-opt/inline/forced_inherent_ambiguous.caller.ForceInline.panic-unwind.diff +++ b/tests/mir-opt/inline/forced_inherent_ambiguous.caller.ForceInline.panic-unwind.diff @@ -13,6 +13,7 @@ - } - - bb1: { ++ _1 = const (); StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/inline/forced_inherent_dead_code.caller.ForceInline.panic-abort.diff b/tests/mir-opt/inline/forced_inherent_dead_code.caller.ForceInline.panic-abort.diff index edaf2820d85c3..1f6e8c6331d7c 100644 --- a/tests/mir-opt/inline/forced_inherent_dead_code.caller.ForceInline.panic-abort.diff +++ b/tests/mir-opt/inline/forced_inherent_dead_code.caller.ForceInline.panic-abort.diff @@ -13,6 +13,7 @@ - } - - bb1: { ++ _1 = const (); StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/inline/forced_inherent_dead_code.caller.ForceInline.panic-unwind.diff b/tests/mir-opt/inline/forced_inherent_dead_code.caller.ForceInline.panic-unwind.diff index 22f8b14a724b8..b7f2f0dec6694 100644 --- a/tests/mir-opt/inline/forced_inherent_dead_code.caller.ForceInline.panic-unwind.diff +++ b/tests/mir-opt/inline/forced_inherent_dead_code.caller.ForceInline.panic-unwind.diff @@ -13,6 +13,7 @@ - } - - bb1: { ++ _1 = const (); StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/inline/inline_compatibility.rs b/tests/mir-opt/inline/inline_compatibility.rs index 3f72584017abd..43875669be3c7 100644 --- a/tests/mir-opt/inline/inline_compatibility.rs +++ b/tests/mir-opt/inline/inline_compatibility.rs @@ -15,6 +15,7 @@ fn nop() {} // CHECK-LABEL: fn f0() // CHECK: bb0: { +// CHECK-NEXT: _0 = const (); // CHECK-NEXT: return; #[target_feature(enable = "sse2")] pub unsafe fn f0() { @@ -42,6 +43,7 @@ pub unsafe fn sanitize_off() {} // CHECK-LABEL: fn inlined_sanitize_off() // CHECK: bb0: { +// CHECK-NEXT: _0 = const (); // CHECK-NEXT: return; #[sanitize(address = "off")] pub unsafe fn inlined_sanitize_off() { diff --git a/tests/mir-opt/inline/inline_cycle.two.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_cycle.two.Inline.panic-abort.diff index c878b8b632414..341ecf729775e 100644 --- a/tests/mir-opt/inline/inline_cycle.two.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_cycle.two.Inline.panic-abort.diff @@ -29,8 +29,10 @@ } bb1: { ++ _3 = const (); + StorageDead(_5); + StorageDead(_4); ++ _1 = const (); + StorageDead(_3); + StorageDead(_2); StorageDead(_1); diff --git a/tests/mir-opt/inline/inline_cycle.two.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_cycle.two.Inline.panic-unwind.diff index 072b7ab3fa491..494e2b3fa01e6 100644 --- a/tests/mir-opt/inline/inline_cycle.two.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_cycle.two.Inline.panic-unwind.diff @@ -29,8 +29,10 @@ } bb1: { ++ _3 = const (); + StorageDead(_5); + StorageDead(_4); ++ _1 = const (); + StorageDead(_3); + StorageDead(_2); StorageDead(_1); diff --git a/tests/mir-opt/inline/inline_empty_drop_glue.rs b/tests/mir-opt/inline/inline_empty_drop_glue.rs index ad7dbb06da1eb..1f710f7f2716d 100644 --- a/tests/mir-opt/inline/inline_empty_drop_glue.rs +++ b/tests/mir-opt/inline/inline_empty_drop_glue.rs @@ -6,6 +6,7 @@ unsafe fn slice_in_place(ptr: *mut [char]) { // CHECK-LABEL: fn slice_in_place(_1: *mut [char]) // CHECK: bb0: { + // CHECK-NEXT: _0 = const (); // CHECK-NEXT: return; // CHECK-NEXT: } std::ptr::drop_in_place(ptr) diff --git a/tests/mir-opt/inline/inline_empty_drop_glue.slice_in_place.Inline.diff b/tests/mir-opt/inline/inline_empty_drop_glue.slice_in_place.Inline.diff index 2b5cbe6e44820..9f8aad1e2350a 100644 --- a/tests/mir-opt/inline/inline_empty_drop_glue.slice_in_place.Inline.diff +++ b/tests/mir-opt/inline/inline_empty_drop_glue.slice_in_place.Inline.diff @@ -20,6 +20,7 @@ - bb1: { + StorageLive(_3); + _3 = &mut (*_2); ++ _0 = const (); + StorageDead(_3); StorageDead(_2); return; diff --git a/tests/mir-opt/inline/inline_instruction_set.default.Inline.diff b/tests/mir-opt/inline/inline_instruction_set.default.Inline.diff index 158cc973779c8..b48fb31e0e199 100644 --- a/tests/mir-opt/inline/inline_instruction_set.default.Inline.diff +++ b/tests/mir-opt/inline/inline_instruction_set.default.Inline.diff @@ -30,6 +30,7 @@ - } - - bb3: { ++ _3 = const (); StorageDead(_3); StorageLive(_4); - _4 = inline_always_and_using_inline_asm() -> [return: bb4, unwind unreachable]; @@ -38,6 +39,7 @@ - bb4: { + bb3: { ++ _4 = const (); StorageDead(_4); _0 = const (); return; diff --git a/tests/mir-opt/inline/inline_instruction_set.t32.Inline.diff b/tests/mir-opt/inline/inline_instruction_set.t32.Inline.diff index 33dc116f622e1..ae528f383929b 100644 --- a/tests/mir-opt/inline/inline_instruction_set.t32.Inline.diff +++ b/tests/mir-opt/inline/inline_instruction_set.t32.Inline.diff @@ -24,12 +24,14 @@ - } - - bb2: { ++ _2 = const (); StorageDead(_2); StorageLive(_3); - _3 = instruction_set_default() -> [return: bb3, unwind unreachable]; - } - - bb3: { ++ _3 = const (); StorageDead(_3); StorageLive(_4); - _4 = inline_always_and_using_inline_asm() -> [return: bb4, unwind unreachable]; diff --git a/tests/mir-opt/inline/inline_more_in_non_inline.marked_inline_indirect.Inline.after.panic-abort.mir b/tests/mir-opt/inline/inline_more_in_non_inline.marked_inline_indirect.Inline.after.panic-abort.mir index 374ed294d8b26..38d32b0f8dde3 100644 --- a/tests/mir-opt/inline/inline_more_in_non_inline.marked_inline_indirect.Inline.after.panic-abort.mir +++ b/tests/mir-opt/inline/inline_more_in_non_inline.marked_inline_indirect.Inline.after.panic-abort.mir @@ -18,6 +18,7 @@ fn marked_inline_indirect(_1: i32) -> () { } bb1: { + _2 = const (); StorageDead(_4); StorageDead(_3); StorageDead(_2); diff --git a/tests/mir-opt/inline/inline_more_in_non_inline.marked_inline_indirect.Inline.after.panic-unwind.mir b/tests/mir-opt/inline/inline_more_in_non_inline.marked_inline_indirect.Inline.after.panic-unwind.mir index 97bed8020bad7..3004e498c7fcc 100644 --- a/tests/mir-opt/inline/inline_more_in_non_inline.marked_inline_indirect.Inline.after.panic-unwind.mir +++ b/tests/mir-opt/inline/inline_more_in_non_inline.marked_inline_indirect.Inline.after.panic-unwind.mir @@ -18,6 +18,7 @@ fn marked_inline_indirect(_1: i32) -> () { } bb1: { + _2 = const (); StorageDead(_4); StorageDead(_3); StorageDead(_2); diff --git a/tests/mir-opt/inline/inline_more_in_non_inline.monomorphic_not_inline.Inline.after.panic-abort.mir b/tests/mir-opt/inline/inline_more_in_non_inline.monomorphic_not_inline.Inline.after.panic-abort.mir index cffe0e96f5c94..0cecc66a32218 100644 --- a/tests/mir-opt/inline/inline_more_in_non_inline.monomorphic_not_inline.Inline.after.panic-abort.mir +++ b/tests/mir-opt/inline/inline_more_in_non_inline.monomorphic_not_inline.Inline.after.panic-abort.mir @@ -16,10 +16,15 @@ fn monomorphic_not_inline(_1: i32) -> () { _3 = copy _1; StorageLive(_4); StorageLive(_5); - _4 = other_thing(copy _3) -> [return: bb2, unwind unreachable]; + _4 = other_thing(copy _3) -> [return: bb1, unwind unreachable]; } bb1: { + _5 = other_thing(move _3) -> [return: bb2, unwind unreachable]; + } + + bb2: { + _2 = const (); StorageDead(_5); StorageDead(_4); StorageDead(_3); @@ -27,8 +32,4 @@ fn monomorphic_not_inline(_1: i32) -> () { _0 = const (); return; } - - bb2: { - _5 = other_thing(move _3) -> [return: bb1, unwind unreachable]; - } } diff --git a/tests/mir-opt/inline/inline_more_in_non_inline.monomorphic_not_inline.Inline.after.panic-unwind.mir b/tests/mir-opt/inline/inline_more_in_non_inline.monomorphic_not_inline.Inline.after.panic-unwind.mir index 7f3a093012bcd..898bbdfc13d04 100644 --- a/tests/mir-opt/inline/inline_more_in_non_inline.monomorphic_not_inline.Inline.after.panic-unwind.mir +++ b/tests/mir-opt/inline/inline_more_in_non_inline.monomorphic_not_inline.Inline.after.panic-unwind.mir @@ -16,10 +16,15 @@ fn monomorphic_not_inline(_1: i32) -> () { _3 = copy _1; StorageLive(_4); StorageLive(_5); - _4 = other_thing(copy _3) -> [return: bb2, unwind continue]; + _4 = other_thing(copy _3) -> [return: bb1, unwind continue]; } bb1: { + _5 = other_thing(move _3) -> [return: bb2, unwind continue]; + } + + bb2: { + _2 = const (); StorageDead(_5); StorageDead(_4); StorageDead(_3); @@ -27,8 +32,4 @@ fn monomorphic_not_inline(_1: i32) -> () { _0 = const (); return; } - - bb2: { - _5 = other_thing(move _3) -> [return: bb1, unwind continue]; - } } diff --git a/tests/mir-opt/inline/inline_options.main.Inline.after.panic-abort.mir b/tests/mir-opt/inline/inline_options.main.Inline.after.panic-abort.mir index 3218c4e567378..8080157239fda 100644 --- a/tests/mir-opt/inline/inline_options.main.Inline.after.panic-abort.mir +++ b/tests/mir-opt/inline/inline_options.main.Inline.after.panic-abort.mir @@ -21,23 +21,24 @@ fn main() -> () { StorageLive(_3); StorageLive(_4); StorageLive(_5); - _3 = g() -> [return: bb3, unwind unreachable]; + _3 = g() -> [return: bb2, unwind unreachable]; } bb2: { - StorageDead(_5); - StorageDead(_4); - StorageDead(_3); - StorageDead(_2); - _0 = const (); - return; + _4 = g() -> [return: bb3, unwind unreachable]; } bb3: { - _4 = g() -> [return: bb4, unwind unreachable]; + _5 = g() -> [return: bb4, unwind unreachable]; } bb4: { - _5 = g() -> [return: bb2, unwind unreachable]; + _2 = const (); + StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); + _0 = const (); + return; } } diff --git a/tests/mir-opt/inline/inline_options.main.Inline.after.panic-unwind.mir b/tests/mir-opt/inline/inline_options.main.Inline.after.panic-unwind.mir index df0cab513eca7..1cec7a885005e 100644 --- a/tests/mir-opt/inline/inline_options.main.Inline.after.panic-unwind.mir +++ b/tests/mir-opt/inline/inline_options.main.Inline.after.panic-unwind.mir @@ -21,23 +21,24 @@ fn main() -> () { StorageLive(_3); StorageLive(_4); StorageLive(_5); - _3 = g() -> [return: bb3, unwind continue]; + _3 = g() -> [return: bb2, unwind continue]; } bb2: { - StorageDead(_5); - StorageDead(_4); - StorageDead(_3); - StorageDead(_2); - _0 = const (); - return; + _4 = g() -> [return: bb3, unwind continue]; } bb3: { - _4 = g() -> [return: bb4, unwind continue]; + _5 = g() -> [return: bb4, unwind continue]; } bb4: { - _5 = g() -> [return: bb2, unwind continue]; + _2 = const (); + StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); + _0 = const (); + return; } } diff --git a/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff index a7cf6a7733083..4d138fcbede7d 100644 --- a/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff @@ -13,49 +13,13 @@ + scope 2 (inlined std::ptr::drop_glue::> - shim(Some(Vec))) { + let mut _7: &mut std::vec::Vec; + let mut _8: (); -+ scope 3 (inlined as Drop>::drop) { -+ let mut _9: *mut [A]; -+ let mut _10: *mut A; -+ let mut _11: usize; -+ scope 4 (inlined Vec::::as_mut_ptr) { -+ scope 5 (inlined alloc::raw_vec::RawVec::::ptr) { -+ scope 6 (inlined alloc::raw_vec::RawVecInner::ptr::) { -+ scope 7 (inlined alloc::raw_vec::RawVecInner::non_null::) { -+ let mut _12: std::ptr::NonNull; -+ scope 8 (inlined NonNull::::cast::) { -+ scope 9 (inlined NonNull::::as_ptr) { -+ } -+ } -+ } -+ scope 10 (inlined NonNull::::as_ptr) { -+ } -+ } -+ } -+ } -+ scope 11 (inlined std::ptr::mut_ptr::::cast_slice) { -+ scope 12 (inlined slice_from_raw_parts_mut::) { -+ scope 13 (inlined std::ptr::from_raw_parts_mut::<[A], A>) { -+ } -+ } -+ } -+ scope 14 (inlined std::ptr::mut_ptr::::drop_in_place) { -+ scope 15 (inlined drop_in_place::<[A]>) { -+ let mut _13: &mut [A]; -+ scope 16 (inlined std::ptr::drop_glue::<[A]> - shim(Some([A]))) { -+ let mut _14: usize; -+ let mut _15: *mut A; -+ let mut _16: bool; -+ } -+ } -+ } -+ } + } + } -+ scope 17 (inlined drop_in_place::>) { -+ let mut _17: &mut std::option::Option; -+ scope 18 (inlined std::ptr::drop_glue::> - shim(Some(Option))) { -+ let mut _18: isize; -+ let mut _19: isize; ++ scope 3 (inlined drop_in_place::>) { ++ let mut _9: &mut std::option::Option; ++ scope 4 (inlined std::ptr::drop_glue::> - shim(Some(Option))) { ++ let mut _10: isize; ++ let mut _11: isize; + } + } @@ -69,26 +33,11 @@ + StorageLive(_7); + StorageLive(_8); + _7 = copy _6; -+ StorageLive(_11); -+ StorageLive(_9); -+ StorageLive(_10); -+ StorageLive(_12); -+ _12 = copy ((((*_7).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::NonNull); -+ _10 = copy _12 as *mut A (Transmute); -+ StorageDead(_12); -+ _11 = copy ((*_7).1: usize); -+ _9 = *mut [A] from (copy _10, copy _11); -+ StorageDead(_10); -+ StorageLive(_13); -+ _13 = &mut (*_9); -+ StorageLive(_14); -+ StorageLive(_15); -+ StorageLive(_16); -+ _14 = const 0_usize; -+ goto -> bb4; ++ _8 = as Drop>::drop(move _7) -> [return: bb2, unwind unreachable]; } bb1: { ++ _3 = const (); + StorageDead(_8); + StorageDead(_7); + StorageDead(_6); @@ -97,43 +46,27 @@ StorageLive(_5); _5 = copy _2; - _0 = drop_in_place::>(move _5) -> [return: bb2, unwind unreachable]; -+ StorageLive(_17); -+ _17 = &mut (*_5); -+ StorageLive(_18); -+ _18 = discriminant((*_17)); -+ switchInt(move _18) -> [0: bb5, otherwise: bb6]; ++ StorageLive(_9); ++ _9 = &mut (*_5); ++ StorageLive(_10); ++ _10 = discriminant((*_9)); ++ switchInt(move _10) -> [0: bb3, otherwise: bb4]; } bb2: { -+ StorageDead(_16); -+ StorageDead(_15); -+ StorageDead(_14); -+ StorageDead(_13); -+ StorageDead(_9); -+ StorageDead(_11); + drop(((*_6).0: alloc::raw_vec::RawVec)) -> [return: bb1, unwind unreachable]; + } + + bb3: { -+ _15 = &raw mut (*_13)[_14]; -+ _14 = Add(move _14, const 1_usize); -+ drop((*_15)) -> [return: bb4, unwind unreachable]; -+ } -+ -+ bb4: { -+ _16 = Eq(copy _14, copy _11); -+ switchInt(move _16) -> [0: bb3, otherwise: bb2]; -+ } -+ -+ bb5: { -+ StorageDead(_18); -+ StorageDead(_17); ++ _0 = const (); ++ StorageDead(_10); ++ StorageDead(_9); StorageDead(_5); return; + } + -+ bb6: { -+ drop((((*_17) as Some).0: B)) -> [return: bb5, unwind unreachable]; ++ bb4: { ++ drop((((*_9) as Some).0: B)) -> [return: bb3, unwind unreachable]; } } diff --git a/tests/mir-opt/inline/inline_shims.drop.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_shims.drop.Inline.panic-unwind.diff index 2160cd19652e3..d4b1f0623c4fb 100644 --- a/tests/mir-opt/inline/inline_shims.drop.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_shims.drop.Inline.panic-unwind.diff @@ -44,6 +44,7 @@ } bb2: { ++ _0 = const (); + StorageDead(_8); + StorageDead(_7); StorageDead(_5); diff --git a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir index 63d3ae2a86987..5b792379254de 100644 --- a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir +++ b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir @@ -28,6 +28,7 @@ fn main() -> () { _3 = (move _4,); StorageLive(_5); _5 = move (_3.0: ()); + _0 = const (); StorageDead(_5); StorageDead(_4); StorageDead(_3); diff --git a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff index 14a0c639c3abd..0f16de7ed5f92 100644 --- a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff @@ -23,6 +23,7 @@ - } - - bb1: { ++ _4 = foo; _3 = &_4; StorageLive(_5); _5 = (); @@ -30,6 +31,7 @@ - } - - bb2: { ++ _2 = const (); StorageDead(_5); StorageDead(_3); StorageDead(_4); diff --git a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff index e0a273eb13f50..d79765ed6a6fa 100644 --- a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff @@ -23,6 +23,7 @@ - } - - bb1: { ++ _4 = foo; _3 = &_4; StorageLive(_5); _5 = (); @@ -30,6 +31,7 @@ - } - - bb2: { ++ _2 = const (); StorageDead(_5); StorageDead(_3); StorageDead(_4); diff --git a/tests/mir-opt/inline/rustc_no_mir_inline.caller.runtime-optimized.after.panic-abort.mir b/tests/mir-opt/inline/rustc_no_mir_inline.caller.runtime-optimized.after.panic-abort.mir index f6a6e86bff26a..2b49d78d8c9d4 100644 --- a/tests/mir-opt/inline/rustc_no_mir_inline.caller.runtime-optimized.after.panic-abort.mir +++ b/tests/mir-opt/inline/rustc_no_mir_inline.caller.runtime-optimized.after.panic-abort.mir @@ -9,6 +9,7 @@ fn caller() -> () { } bb1: { + _0 = const (); return; } } diff --git a/tests/mir-opt/inline/rustc_no_mir_inline.caller.runtime-optimized.after.panic-unwind.mir b/tests/mir-opt/inline/rustc_no_mir_inline.caller.runtime-optimized.after.panic-unwind.mir index c8703ce515989..c991c6a3737ea 100644 --- a/tests/mir-opt/inline/rustc_no_mir_inline.caller.runtime-optimized.after.panic-unwind.mir +++ b/tests/mir-opt/inline/rustc_no_mir_inline.caller.runtime-optimized.after.panic-unwind.mir @@ -9,6 +9,7 @@ fn caller() -> () { } bb1: { + _0 = const (); return; } } diff --git a/tests/mir-opt/instsimplify/intrinsic_asserts.removable.InstSimplify-after-simplifycfg.diff b/tests/mir-opt/instsimplify/intrinsic_asserts.removable.InstSimplify-after-simplifycfg.diff index 20e046d8e194b..ef9385b1c8457 100644 --- a/tests/mir-opt/instsimplify/intrinsic_asserts.removable.InstSimplify-after-simplifycfg.diff +++ b/tests/mir-opt/instsimplify/intrinsic_asserts.removable.InstSimplify-after-simplifycfg.diff @@ -10,6 +10,7 @@ bb0: { StorageLive(_1); - _1 = assert_inhabited::<()>() -> [return: bb1, unwind unreachable]; ++ _1 = const (); + goto -> bb1; } @@ -17,6 +18,7 @@ StorageDead(_1); StorageLive(_2); - _2 = assert_zero_valid::() -> [return: bb2, unwind unreachable]; ++ _2 = const (); + goto -> bb2; } @@ -24,6 +26,7 @@ StorageDead(_2); StorageLive(_3); - _3 = assert_mem_uninitialized_valid::() -> [return: bb3, unwind unreachable]; ++ _3 = const (); + goto -> bb3; } diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff index 95f9b5997d4f6..cf95976e764b5 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff @@ -38,6 +38,7 @@ // DBG: _5 = &(*_2)[0 of 3]; // DBG: _6 = &(*_2)[1 of 3]; // DBG: _7 = &(*_2)[2 of 3]; + _0 = const (); StorageDead(_4); return; } diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff index 87449b043fd5e..886eab2a4ffde 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff @@ -38,6 +38,7 @@ // DBG: _5 = &(*_2)[0 of 3]; // DBG: _6 = &(*_2)[1 of 3]; // DBG: _7 = &(*_2)[2 of 3]; + _0 = const (); StorageDead(_4); return; } diff --git a/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.panic-abort.diff b/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.panic-abort.diff index 6c1f457cb5f50..2c83ba9629c01 100644 --- a/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.panic-abort.diff +++ b/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.panic-abort.diff @@ -9,6 +9,7 @@ StorageLive(_1); - _1 = std::intrinsics::assume(const true) -> [return: bb1, unwind unreachable]; + assume(const true); ++ _1 = const (); + goto -> bb1; } diff --git a/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.panic-unwind.diff b/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.panic-unwind.diff index 6c1f457cb5f50..2c83ba9629c01 100644 --- a/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.panic-unwind.diff +++ b/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.panic-unwind.diff @@ -9,6 +9,7 @@ StorageLive(_1); - _1 = std::intrinsics::assume(const true) -> [return: bb1, unwind unreachable]; + assume(const true); ++ _1 = const (); + goto -> bb1; } diff --git a/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-abort.diff b/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-abort.diff index d73cc3d214e4c..5e36aaeed3e5f 100644 --- a/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-abort.diff +++ b/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-abort.diff @@ -47,6 +47,7 @@ StorageDead(_9); - _3 = std::intrinsics::copy_nonoverlapping::(move _4, move _8, const 0_usize) -> [return: bb1, unwind unreachable]; + copy_nonoverlapping(dst = move _8, src = move _4, count = const 0_usize); ++ _3 = const (); + goto -> bb1; } diff --git a/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-unwind.diff b/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-unwind.diff index d73cc3d214e4c..5e36aaeed3e5f 100644 --- a/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-unwind.diff +++ b/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-unwind.diff @@ -47,6 +47,7 @@ StorageDead(_9); - _3 = std::intrinsics::copy_nonoverlapping::(move _4, move _8, const 0_usize) -> [return: bb1, unwind unreachable]; + copy_nonoverlapping(dst = move _8, src = move _4, count = const 0_usize); ++ _3 = const (); + goto -> bb1; } diff --git a/tests/mir-opt/lower_intrinsics.rs b/tests/mir-opt/lower_intrinsics.rs index e8a7701477415..b50b95fd1e527 100644 --- a/tests/mir-opt/lower_intrinsics.rs +++ b/tests/mir-opt/lower_intrinsics.rs @@ -147,6 +147,7 @@ pub fn discriminant(t: T) { pub fn f_copy_nonoverlapping() { // CHECK-LABEL: fn f_copy_nonoverlapping( // CHECK: copy_nonoverlapping({{.*}}); + // CHECK-NEXT: {{_[0-9]+}} = const (); let src = (); let mut dst = (); @@ -159,6 +160,7 @@ pub fn f_copy_nonoverlapping() { pub fn assume() { // CHECK-LABEL: fn assume( // CHECK: assume({{.*}}); + // CHECK-NEXT: {{_[0-9]+}} = const (); unsafe { std::intrinsics::assume(true); diff --git a/tests/mir-opt/match_branch_simplification_zst.rs b/tests/mir-opt/match_branch_simplification_zst.rs new file mode 100644 index 0000000000000..36dae88ce7fef --- /dev/null +++ b/tests/mir-opt/match_branch_simplification_zst.rs @@ -0,0 +1,14 @@ +//@ test-mir-pass: MatchBranchSimplification + +#![crate_type = "lib"] + +// Both arms assign the same unit constant with different source spans. +// EMIT_MIR match_branch_simplification_zst.same_unit.MatchBranchSimplification.diff +pub fn same_unit(condition: bool) { + // CHECK-LABEL: fn same_unit( + // CHECK-NOT: switchInt + // CHECK: _0 = no_retag const (); + // CHECK-NOT: switchInt + // CHECK: return; + if condition {} +} diff --git a/tests/mir-opt/match_branch_simplification_zst.same_unit.MatchBranchSimplification.diff b/tests/mir-opt/match_branch_simplification_zst.same_unit.MatchBranchSimplification.diff new file mode 100644 index 0000000000000..ff35a2a25887f --- /dev/null +++ b/tests/mir-opt/match_branch_simplification_zst.same_unit.MatchBranchSimplification.diff @@ -0,0 +1,31 @@ +- // MIR for `same_unit` before MatchBranchSimplification ++ // MIR for `same_unit` after MatchBranchSimplification + + fn same_unit(_1: bool) -> () { + debug condition => _1; + let mut _0: (); + let mut _2: bool; + + bb0: { + StorageLive(_2); + _2 = copy _1; +- switchInt(move _2) -> [0: bb2, otherwise: bb1]; +- } +- +- bb1: { +- _0 = const (); +- goto -> bb3; +- } +- +- bb2: { +- _0 = const (); +- goto -> bb3; +- } +- +- bb3: { ++ _0 = no_retag const (); + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/multiple_return_terminators.test.MultipleReturnTerminators.diff b/tests/mir-opt/multiple_return_terminators.test.MultipleReturnTerminators.diff index e28809f38afa6..b9c2de4aaf5f8 100644 --- a/tests/mir-opt/multiple_return_terminators.test.MultipleReturnTerminators.diff +++ b/tests/mir-opt/multiple_return_terminators.test.MultipleReturnTerminators.diff @@ -6,6 +6,7 @@ let mut _0: (); bb0: { + _0 = const (); return; } } diff --git a/tests/mir-opt/pattern_types.main.runtime-optimized.after.mir b/tests/mir-opt/pattern_types.main.runtime-optimized.after.mir index 541472fc22957..9bc455d98ebbf 100644 --- a/tests/mir-opt/pattern_types.main.runtime-optimized.after.mir +++ b/tests/mir-opt/pattern_types.main.runtime-optimized.after.mir @@ -10,6 +10,7 @@ fn main() -> () { } bb0: { + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/checked_ops.use_checked_sub.runtime-optimized.after.panic-abort.mir b/tests/mir-opt/pre-codegen/checked_ops.use_checked_sub.runtime-optimized.after.panic-abort.mir index f24a8e41b7db5..8e21c607b6fbd 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.use_checked_sub.runtime-optimized.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.use_checked_sub.runtime-optimized.after.panic-abort.mir @@ -34,12 +34,14 @@ fn use_checked_sub(_1: u32, _2: u32) -> () { } bb2: { + _0 = const (); StorageDead(_6); goto -> bb4; } bb3: { StorageDead(_3); + _0 = const (); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/checked_ops.use_checked_sub.runtime-optimized.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/checked_ops.use_checked_sub.runtime-optimized.after.panic-unwind.mir index 6bcb730be7f14..fef388f87a7ce 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.use_checked_sub.runtime-optimized.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.use_checked_sub.runtime-optimized.after.panic-unwind.mir @@ -34,12 +34,14 @@ fn use_checked_sub(_1: u32, _2: u32) -> () { } bb2: { + _0 = const (); StorageDead(_6); goto -> bb4; } bb3: { StorageDead(_3); + _0 = const (); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_bytes.runtime-optimized.after.panic-abort.mir b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_bytes.runtime-optimized.after.panic-abort.mir index 8384d563e52d2..16e8f326aa6dc 100644 --- a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_bytes.runtime-optimized.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_bytes.runtime-optimized.after.panic-abort.mir @@ -78,6 +78,7 @@ fn drop_bytes(_1: *mut Box<[u8; 1024]>) -> () { bb1: { StorageDead(_2); StorageDead(_3); + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_bytes.runtime-optimized.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_bytes.runtime-optimized.after.panic-unwind.mir index 8384d563e52d2..16e8f326aa6dc 100644 --- a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_bytes.runtime-optimized.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_bytes.runtime-optimized.after.panic-unwind.mir @@ -78,6 +78,7 @@ fn drop_bytes(_1: *mut Box<[u8; 1024]>) -> () { bb1: { StorageDead(_2); StorageDead(_3); + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.runtime-optimized.after.panic-abort.mir b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.runtime-optimized.after.panic-abort.mir index 3d24aa8c349e7..405a806d9fabf 100644 --- a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.runtime-optimized.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.runtime-optimized.after.panic-abort.mir @@ -88,6 +88,7 @@ fn drop_generic(_1: *mut Box) -> () { bb3: { StorageDead(_2); StorageDead(_4); + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.runtime-optimized.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.runtime-optimized.after.panic-unwind.mir index 3d24aa8c349e7..405a806d9fabf 100644 --- a/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.runtime-optimized.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/drop_box_of_sized.drop_generic.runtime-optimized.after.panic-unwind.mir @@ -88,6 +88,7 @@ fn drop_generic(_1: *mut Box) -> () { bb3: { StorageDead(_2); StorageDead(_4); + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.runtime-optimized.after.32bit.panic-abort.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.runtime-optimized.after.32bit.panic-abort.mir index 7c0cede85a4ca..3378e272bb867 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.runtime-optimized.after.32bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.runtime-optimized.after.32bit.panic-abort.mir @@ -103,6 +103,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { StorageDead(_8); StorageDead(_5); StorageDead(_3); + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.runtime-optimized.after.32bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.runtime-optimized.after.32bit.panic-unwind.mir index 7c0cede85a4ca..3378e272bb867 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.runtime-optimized.after.32bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.runtime-optimized.after.32bit.panic-unwind.mir @@ -103,6 +103,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { StorageDead(_8); StorageDead(_5); StorageDead(_3); + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.runtime-optimized.after.64bit.panic-abort.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.runtime-optimized.after.64bit.panic-abort.mir index 7c0cede85a4ca..3378e272bb867 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.runtime-optimized.after.64bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.runtime-optimized.after.64bit.panic-abort.mir @@ -103,6 +103,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { StorageDead(_8); StorageDead(_5); StorageDead(_3); + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.runtime-optimized.after.64bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.runtime-optimized.after.64bit.panic-unwind.mir index 7c0cede85a4ca..3378e272bb867 100644 --- a/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.runtime-optimized.after.64bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.runtime-optimized.after.64bit.panic-unwind.mir @@ -103,6 +103,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { StorageDead(_8); StorageDead(_5); StorageDead(_3); + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/intrinsics.f_u64.runtime-optimized.after.mir b/tests/mir-opt/pre-codegen/intrinsics.f_u64.runtime-optimized.after.mir index 0a5fa6daa9285..07ee6eb87e301 100644 --- a/tests/mir-opt/pre-codegen/intrinsics.f_u64.runtime-optimized.after.mir +++ b/tests/mir-opt/pre-codegen/intrinsics.f_u64.runtime-optimized.after.mir @@ -13,6 +13,7 @@ fn f_u64() -> () { } bb1: { + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/intrinsics.f_unit.runtime-optimized.after.mir b/tests/mir-opt/pre-codegen/intrinsics.f_unit.runtime-optimized.after.mir index 7c35963169d7c..4359dcc520fc1 100644 --- a/tests/mir-opt/pre-codegen/intrinsics.f_unit.runtime-optimized.after.mir +++ b/tests/mir-opt/pre-codegen/intrinsics.f_unit.runtime-optimized.after.mir @@ -13,6 +13,7 @@ fn f_unit() -> () { } bb1: { + _0 = const (); return; } } 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 a0526d279a863..150762aa3b7ed 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 @@ -84,6 +84,7 @@ } bb5: { + _11 = const std::alloc::AllocError; StorageLive(_13); StorageLive(_14); _14 = &_11; @@ -100,6 +101,7 @@ _3 = copy _4 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); + _0 = const (); StorageDead(_1); return; } 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 3b5ecd3d2b16c..a9f176e989015 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 @@ -48,6 +48,7 @@ _3 = copy _4 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); + _0 = const (); StorageDead(_1); return; } 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 3a6b52b0f2496..14c164190abd3 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 @@ -84,6 +84,7 @@ } bb5: { + _11 = const std::alloc::AllocError; StorageLive(_13); StorageLive(_14); _14 = &_11; @@ -100,6 +101,7 @@ _3 = copy _4 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); + _0 = const (); StorageDead(_1); return; } 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 673c05d673fb2..cc978733dd210 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 @@ -48,6 +48,7 @@ _3 = copy _4 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); + _0 = const (); StorageDead(_1); return; } diff --git a/tests/mir-opt/pre-codegen/loops.filter_mapped.runtime-optimized.after.mir b/tests/mir-opt/pre-codegen/loops.filter_mapped.runtime-optimized.after.mir index b3d38472a6a72..6643d93afd2ec 100644 --- a/tests/mir-opt/pre-codegen/loops.filter_mapped.runtime-optimized.after.mir +++ b/tests/mir-opt/pre-codegen/loops.filter_mapped.runtime-optimized.after.mir @@ -54,6 +54,7 @@ fn filter_mapped(_1: impl Iterator, _2: impl Fn(T) -> Option) -> () } bb4: { + _0 = const (); StorageDead(_7); drop(_4) -> [return: bb5, unwind continue]; } diff --git a/tests/mir-opt/pre-codegen/loops.int_range.runtime-optimized.after.mir b/tests/mir-opt/pre-codegen/loops.int_range.runtime-optimized.after.mir index cd146079c6328..7de0f54f28861 100644 --- a/tests/mir-opt/pre-codegen/loops.int_range.runtime-optimized.after.mir +++ b/tests/mir-opt/pre-codegen/loops.int_range.runtime-optimized.after.mir @@ -74,6 +74,7 @@ fn int_range(_1: usize, _2: usize) -> () { bb2: { StorageDead(_6); + _0 = const (); StorageDead(_9); return; } diff --git a/tests/mir-opt/pre-codegen/loops.mapped.runtime-optimized.after.mir b/tests/mir-opt/pre-codegen/loops.mapped.runtime-optimized.after.mir index f7c294bc1feb2..256d933552d1f 100644 --- a/tests/mir-opt/pre-codegen/loops.mapped.runtime-optimized.after.mir +++ b/tests/mir-opt/pre-codegen/loops.mapped.runtime-optimized.after.mir @@ -73,6 +73,7 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { StorageDead(_8); StorageDead(_7); StorageDead(_6); + _0 = const (); StorageDead(_12); drop(_4) -> [return: bb5, unwind continue]; } diff --git a/tests/mir-opt/pre-codegen/loops.vec_move.runtime-optimized.after.mir b/tests/mir-opt/pre-codegen/loops.vec_move.runtime-optimized.after.mir index 6815c22fc9552..3504a13795ff5 100644 --- a/tests/mir-opt/pre-codegen/loops.vec_move.runtime-optimized.after.mir +++ b/tests/mir-opt/pre-codegen/loops.vec_move.runtime-optimized.after.mir @@ -281,6 +281,7 @@ fn vec_move(_1: Vec) -> () { } bb10: { + _0 = const (); StorageDead(_23); StorageDead(_24); drop(_22) -> [return: bb11, unwind continue]; 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..8f68119c7266d 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 @@ -54,6 +54,7 @@ - _7 = copy _8; + _7 = const 42_u32; StorageDead(_8); + _0 = const (); StorageDead(_7); StorageDead(_3); StorageDead(_1); 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..d3fa5ff864c14 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 @@ -54,6 +54,7 @@ - _7 = copy _8; + _7 = const 42_u32; StorageDead(_8); + _0 = const (); StorageDead(_7); StorageDead(_3); StorageDead(_1); 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..8f68119c7266d 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 @@ -54,6 +54,7 @@ - _7 = copy _8; + _7 = const 42_u32; StorageDead(_8); + _0 = const (); StorageDead(_7); StorageDead(_3); StorageDead(_1); 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..d3fa5ff864c14 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 @@ -54,6 +54,7 @@ - _7 = copy _8; + _7 = const 42_u32; StorageDead(_8); + _0 = const (); StorageDead(_7); StorageDead(_3); StorageDead(_1); diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-abort.diff index f7fe08831b97d..59571d145c2ef 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-abort.diff @@ -59,6 +59,7 @@ + StorageDead(_9); + StorageDead(_10); + nop; + _0 = const (); StorageDead(_7); StorageDead(_3); StorageDead(_1); diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff index 6e36386bea601..b877371d2723e 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff @@ -59,6 +59,7 @@ + StorageDead(_9); + StorageDead(_10); + nop; + _0 = const (); StorageDead(_7); StorageDead(_3); StorageDead(_1); diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-abort.diff index f7fe08831b97d..59571d145c2ef 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-abort.diff @@ -59,6 +59,7 @@ + StorageDead(_9); + StorageDead(_10); + nop; + _0 = const (); StorageDead(_7); StorageDead(_3); StorageDead(_1); diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff index 6e36386bea601..b877371d2723e 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff @@ -59,6 +59,7 @@ + StorageDead(_9); + StorageDead(_10); + nop; + _0 = const (); StorageDead(_7); StorageDead(_3); StorageDead(_1); diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-abort.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-abort.mir index 425b95db3363a..cc7ed0843fef7 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-abort.mir @@ -13,6 +13,7 @@ fn main() -> () { } bb0: { + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-unwind.mir index 425b95db3363a..cc7ed0843fef7 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-unwind.mir @@ -13,6 +13,7 @@ fn main() -> () { } bb0: { + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-abort.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-abort.mir index 425b95db3363a..cc7ed0843fef7 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-abort.mir @@ -13,6 +13,7 @@ fn main() -> () { } bb0: { + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-unwind.mir index 425b95db3363a..cc7ed0843fef7 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-unwind.mir @@ -13,6 +13,7 @@ fn main() -> () { } bb0: { + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.runtime-optimized.after.32bit.panic-abort.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.runtime-optimized.after.32bit.panic-abort.mir index 1be0cd30068eb..d682c76299850 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.runtime-optimized.after.32bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.runtime-optimized.after.32bit.panic-abort.mir @@ -13,6 +13,7 @@ fn main() -> () { } bb0: { + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.runtime-optimized.after.32bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.runtime-optimized.after.32bit.panic-unwind.mir index 1be0cd30068eb..d682c76299850 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.runtime-optimized.after.32bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.runtime-optimized.after.32bit.panic-unwind.mir @@ -13,6 +13,7 @@ fn main() -> () { } bb0: { + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.runtime-optimized.after.64bit.panic-abort.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.runtime-optimized.after.64bit.panic-abort.mir index 1be0cd30068eb..d682c76299850 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.runtime-optimized.after.64bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.runtime-optimized.after.64bit.panic-abort.mir @@ -13,6 +13,7 @@ fn main() -> () { } bb0: { + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.runtime-optimized.after.64bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.runtime-optimized.after.64bit.panic-unwind.mir index 1be0cd30068eb..d682c76299850 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.runtime-optimized.after.64bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.runtime-optimized.after.64bit.panic-unwind.mir @@ -13,6 +13,7 @@ fn main() -> () { } bb0: { + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.runtime-optimized.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.runtime-optimized.after.panic-abort.mir index 47c78d4e80138..17f5f5f8e613d 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.runtime-optimized.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.runtime-optimized.after.panic-abort.mir @@ -55,6 +55,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb2: { StorageDead(_5); + _0 = const (); StorageDead(_7); drop(_3) -> [return: bb3, unwind unreachable]; } diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.runtime-optimized.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.runtime-optimized.after.panic-unwind.mir index 5dfcba18be02f..f50919caab65d 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.runtime-optimized.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.runtime-optimized.after.panic-unwind.mir @@ -55,6 +55,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb2: { StorageDead(_5); + _0 = const (); StorageDead(_7); drop(_3) -> [return: bb3, unwind continue]; } diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.runtime-optimized.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.runtime-optimized.after.panic-abort.mir index 8e89ffefe8ee7..67bc7b5666e49 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.runtime-optimized.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.runtime-optimized.after.panic-abort.mir @@ -45,6 +45,7 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb3: { + _0 = const (); StorageDead(_6); StorageDead(_7); StorageDead(_5); diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.runtime-optimized.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.runtime-optimized.after.panic-unwind.mir index 084708b53c933..338c1cfcae8f5 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.runtime-optimized.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.runtime-optimized.after.panic-unwind.mir @@ -45,6 +45,7 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb3: { + _0 = const (); StorageDead(_6); StorageDead(_7); StorageDead(_5); diff --git a/tests/mir-opt/pre-codegen/simple_option_map.map_via_question_mark.runtime-optimized.after.mir b/tests/mir-opt/pre-codegen/simple_option_map.map_via_question_mark.runtime-optimized.after.mir index 3c559614e9863..5e380762f2514 100644 --- a/tests/mir-opt/pre-codegen/simple_option_map.map_via_question_mark.runtime-optimized.after.mir +++ b/tests/mir-opt/pre-codegen/simple_option_map.map_via_question_mark.runtime-optimized.after.mir @@ -3,34 +3,31 @@ fn map_via_question_mark(_1: Option) -> Option { debug x => _1; let mut _0: std::option::Option; - let mut _4: std::option::Option; - let mut _7: std::ops::ControlFlow, i32>; - let _8: i32; - let mut _9: i32; + let mut _4: std::ops::ControlFlow, i32>; + let _5: i32; + let mut _6: i32; scope 1 { debug residual => const Option::::None; scope 2 { scope 7 (inlined as FromResidual>>::from_residual) { - let mut _3: isize; - let mut _5: bool; } } } scope 3 { - debug val => _8; + debug val => _5; scope 4 { } } scope 5 (inlined as Try>::branch) { let mut _2: isize; - let _6: i32; + let _3: i32; scope 6 { } } bb0: { - StorageLive(_9); - StorageLive(_7); + StorageLive(_6); + StorageLive(_4); StorageLive(_2); _2 = discriminant(_1); switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb4]; @@ -38,30 +35,23 @@ fn map_via_question_mark(_1: Option) -> Option { bb1: { StorageDead(_2); - StorageLive(_3); - StorageLive(_5); - _3 = discriminant(_4); - _5 = Eq(copy _3, const 0_isize); - assume(move _5); _0 = const Option::::None; - StorageDead(_5); - StorageDead(_3); - StorageDead(_9); - StorageDead(_7); + StorageDead(_6); + StorageDead(_4); goto -> bb3; } bb2: { - StorageLive(_6); - _6 = copy ((_1 as Some).0: i32); - _7 = ControlFlow::, i32>::Continue(copy _6); - StorageDead(_6); + StorageLive(_3); + _3 = copy ((_1 as Some).0: i32); + _4 = ControlFlow::, i32>::Continue(copy _3); + StorageDead(_3); StorageDead(_2); - _8 = copy ((_7 as Continue).0: i32); - _9 = Add(copy _8, const 1_i32); - _0 = Option::::Some(move _9); - StorageDead(_9); - StorageDead(_7); + _5 = copy ((_4 as Continue).0: i32); + _6 = Add(copy _5, const 1_i32); + _0 = Option::::Some(move _6); + StorageDead(_6); + StorageDead(_4); goto -> bb3; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.runtime-optimized.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.runtime-optimized.after.panic-abort.mir index b42087b5c822d..df8eb79dc9e34 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.runtime-optimized.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.runtime-optimized.after.panic-abort.mir @@ -5,36 +5,33 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug f => _2; let mut _0: (); let mut _12: usize; - let mut _32: std::option::Option<(usize, &T)>; - let mut _35: &impl Fn(usize, &T); - let mut _36: (usize, &T); - let _37: (); + let mut _29: std::option::Option<(usize, &T)>; + let mut _32: &impl Fn(usize, &T); + let mut _33: (usize, &T); + let _34: (); scope 1 { debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).0: std::ptr::NonNull) => _8; debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).1: *const T) => _11; debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; debug ((iter: Enumerate>).1: usize) => _12; - let _33: usize; - let _34: &T; + let _30: usize; + let _31: &T; scope 2 { - debug i => _33; - debug x => _34; + debug i => _30; + debug x => _31; } scope 18 (inlined > as Iterator>::next) { - let mut _22: std::option::Option; - let mut _27: std::option::Option<&T>; - let mut _30: (usize, bool); - let mut _31: (usize, &T); + let mut _24: std::option::Option<&T>; + let mut _27: (usize, bool); + let mut _28: (usize, &T); scope 19 { - let _29: usize; + let _26: usize; scope 24 { } } scope 20 { scope 21 { scope 27 (inlined as FromResidual>>::from_residual) { - let mut _21: isize; - let mut _23: bool; } } } @@ -43,7 +40,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 25 (inlined as Try>::branch) { - let _28: &T; + let _25: &T; scope 26 { } } @@ -52,8 +49,8 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let _13: std::ptr::NonNull; let _15: std::ptr::NonNull; let mut _18: bool; - let mut _24: usize; - let _26: &T; + let mut _21: usize; + let _23: &T; scope 29 { let _14: *const T; scope 30 { @@ -86,7 +83,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 43 (inlined NonNull::::as_ref::<'_>) { - let _25: *const T; + let _22: *const T; scope 44 (inlined NonNull::::as_ptr) { } scope 45 (inlined std::ptr::mut_ptr::::cast_const) { @@ -179,10 +176,10 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb4: { - StorageLive(_32); - StorageLive(_30); + StorageLive(_29); StorageLive(_27); StorageLive(_24); + StorageLive(_21); StorageLive(_16); StorageLive(_13); _13 = copy _8; @@ -234,17 +231,11 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { StorageDead(_14); StorageDead(_13); StorageDead(_16); + StorageDead(_21); StorageDead(_24); StorageDead(_27); - StorageLive(_21); - StorageLive(_23); - _21 = discriminant(_22); - _23 = Eq(copy _21, const 0_isize); - assume(move _23); - StorageDead(_23); - StorageDead(_21); - StorageDead(_30); - StorageDead(_32); + _0 = const (); + StorageDead(_29); StorageDead(_12); drop(_2) -> [return: bb11, unwind unreachable]; } @@ -254,57 +245,57 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb12: { - _24 = SubUnchecked(copy _20, const 1_usize); - _11 = copy _24 as *const T (Transmute); + _21 = SubUnchecked(copy _20, const 1_usize); + _11 = copy _21 as *const T (Transmute); StorageDead(_20); goto -> bb13; } bb13: { - StorageLive(_26); - StorageLive(_25); - _25 = copy _13 as *const T (Transmute); - _26 = &(*_25); - StorageDead(_25); - _27 = Option::<&T>::Some(copy _26); - StorageDead(_26); + StorageLive(_23); + StorageLive(_22); + _22 = copy _13 as *const T (Transmute); + _23 = &(*_22); + StorageDead(_22); + _24 = Option::<&T>::Some(copy _23); + StorageDead(_23); StorageDead(_14); StorageDead(_13); StorageDead(_16); + StorageDead(_21); + _25 = copy ((_24 as Some).0: &T); StorageDead(_24); - _28 = copy ((_27 as Some).0: &T); - StorageDead(_27); - StorageLive(_29); - _29 = copy _12; - _30 = AddWithOverflow(copy _12, const 1_usize); - assert(!move (_30.1: bool), "attempt to compute `{} + {}`, which would overflow", copy _12, const 1_usize) -> [success: bb14, unwind unreachable]; + StorageLive(_26); + _26 = copy _12; + _27 = AddWithOverflow(copy _12, const 1_usize); + assert(!move (_27.1: bool), "attempt to compute `{} + {}`, which would overflow", copy _12, const 1_usize) -> [success: bb14, unwind unreachable]; } bb14: { - _12 = move (_30.0: usize); + _12 = move (_27.0: usize); + StorageLive(_28); + _28 = (copy _26, copy _25); + _29 = Option::<(usize, &T)>::Some(move _28); + StorageDead(_28); + StorageDead(_26); + StorageDead(_27); + StorageLive(_30); + _30 = copy (((_29 as Some).0: (usize, &T)).0: usize); StorageLive(_31); - _31 = (copy _29, copy _28); - _32 = Option::<(usize, &T)>::Some(move _31); - StorageDead(_31); - StorageDead(_29); - StorageDead(_30); + _31 = copy (((_29 as Some).0: (usize, &T)).1: &T); + StorageLive(_32); + _32 = &_2; StorageLive(_33); - _33 = copy (((_32 as Some).0: (usize, &T)).0: usize); - StorageLive(_34); - _34 = copy (((_32 as Some).0: (usize, &T)).1: &T); - StorageLive(_35); - _35 = &_2; - StorageLive(_36); - _36 = (copy _33, copy _34); - _37 = >::call(move _35, move _36) -> [return: bb15, unwind unreachable]; + _33 = (copy _30, copy _31); + _34 = >::call(move _32, move _33) -> [return: bb15, unwind unreachable]; } bb15: { - StorageDead(_36); - StorageDead(_35); - StorageDead(_34); StorageDead(_33); StorageDead(_32); + StorageDead(_31); + StorageDead(_30); + StorageDead(_29); goto -> bb4; } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.runtime-optimized.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.runtime-optimized.after.panic-unwind.mir index bdb72abeac7e4..9cf28f01c2342 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.runtime-optimized.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.runtime-optimized.after.panic-unwind.mir @@ -125,6 +125,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb6: { + _0 = const (); StorageDead(_15); StorageDead(_16); StorageDead(_14); diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.runtime-optimized.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.runtime-optimized.after.panic-abort.mir index 2e662fc36ac67..6f991a484bb07 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.runtime-optimized.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.runtime-optimized.after.panic-abort.mir @@ -195,6 +195,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { StorageDead(_12); StorageDead(_15); StorageDead(_20); + _0 = const (); StorageDead(_23); drop(_2) -> [return: bb11, unwind unreachable]; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.runtime-optimized.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.runtime-optimized.after.panic-unwind.mir index dc5feaa1344b0..bd1010ec1690b 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.runtime-optimized.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.runtime-optimized.after.panic-unwind.mir @@ -195,6 +195,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { StorageDead(_12); StorageDead(_15); StorageDead(_20); + _0 = const (); StorageDead(_23); drop(_2) -> [return: bb11, unwind continue]; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.runtime-optimized.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.runtime-optimized.after.panic-abort.mir index e817d9cd87289..1baee184e2958 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.runtime-optimized.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.runtime-optimized.after.panic-abort.mir @@ -63,6 +63,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb2: { StorageDead(_6); + _0 = const (); StorageDead(_8); drop(_2) -> [return: bb3, unwind unreachable]; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.runtime-optimized.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.runtime-optimized.after.panic-unwind.mir index b780f686570f8..d7b8a08e00316 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.runtime-optimized.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.runtime-optimized.after.panic-unwind.mir @@ -63,6 +63,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb2: { StorageDead(_6); + _0 = const (); StorageDead(_8); drop(_2) -> [return: bb3, unwind continue]; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.runtime-optimized.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.runtime-optimized.after.panic-abort.mir index c2c521729b75c..e4c82f9276034 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.runtime-optimized.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.runtime-optimized.after.panic-abort.mir @@ -303,6 +303,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb15: { StorageDead(_20); + _0 = const (); StorageDead(_35); StorageDead(_14); drop(_2) -> [return: bb16, unwind unreachable]; diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.runtime-optimized.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.runtime-optimized.after.panic-unwind.mir index c11eab18521dd..75782845f14d1 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.runtime-optimized.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.runtime-optimized.after.panic-unwind.mir @@ -311,6 +311,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb17: { StorageDead(_20); + _0 = const (); StorageDead(_35); StorageDead(_14); drop(_2) -> [return: bb18, unwind continue]; diff --git a/tests/mir-opt/pre-codegen/transmutes.forget_at_home.runtime-optimized.after.mir b/tests/mir-opt/pre-codegen/transmutes.forget_at_home.runtime-optimized.after.mir index 80ad68c8a48bb..6bd43650734c0 100644 --- a/tests/mir-opt/pre-codegen/transmutes.forget_at_home.runtime-optimized.after.mir +++ b/tests/mir-opt/pre-codegen/transmutes.forget_at_home.runtime-optimized.after.mir @@ -15,6 +15,7 @@ fn forget_at_home(_1: String) -> () { } bb0: { + _0 = const (); return; } } diff --git a/tests/mir-opt/pre-codegen/transmutes.rs b/tests/mir-opt/pre-codegen/transmutes.rs index d8369e839b6ba..6b1129d68134c 100644 --- a/tests/mir-opt/pre-codegen/transmutes.rs +++ b/tests/mir-opt/pre-codegen/transmutes.rs @@ -45,6 +45,7 @@ pub fn pad_for_alignment(x: u32) -> Align64 { pub fn forget_at_home(x: String) { // CHECK-LABEL: fn forget_at_home // CHECK: bb0: + // CHECK-NEXT: _0 = const (); // CHECK-NEXT: return; unsafe { transmute_prefix(x) } } diff --git a/tests/mir-opt/pre-codegen/unaligned.unaligned_copy_generic.runtime-optimized.after.mir b/tests/mir-opt/pre-codegen/unaligned.unaligned_copy_generic.runtime-optimized.after.mir index ffb1fe334b201..6ce5a410ff666 100644 --- a/tests/mir-opt/pre-codegen/unaligned.unaligned_copy_generic.runtime-optimized.after.mir +++ b/tests/mir-opt/pre-codegen/unaligned.unaligned_copy_generic.runtime-optimized.after.mir @@ -51,6 +51,7 @@ fn unaligned_copy_generic(_1: *const T, _2: *mut T) -> () { (*_6) = copy _7; StorageDead(_7); StorageDead(_6); + _0 = const (); StorageDead(_5); return; } diff --git a/tests/mir-opt/pre-codegen/unaligned.unaligned_copy_manual.runtime-optimized.after.mir b/tests/mir-opt/pre-codegen/unaligned.unaligned_copy_manual.runtime-optimized.after.mir index 450df935a0fb3..b3b4365bc46ad 100644 --- a/tests/mir-opt/pre-codegen/unaligned.unaligned_copy_manual.runtime-optimized.after.mir +++ b/tests/mir-opt/pre-codegen/unaligned.unaligned_copy_manual.runtime-optimized.after.mir @@ -27,6 +27,7 @@ fn unaligned_copy_manual(_1: *const u128, _2: *mut u128) -> () { _5 = copy ((*_3).0: u128); ((*_4).0: u128) = move _5; StorageDead(_5); + _0 = const (); StorageDead(_4); StorageDead(_3); return; diff --git a/tests/mir-opt/range/ssa_range.on_assume.SsaRangePropagation.diff b/tests/mir-opt/range/ssa_range.on_assume.SsaRangePropagation.diff index 3be6f083604d3..7552c27cfb800 100644 --- a/tests/mir-opt/range/ssa_range.on_assume.SsaRangePropagation.diff +++ b/tests/mir-opt/range/ssa_range.on_assume.SsaRangePropagation.diff @@ -34,6 +34,7 @@ nop; StorageDead(_6); assume(copy _5); + _4 = const (); nop; StorageDead(_4); _3 = const (); diff --git a/tests/mir-opt/remove_zsts.get_union.RemoveZsts.diff b/tests/mir-opt/remove_zsts.get_union.RemoveZsts.diff index 748c18ba7da97..ed338d69906c3 100644 --- a/tests/mir-opt/remove_zsts.get_union.RemoveZsts.diff +++ b/tests/mir-opt/remove_zsts.get_union.RemoveZsts.diff @@ -7,11 +7,10 @@ bb0: { - StorageLive(_1); -- _1 = (); ++ nop; + _1 = (); - _0 = Foo { x: move _1 }; - StorageDead(_1); -+ nop; -+ nop; + _0 = Foo { x: const () }; + nop; return; diff --git a/tests/mir-opt/remove_zsts.remove_generic_array.RemoveZsts.diff b/tests/mir-opt/remove_zsts.remove_generic_array.RemoveZsts.diff index 2ac944a6c6bc5..3241d40363753 100644 --- a/tests/mir-opt/remove_zsts.remove_generic_array.RemoveZsts.diff +++ b/tests/mir-opt/remove_zsts.remove_generic_array.RemoveZsts.diff @@ -1,12 +1,14 @@ - // MIR for `remove_generic_array` before RemoveZsts + // MIR for `remove_generic_array` after RemoveZsts - fn remove_generic_array(_1: T) -> () { + fn remove_generic_array(_1: T) -> ([T; 0], [T; 0]) { debug x => _1; - let mut _0: (); + let mut _0: ([T; 0], [T; 0]); let _2: [T; 0]; let mut _3: T; let mut _5: T; + let mut _6: [T; 0]; + let mut _7: [T; 0]; scope 1 { - debug a => _2; + debug a => const ZeroSized: [T; 0]; @@ -22,20 +24,30 @@ + nop; StorageLive(_3); _3 = copy _1; -- _2 = []; -+ nop; + _2 = []; StorageDead(_3); - StorageLive(_4); + nop; StorageLive(_5); _5 = copy _1; -- _4 = []; -+ nop; + _4 = []; StorageDead(_5); -- _0 = const (); +- StorageLive(_6); +- _6 = copy _2; +- StorageLive(_7); +- _7 = copy _4; +- _0 = (move _6, move _7); +- StorageDead(_7); +- StorageDead(_6); - StorageDead(_4); - StorageDead(_2); + nop; ++ _6 = const ZeroSized: [T; 0]; ++ nop; ++ _7 = const ZeroSized: [T; 0]; ++ _0 = (const ZeroSized: [T; 0], const ZeroSized: [T; 0]); ++ nop; ++ nop; + nop; + nop; return; diff --git a/tests/mir-opt/remove_zsts.rs b/tests/mir-opt/remove_zsts.rs index baf9d8ece266d..ff80edda68e77 100644 --- a/tests/mir-opt/remove_zsts.rs +++ b/tests/mir-opt/remove_zsts.rs @@ -15,14 +15,14 @@ fn get_union() -> Foo { const MYSTERY: usize = 280_usize.isqrt() - 260_usize.isqrt(); // EMIT_MIR remove_zsts.remove_generic_array.RemoveZsts.diff -fn remove_generic_array(x: T) { +fn remove_generic_array(x: T) -> ([T; 0], [T; MYSTERY]) { // CHECK-LABEL: fn remove_generic_array // CHECK: debug a => const ZeroSized: [T; 0]; // CHECK: debug b => const ZeroSized: [T; 0]; - // CHECK-NOT: = []; - // CHECK-NOT: ; 1] + // CHECK: _0 = (const ZeroSized: [T; 0], const ZeroSized: [T; 0]); let a = [x; 0]; let b = [x; MYSTERY]; + (a, b) } fn main() { diff --git a/tests/mir-opt/remove_zsts_move_elimination.discriminant.RemoveZsts.diff b/tests/mir-opt/remove_zsts_move_elimination.discriminant.RemoveZsts.diff new file mode 100644 index 0000000000000..7c2b40b6cc33e --- /dev/null +++ b/tests/mir-opt/remove_zsts_move_elimination.discriminant.RemoveZsts.diff @@ -0,0 +1,12 @@ +- // MIR for `discriminant` before RemoveZsts ++ // MIR for `discriminant` after RemoveZsts + + fn discriminant() -> Unit { + let mut _0: Unit; + + bb0: { + discriminant(_0) = 0; + return; + } + } + diff --git a/tests/mir-opt/remove_zsts_move_elimination.indirect.RemoveZsts.diff b/tests/mir-opt/remove_zsts_move_elimination.indirect.RemoveZsts.diff new file mode 100644 index 0000000000000..2d6fc87bbd906 --- /dev/null +++ b/tests/mir-opt/remove_zsts_move_elimination.indirect.RemoveZsts.diff @@ -0,0 +1,16 @@ +- // MIR for `indirect` before RemoveZsts ++ // MIR for `indirect` after RemoveZsts + + fn indirect(_1: *mut (), _2: *mut Unit) -> () { + let mut _0: (); + + bb0: { +- (*_1) = (); +- discriminant((*_2)) = 0; ++ nop; ++ nop; + _0 = (); + return; + } + } + diff --git a/tests/mir-opt/remove_zsts_move_elimination.local.RemoveZsts.diff b/tests/mir-opt/remove_zsts_move_elimination.local.RemoveZsts.diff new file mode 100644 index 0000000000000..4212876542ec5 --- /dev/null +++ b/tests/mir-opt/remove_zsts_move_elimination.local.RemoveZsts.diff @@ -0,0 +1,19 @@ +- // MIR for `local` before RemoveZsts ++ // MIR for `local` after RemoveZsts + + fn local() -> () { + let mut _0: (); + let mut _1: (); + + bb0: { +- StorageLive(_1); ++ nop; + _1 = (); +- _0 = move _1; +- StorageDead(_1); ++ _0 = const (); ++ nop; + return; + } + } + diff --git a/tests/mir-opt/remove_zsts_move_elimination.rs b/tests/mir-opt/remove_zsts_move_elimination.rs new file mode 100644 index 0000000000000..2065c1f7c58ba --- /dev/null +++ b/tests/mir-opt/remove_zsts_move_elimination.rs @@ -0,0 +1,68 @@ +//@ test-mir-pass: RemoveZsts + +#![crate_type = "lib"] +#![feature(custom_mir, core_intrinsics)] +use std::intrinsics::mir::*; + +// Under move elimination semantics we can't remove direct assignments since they have +// the side effect of creating an allocation for a local. If they are truly +// dead then they will be eliminated later optimization passes. + +// Preserve ZST writes while removing storage markers and replacing operands with constants. +// EMIT_MIR remove_zsts_move_elimination.local.RemoveZsts.diff +#[custom_mir(dialect = "runtime", phase = "initial")] +pub fn local() { + // CHECK-LABEL: fn local( + // CHECK-NOT: StorageLive + // CHECK: {{_[0-9]+}} = (); + // CHECK-NEXT: _0 = const (); + // CHECK-NOT: StorageDead + // CHECK: return; + mir! { + let value: (); + { + StorageLive(value); + value = (); + RET = Move(value); + StorageDead(value); + Return() + } + } +} + +pub enum Unit { + Value, +} + +// Preserve ZST SetDiscriminant since it allocates the destination local. +// EMIT_MIR remove_zsts_move_elimination.discriminant.RemoveZsts.diff +#[custom_mir(dialect = "runtime", phase = "initial")] +pub fn discriminant() -> Unit { + // CHECK-LABEL: fn discriminant( + // CHECK: discriminant(_0) = 0; + // CHECK-NEXT: return; + mir! { + { + SetDiscriminant(RET, 0); + Return() + } + } +} + +// Indirect ZST writes cannot allocate a local and can still be removed. +// EMIT_MIR remove_zsts_move_elimination.indirect.RemoveZsts.diff +#[custom_mir(dialect = "runtime", phase = "initial")] +pub unsafe fn indirect(value: *mut (), discriminant: *mut Unit) { + // CHECK-LABEL: fn indirect( + // CHECK-NOT: (* + // CHECK: _0 = (); + // CHECK-NEXT: return; + mir! { + { + *value = (); + SetDiscriminant(*discriminant, 0); + RET = (); + Return() + } + } +} diff --git a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-inst-simplify.panic-abort.diff b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-inst-simplify.panic-abort.diff index c67fd69235b47..60eb2add6cb5c 100644 --- a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-inst-simplify.panic-abort.diff +++ b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-inst-simplify.panic-abort.diff @@ -9,8 +9,8 @@ bb0: { StorageLive(_1); _1 = const false; -- switchInt(move _1) -> [0: bb2, otherwise: bb1]; -+ goto -> bb2; +- switchInt(move _1) -> [0: bb3, otherwise: bb1]; ++ goto -> bb3; } bb1: { @@ -18,6 +18,16 @@ } bb2: { + _0 = const (); + goto -> bb4; + } + + bb3: { + _0 = const (); + goto -> bb4; + } + + bb4: { StorageDead(_1); return; } diff --git a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-inst-simplify.panic-unwind.diff b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-inst-simplify.panic-unwind.diff index 07f179dfdd454..ff6f4f5d397c1 100644 --- a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-inst-simplify.panic-unwind.diff +++ b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-inst-simplify.panic-unwind.diff @@ -9,8 +9,8 @@ bb0: { StorageLive(_1); _1 = const false; -- switchInt(move _1) -> [0: bb2, otherwise: bb1]; -+ goto -> bb2; +- switchInt(move _1) -> [0: bb3, otherwise: bb1]; ++ goto -> bb3; } bb1: { @@ -18,6 +18,16 @@ } bb2: { + _0 = const (); + goto -> bb4; + } + + bb3: { + _0 = const (); + goto -> bb4; + } + + bb4: { StorageDead(_1); return; } diff --git a/tests/mir-opt/simplify_if.rs b/tests/mir-opt/simplify_if.rs index 6aca233655544..e86f19a7823a8 100644 --- a/tests/mir-opt/simplify_if.rs +++ b/tests/mir-opt/simplify_if.rs @@ -7,6 +7,7 @@ fn main() { // CHECK-LABEL: fn main( // CHECK: bb0: { + // CHECK-NEXT: _0 = const (); // CHECK-NEXT: return; if false { noop(); diff --git a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-abort.diff b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-abort.diff index 98727b80ca12e..2a2ce9ddb81fd 100644 --- a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-abort.diff +++ b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-abort.diff @@ -25,31 +25,37 @@ StorageDead(_3); StorageDead(_2); _5 = discriminant((_1.0: std::option::Option)); - switchInt(move _5) -> [1: bb1, 0: bb3, otherwise: bb5]; + switchInt(move _5) -> [1: bb1, 0: bb3, otherwise: bb6]; } bb1: { _4 = discriminant((_1.1: std::option::Option)); - switchInt(move _4) -> [0: bb2, 1: bb3, otherwise: bb5]; + switchInt(move _4) -> [0: bb2, 1: bb3, otherwise: bb6]; } bb2: { StorageLive(_6); _6 = copy (((_1.0: std::option::Option) as Some).0: u8); + _0 = no_retag const (); StorageDead(_6); - goto -> bb3; + goto -> bb4; } bb3: { - drop(_1) -> [return: bb4, unwind unreachable]; + _0 = const (); + goto -> bb4; } bb4: { + drop(_1) -> [return: bb5, unwind unreachable]; + } + + bb5: { StorageDead(_1); return; } - bb5: { + bb6: { unreachable; } } diff --git a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff index 12b0a7f4ba535..1517268b7df5a 100644 --- a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff +++ b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff @@ -25,31 +25,37 @@ StorageDead(_3); StorageDead(_2); _5 = discriminant((_1.0: std::option::Option)); - switchInt(move _5) -> [1: bb1, 0: bb3, otherwise: bb5]; + switchInt(move _5) -> [1: bb1, 0: bb3, otherwise: bb6]; } bb1: { _4 = discriminant((_1.1: std::option::Option)); - switchInt(move _4) -> [0: bb2, 1: bb3, otherwise: bb5]; + switchInt(move _4) -> [0: bb2, 1: bb3, otherwise: bb6]; } bb2: { StorageLive(_6); _6 = copy (((_1.0: std::option::Option) as Some).0: u8); + _0 = no_retag const (); StorageDead(_6); - goto -> bb3; + goto -> bb4; } bb3: { - drop(_1) -> [return: bb4, unwind continue]; + _0 = const (); + goto -> bb4; } bb4: { + drop(_1) -> [return: bb5, unwind continue]; + } + + bb5: { StorageDead(_1); return; } - bb5: { + bb6: { unreachable; } } 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 30c3b0bcfa1d7..6674b425bd492 100644 --- a/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff +++ b/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff @@ -16,15 +16,20 @@ - _1 = copy _2; + _1 = const false; StorageDead(_2); -- switchInt(copy _1) -> [0: bb2, otherwise: bb1]; -+ switchInt(const false) -> [0: bb2, otherwise: bb1]; +- switchInt(copy _1) -> [0: bb1, otherwise: bb2]; ++ switchInt(const false) -> [0: bb1, otherwise: bb2]; } bb1: { - _0 = noop() -> [return: bb2, unwind unreachable]; + _0 = const (); + goto -> bb3; } bb2: { + _0 = noop() -> [return: bb3, unwind unreachable]; + } + + bb3: { StorageDead(_1); return; } 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 7923d3210d83f..2cef773f0d1c4 100644 --- a/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff @@ -16,15 +16,20 @@ - _1 = copy _2; + _1 = const false; StorageDead(_2); -- switchInt(copy _1) -> [0: bb2, otherwise: bb1]; -+ switchInt(const false) -> [0: bb2, otherwise: bb1]; +- switchInt(copy _1) -> [0: bb1, otherwise: bb2]; ++ switchInt(const false) -> [0: bb1, otherwise: bb2]; } bb1: { - _0 = noop() -> [return: bb2, unwind continue]; + _0 = const (); + goto -> bb3; } bb2: { + _0 = noop() -> [return: bb3, unwind continue]; + } + + bb3: { StorageDead(_1); return; } diff --git a/tests/mir-opt/simplify_match.rs b/tests/mir-opt/simplify_match.rs index ca9dac40aa917..1776379086cab 100644 --- a/tests/mir-opt/simplify_match.rs +++ b/tests/mir-opt/simplify_match.rs @@ -9,6 +9,7 @@ fn noop() {} // CHECK: debug x => const false; // CHECK-NOT: switchInt // CHECK: bb0: { +// CHECK-NEXT: _0 = const (); // CHECK-NEXT: return; fn main() { match { diff --git a/tests/mir-opt/slice_drop_shim.core.ptr-drop_glue.[String;42].AddMovesForPackedDrops.before.mir b/tests/mir-opt/slice_drop_shim.core.ptr-drop_glue.[String;42].AddMovesForPackedDrops.before.mir index 1d4b0f033e0be..b7daabb24ebd0 100644 --- a/tests/mir-opt/slice_drop_shim.core.ptr-drop_glue.[String;42].AddMovesForPackedDrops.before.mir +++ b/tests/mir-opt/slice_drop_shim.core.ptr-drop_glue.[String;42].AddMovesForPackedDrops.before.mir @@ -10,6 +10,7 @@ fn std::ptr::drop_glue(_1: &mut [String; 42]) -> () { } bb1: { + _0 = const (); return; } } diff --git a/tests/mir-opt/slice_drop_shim.core.ptr-drop_glue.[String].AddMovesForPackedDrops.before.mir b/tests/mir-opt/slice_drop_shim.core.ptr-drop_glue.[String].AddMovesForPackedDrops.before.mir index 227f02d4c0e25..0b29f234e1b42 100644 --- a/tests/mir-opt/slice_drop_shim.core.ptr-drop_glue.[String].AddMovesForPackedDrops.before.mir +++ b/tests/mir-opt/slice_drop_shim.core.ptr-drop_glue.[String].AddMovesForPackedDrops.before.mir @@ -14,6 +14,7 @@ fn std::ptr::drop_glue(_1: &mut [String]) -> () { } bb1: { + _0 = const (); return; } diff --git a/tests/mir-opt/sroa/scalable_sroa.bar.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/scalable_sroa.bar.ScalarReplacementOfAggregates.diff index fa4b14620b10e..5dc6a85ab5725 100644 --- a/tests/mir-opt/sroa/scalable_sroa.bar.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa/scalable_sroa.bar.ScalarReplacementOfAggregates.diff @@ -25,6 +25,7 @@ bb1: { _3 = copy (*_1)[_4]; StorageDead(_4); + _0 = const (); StorageDead(_3); return; } diff --git a/tests/mir-opt/sroa/scalable_sroa.foo.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/scalable_sroa.foo.ScalarReplacementOfAggregates.diff index 0aceea57e17a6..ee8f64fe33327 100644 --- a/tests/mir-opt/sroa/scalable_sroa.foo.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa/scalable_sroa.foo.ScalarReplacementOfAggregates.diff @@ -25,6 +25,7 @@ bb1: { _3 = copy (*_1)[_4]; StorageDead(_4); + _0 = const (); StorageDead(_3); return; } diff --git a/tests/mir-opt/sroa/simd_sroa.foo.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/simd_sroa.foo.ScalarReplacementOfAggregates.diff index 744032471089d..477d05b90702a 100644 --- a/tests/mir-opt/sroa/simd_sroa.foo.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa/simd_sroa.foo.ScalarReplacementOfAggregates.diff @@ -25,6 +25,7 @@ bb1: { _3 = copy (*_1)[_4]; StorageDead(_4); + _0 = const (); StorageDead(_3); return; } diff --git a/tests/mir-opt/uninhabited_enum.process_void.SimplifyLocals-final.after.mir b/tests/mir-opt/uninhabited_enum.process_void.SimplifyLocals-final.after.mir index 64711755f7394..585c6f3fdb06a 100644 --- a/tests/mir-opt/uninhabited_enum.process_void.SimplifyLocals-final.after.mir +++ b/tests/mir-opt/uninhabited_enum.process_void.SimplifyLocals-final.after.mir @@ -8,6 +8,7 @@ fn process_void(_1: *const Void) -> () { } bb0: { + _0 = const (); return; } } diff --git a/tests/mir-opt/uninhabited_not_read.main.SimplifyLocals-final.after.mir b/tests/mir-opt/uninhabited_not_read.main.SimplifyLocals-final.after.mir index 89f4cbc2edea5..ecea1ced574f9 100644 --- a/tests/mir-opt/uninhabited_not_read.main.SimplifyLocals-final.after.mir +++ b/tests/mir-opt/uninhabited_not_read.main.SimplifyLocals-final.after.mir @@ -43,6 +43,7 @@ fn main() -> () { _5 = copy _6 as *const ! (PtrToPtr); StorageDead(_6); StorageDead(_5); + _0 = const (); StorageDead(_4); return; } diff --git a/tests/mir-opt/unusual_item_types.core.ptr-drop_glue.Vec_i32_.AddMovesForPackedDrops.before.mir b/tests/mir-opt/unusual_item_types.core.ptr-drop_glue.Vec_i32_.AddMovesForPackedDrops.before.mir index 4f124c666bfb0..e4dda75280d14 100644 --- a/tests/mir-opt/unusual_item_types.core.ptr-drop_glue.Vec_i32_.AddMovesForPackedDrops.before.mir +++ b/tests/mir-opt/unusual_item_types.core.ptr-drop_glue.Vec_i32_.AddMovesForPackedDrops.before.mir @@ -10,6 +10,7 @@ fn std::ptr::drop_glue(_1: &mut Vec) -> () { } bb1: { + _0 = const (); return; } diff --git a/tests/run-make/const_fn_mir/dump.mir b/tests/run-make/const_fn_mir/dump.mir index 2b5c684bbef00..f758dea568e8c 100644 --- a/tests/run-make/const_fn_mir/dump.mir +++ b/tests/run-make/const_fn_mir/dump.mir @@ -41,6 +41,7 @@ fn main() -> () { } bb1: { + _0 = const (); return; } } diff --git a/tests/ui/inline-const/const-expr-generic-err.stderr b/tests/ui/inline-const/const-expr-generic-err.stderr index 26039ba6d4449..364d1338808f6 100644 --- a/tests/ui/inline-const/const-expr-generic-err.stderr +++ b/tests/ui/inline-const/const-expr-generic-err.stderr @@ -10,6 +10,14 @@ note: erroneous constant encountered LL | const { assert!(std::mem::size_of::() == 0); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: erroneous constant encountered + --> $DIR/const-expr-generic-err.rs:4:5 + | +LL | const { assert!(std::mem::size_of::() == 0); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + note: the above error was encountered while instantiating `fn foo::` --> $DIR/const-expr-generic-err.rs:12:5 |