From affb081fa0810494165fbfb8d308a0f02a290fed Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Mon, 15 Mar 2021 20:18:03 -0400 Subject: [PATCH 1/9] revert changes from #83118 to mark zst return place as unused --- compiler/rustc_mir/src/transform/simplify.rs | 79 +++++++------------- 1 file changed, 27 insertions(+), 52 deletions(-) diff --git a/compiler/rustc_mir/src/transform/simplify.rs b/compiler/rustc_mir/src/transform/simplify.rs index d2314a9ba158a..a5764d9bf4e3d 100644 --- a/compiler/rustc_mir/src/transform/simplify.rs +++ b/compiler/rustc_mir/src/transform/simplify.rs @@ -31,10 +31,10 @@ use crate::transform::MirPass; use rustc_index::vec::{Idx, IndexVec}; use rustc_middle::mir::visit::{MutVisitor, MutatingUseContext, PlaceContext, Visitor}; use rustc_middle::mir::*; -use rustc_middle::ty::ParamEnv; use rustc_middle::ty::TyCtxt; use smallvec::SmallVec; -use std::{borrow::Cow, convert::TryInto}; +use std::borrow::Cow; +use std::convert::TryInto; pub struct SimplifyCfg { label: String, @@ -326,7 +326,7 @@ impl<'tcx> MirPass<'tcx> for SimplifyLocals { pub fn simplify_locals<'tcx>(body: &mut Body<'tcx>, tcx: TyCtxt<'tcx>) { // First, we're going to get a count of *actual* uses for every `Local`. - let mut used_locals = UsedLocals::new(body, tcx); + let mut used_locals = UsedLocals::new(body); // Next, we're going to remove any `Local` with zero actual uses. When we remove those // `Locals`, we're also going to subtract any uses of other `Locals` from the `used_locals` @@ -336,8 +336,7 @@ pub fn simplify_locals<'tcx>(body: &mut Body<'tcx>, tcx: TyCtxt<'tcx>) { remove_unused_definitions(&mut used_locals, body); // Finally, we'll actually do the work of shrinking `body.local_decls` and remapping the `Local`s. - let arg_count = body.arg_count.try_into().unwrap(); - let map = make_local_map(&mut body.local_decls, &used_locals, arg_count); + let map = make_local_map(&mut body.local_decls, &used_locals); // Only bother running the `LocalUpdater` if we actually found locals to remove. if map.iter().any(Option::is_none) { @@ -350,61 +349,54 @@ pub fn simplify_locals<'tcx>(body: &mut Body<'tcx>, tcx: TyCtxt<'tcx>) { } /// Construct the mapping while swapping out unused stuff out from the `vec`. -fn make_local_map<'tcx, V>( +fn make_local_map( local_decls: &mut IndexVec, - used_locals: &UsedLocals<'tcx>, - arg_count: u32, + used_locals: &UsedLocals, ) -> IndexVec> { - let mut map: IndexVec> = IndexVec::from_elem(None, local_decls); + let mut map: IndexVec> = IndexVec::from_elem(None, &*local_decls); let mut used = Local::new(0); for alive_index in local_decls.indices() { - // When creating the local map treat the `RETURN_PLACE` and arguments as used. - if alive_index.as_u32() <= arg_count || used_locals.is_used(alive_index) { - map[alive_index] = Some(used); - if alive_index != used { - local_decls.swap(alive_index, used); - } - used.increment_by(1); + // `is_used` treats the `RETURN_PLACE` and arguments as used. + if !used_locals.is_used(alive_index) { + continue; } + + map[alive_index] = Some(used); + if alive_index != used { + local_decls.swap(alive_index, used); + } + used.increment_by(1); } local_decls.truncate(used.index()); map } /// Keeps track of used & unused locals. -struct UsedLocals<'tcx> { +struct UsedLocals { increment: bool, + arg_count: u32, use_count: IndexVec, - is_static: bool, - local_decls: IndexVec>, - param_env: ParamEnv<'tcx>, - tcx: TyCtxt<'tcx>, } -impl UsedLocals<'tcx> { +impl UsedLocals { /// Determines which locals are used & unused in the given body. - fn new(body: &Body<'tcx>, tcx: TyCtxt<'tcx>) -> Self { - let def_id = body.source.def_id(); - let is_static = tcx.is_static(def_id); - let param_env = tcx.param_env(def_id); - let local_decls = body.local_decls.clone(); + fn new(body: &Body<'_>) -> Self { let mut this = Self { increment: true, + arg_count: body.arg_count.try_into().unwrap(), use_count: IndexVec::from_elem(0, &body.local_decls), - is_static, - local_decls, - param_env, - tcx, }; this.visit_body(body); this } /// Checks if local is used. + /// + /// Return place and arguments are always considered used. fn is_used(&self, local: Local) -> bool { trace!("is_used({:?}): use_count: {:?}", local, self.use_count[local]); - self.use_count[local] != 0 + local.as_u32() <= self.arg_count || self.use_count[local] != 0 } /// Updates the use counts to reflect the removal of given statement. @@ -432,7 +424,7 @@ impl UsedLocals<'tcx> { } } -impl Visitor<'tcx> for UsedLocals<'tcx> { +impl Visitor<'_> for UsedLocals { fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) { match statement.kind { StatementKind::LlvmInlineAsm(..) @@ -459,21 +451,7 @@ impl Visitor<'tcx> for UsedLocals<'tcx> { } } - fn visit_local(&mut self, local: &Local, ctx: PlaceContext, _location: Location) { - debug!("local: {:?} is_static: {:?}, ctx: {:?}", local, self.is_static, ctx); - // Do not count _0 as a used in `return;` if it is a ZST. - let return_place = *local == RETURN_PLACE - && matches!(ctx, PlaceContext::NonMutatingUse(visit::NonMutatingUseContext::Move)); - if !self.is_static && return_place { - let ty = self.local_decls[*local].ty; - let param_env_and = self.param_env.and(ty); - if let Ok(layout) = self.tcx.layout_of(param_env_and) { - debug!("layout.is_zst: {:?}", layout.is_zst()); - if layout.is_zst() { - return; - } - } - } + fn visit_local(&mut self, local: &Local, _ctx: PlaceContext, _location: Location) { if self.increment { self.use_count[*local] += 1; } else { @@ -484,10 +462,7 @@ impl Visitor<'tcx> for UsedLocals<'tcx> { } /// Removes unused definitions. Updates the used locals to reflect the changes made. -fn remove_unused_definitions<'a, 'tcx>( - used_locals: &'a mut UsedLocals<'tcx>, - body: &mut Body<'tcx>, -) { +fn remove_unused_definitions<'a, 'tcx>(used_locals: &'a mut UsedLocals, body: &mut Body<'tcx>) { // The use counts are updated as we remove the statements. A local might become unused // during the retain operation, leading to a temporary inconsistency (storage statements or // definitions referencing the local might remain). For correctness it is crucial that this From 899836306f65562912e36ace0631c46bb833db14 Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Mon, 15 Mar 2021 21:57:52 -0400 Subject: [PATCH 2/9] remove assignments to ZST places --- .../rustc_mir/src/transform/instcombine.rs | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_mir/src/transform/instcombine.rs b/compiler/rustc_mir/src/transform/instcombine.rs index bad82fe893eb8..5ac2ff1fc9a16 100644 --- a/compiler/rustc_mir/src/transform/instcombine.rs +++ b/compiler/rustc_mir/src/transform/instcombine.rs @@ -12,10 +12,12 @@ pub struct InstCombine; impl<'tcx> MirPass<'tcx> for InstCombine { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { + let param_env = tcx.param_env(body.source.def_id()); let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut(); - let ctx = InstCombineContext { tcx, local_decls }; + let ctx = InstCombineContext { tcx, local_decls, param_env }; for block in basic_blocks.iter_mut() { for statement in block.statements.iter_mut() { + ctx.combine_zst(&statement.source_info, &mut statement.kind); match statement.kind { StatementKind::Assign(box (_place, ref mut rvalue)) => { ctx.combine_bool_cmp(&statement.source_info, rvalue); @@ -32,6 +34,7 @@ impl<'tcx> MirPass<'tcx> for InstCombine { struct InstCombineContext<'tcx, 'a> { tcx: TyCtxt<'tcx>, local_decls: &'a LocalDecls<'tcx>, + param_env: ty::ParamEnv<'tcx>, } impl<'tcx, 'a> InstCombineContext<'tcx, 'a> { @@ -41,6 +44,28 @@ impl<'tcx, 'a> InstCombineContext<'tcx, 'a> { }) } + /// Remove assignments to inhabited ZST places. + fn combine_zst(&self, source_info: &SourceInfo, kind: &mut StatementKind<'tcx>) { + match kind { + StatementKind::Assign(box (place, _)) => { + let place_ty = place.ty(self.local_decls, self.tcx).ty; + if let Ok(layout) = self.tcx.layout_of(self.param_env.and(place_ty)) { + if layout.is_zst() && !layout.abi.is_uninhabited() { + if self.tcx.consider_optimizing(|| { + format!( + "InstCombine ZST - Place: {:?} SourceInfo: {:?}", + place, source_info + ) + }) { + *kind = StatementKind::Nop; + } + } + } + } + _ => {} + } + } + /// Transform boolean comparisons into logical operations. fn combine_bool_cmp(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) { match rvalue { From 90562b401ee63d05d2c96bb2240074dd528d9371 Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Mon, 15 Mar 2021 21:58:54 -0400 Subject: [PATCH 3/9] bless tests --- ..._allocation.main.ConstProp.after.32bit.mir | 2 +- ..._allocation.main.ConstProp.after.64bit.mir | 2 +- ...allocation2.main.ConstProp.after.32bit.mir | 2 +- ...allocation2.main.ConstProp.after.64bit.mir | 2 +- ...allocation3.main.ConstProp.after.32bit.mir | 2 +- ...allocation3.main.ConstProp.after.64bit.mir | 2 +- .../const_debuginfo.main.ConstDebugInfo.diff | 1 - .../const_prop/aggregate.main.ConstProp.diff | 2 +- .../array_index.main.ConstProp.32bit.diff | 2 +- .../array_index.main.ConstProp.64bit.diff | 2 +- .../bad_op_div_by_zero.main.ConstProp.diff | 2 +- .../bad_op_mod_by_zero.main.ConstProp.diff | 2 +- ...e_oob_for_slices.main.ConstProp.32bit.diff | 2 +- ...e_oob_for_slices.main.ConstProp.64bit.diff | 2 +- .../const_prop/boxes.main.ConstProp.diff | 2 +- .../const_prop/cast.main.ConstProp.diff | 2 +- .../checked_add.main.ConstProp.diff | 2 +- ..._prop_fails_gracefully.main.ConstProp.diff | 2 +- ...l_flow_simplification.hello.ConstProp.diff | 2 +- .../discriminant.main.ConstProp.32bit.diff | 2 +- .../discriminant.main.ConstProp.64bit.diff | 2 +- .../const_prop/indirect.main.ConstProp.diff | 2 +- .../issue_66971.main.ConstProp.diff | 5 +- .../issue_67019.main.ConstProp.diff | 2 +- ...arge_array_index.main.ConstProp.32bit.diff | 2 +- ...arge_array_index.main.ConstProp.64bit.diff | 2 +- .../mutable_variable.main.ConstProp.diff | 2 +- ...ble_variable_aggregate.main.ConstProp.diff | 2 +- ...able_aggregate_mut_ref.main.ConstProp.diff | 2 +- ...aggregate_partial_read.main.ConstProp.diff | 2 +- ...table_variable_no_prop.main.ConstProp.diff | 4 +- ...variable_unprop_assign.main.ConstProp.diff | 2 +- ...es_into_variable.main.ConstProp.32bit.diff | 2 +- ...es_into_variable.main.ConstProp.64bit.diff | 2 +- .../read_immutable_static.main.ConstProp.diff | 2 +- .../const_prop/ref_deref.main.ConstProp.diff | 2 +- .../ref_deref_project.main.ConstProp.diff | 2 +- .../reify_fn_ptr.main.ConstProp.diff | 2 +- .../repeat.main.ConstProp.32bit.diff | 2 +- .../repeat.main.ConstProp.64bit.diff | 2 +- ...ar_literal_propagation.main.ConstProp.diff | 2 +- .../slice_len.main.ConstProp.32bit.diff | 2 +- .../slice_len.main.ConstProp.64bit.diff | 2 +- ...le_literal_propagation.main.ConstProp.diff | 2 +- .../const_prop_miscompile.bar.ConstProp.diff | 4 +- .../const_prop_miscompile.foo.ConstProp.diff | 2 +- .../branch.main.DestinationPropagation.diff | 2 +- ...gation_arg.bar.DestinationPropagation.diff | 2 +- ...gation_arg.baz.DestinationPropagation.diff | 2 +- ...gation_arg.foo.DestinationPropagation.diff | 2 +- .../cycle.main.DestinationPropagation.diff | 2 +- .../union.main.DestinationPropagation.diff | 2 +- ...h.before-SimplifyBranches-final.after.diff | 2 +- ...ch_68867.try_sum.EarlyOtherwiseBranch.diff | 2 +- ...ine_scopes_parenting.main.Inline.after.mir | 1 - ..._73223.main.SimplifyArmIdentity.32bit.diff | 6 +-- ..._73223.main.SimplifyArmIdentity.64bit.diff | 6 +-- ...76432.test.SimplifyComparisonIntegral.diff | 2 +- ...s.foo.MatchBranchSimplification.32bit.diff | 29 +++++------ ...s.foo.MatchBranchSimplification.64bit.diff | 29 +++++------ ...e_branches.foo.PreCodegen.before.32bit.mir | 4 +- ...e_branches.foo.PreCodegen.before.64bit.mir | 4 +- ...nators.test.MultipleReturnTerminators.diff | 16 ------ ...entity.main.SimplifyArmIdentity.32bit.diff | 2 +- ...entity.main.SimplifyArmIdentity.64bit.diff | 2 +- ...ain.SimplifyBranches-after-const-prop.diff | 4 +- .../simplify_locals.c.SimplifyLocals.diff | 1 - .../simplify_locals.d1.SimplifyLocals.diff | 1 - .../simplify_locals.d2.SimplifyLocals.diff | 1 - .../simplify_locals.r.SimplifyLocals.diff | 1 - .../simplify_locals.t1.SimplifyLocals.diff | 1 - .../simplify_locals.t2.SimplifyLocals.diff | 1 - .../simplify_locals.t3.SimplifyLocals.diff | 1 - ..._locals_fixedpoint.foo.SimplifyLocals.diff | 49 ++++++------------- ...ves_unused_consts.main.SimplifyLocals.diff | 5 -- .../simplify_match.main.ConstProp.diff | 2 +- ...ls_access.main.SimplifyCfg-final.after.mir | 1 - ...oops.change_loop_body.ConstProp.32bit.diff | 4 +- ...oops.change_loop_body.ConstProp.64bit.diff | 4 +- ...le_storage.while_loop.PreCodegen.after.mir | 20 +++----- ...issue-26548-recursion-via-normalize.stderr | 6 +-- 81 files changed, 130 insertions(+), 187 deletions(-) diff --git a/src/test/mir-opt/const_allocation.main.ConstProp.after.32bit.mir b/src/test/mir-opt/const_allocation.main.ConstProp.after.32bit.mir index a137d7fadba10..a046539665b93 100644 --- a/src/test/mir-opt/const_allocation.main.ConstProp.after.32bit.mir +++ b/src/test/mir-opt/const_allocation.main.ConstProp.after.32bit.mir @@ -18,7 +18,7 @@ fn main() -> () { _1 = (*_2); // scope 0 at $DIR/const_allocation.rs:8:5: 8:8 StorageDead(_2); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9 StorageDead(_1); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9 - _0 = const (); // scope 0 at $DIR/const_allocation.rs:7:11: 9:2 + nop; // scope 0 at $DIR/const_allocation.rs:7:11: 9:2 return; // scope 0 at $DIR/const_allocation.rs:9:2: 9:2 } } diff --git a/src/test/mir-opt/const_allocation.main.ConstProp.after.64bit.mir b/src/test/mir-opt/const_allocation.main.ConstProp.after.64bit.mir index ef98cf9c09148..23859439208fe 100644 --- a/src/test/mir-opt/const_allocation.main.ConstProp.after.64bit.mir +++ b/src/test/mir-opt/const_allocation.main.ConstProp.after.64bit.mir @@ -18,7 +18,7 @@ fn main() -> () { _1 = (*_2); // scope 0 at $DIR/const_allocation.rs:8:5: 8:8 StorageDead(_2); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9 StorageDead(_1); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9 - _0 = const (); // scope 0 at $DIR/const_allocation.rs:7:11: 9:2 + nop; // scope 0 at $DIR/const_allocation.rs:7:11: 9:2 return; // scope 0 at $DIR/const_allocation.rs:9:2: 9:2 } } diff --git a/src/test/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir b/src/test/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir index d2e764f856f08..1e4bd4ba914d5 100644 --- a/src/test/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir +++ b/src/test/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir @@ -18,7 +18,7 @@ fn main() -> () { _1 = (*_2); // scope 0 at $DIR/const_allocation2.rs:5:5: 5:8 StorageDead(_2); // scope 0 at $DIR/const_allocation2.rs:5:8: 5:9 StorageDead(_1); // scope 0 at $DIR/const_allocation2.rs:5:8: 5:9 - _0 = const (); // scope 0 at $DIR/const_allocation2.rs:4:11: 6:2 + nop; // scope 0 at $DIR/const_allocation2.rs:4:11: 6:2 return; // scope 0 at $DIR/const_allocation2.rs:6:2: 6:2 } } diff --git a/src/test/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir b/src/test/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir index 00bf91f90bf61..f943beced3109 100644 --- a/src/test/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir +++ b/src/test/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir @@ -18,7 +18,7 @@ fn main() -> () { _1 = (*_2); // scope 0 at $DIR/const_allocation2.rs:5:5: 5:8 StorageDead(_2); // scope 0 at $DIR/const_allocation2.rs:5:8: 5:9 StorageDead(_1); // scope 0 at $DIR/const_allocation2.rs:5:8: 5:9 - _0 = const (); // scope 0 at $DIR/const_allocation2.rs:4:11: 6:2 + nop; // scope 0 at $DIR/const_allocation2.rs:4:11: 6:2 return; // scope 0 at $DIR/const_allocation2.rs:6:2: 6:2 } } diff --git a/src/test/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir b/src/test/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir index 519002da392e2..5c95afb586ff2 100644 --- a/src/test/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir +++ b/src/test/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir @@ -18,7 +18,7 @@ fn main() -> () { _1 = (*_2); // scope 0 at $DIR/const_allocation3.rs:5:5: 5:8 StorageDead(_2); // scope 0 at $DIR/const_allocation3.rs:5:8: 5:9 StorageDead(_1); // scope 0 at $DIR/const_allocation3.rs:5:8: 5:9 - _0 = const (); // scope 0 at $DIR/const_allocation3.rs:4:11: 6:2 + nop; // scope 0 at $DIR/const_allocation3.rs:4:11: 6:2 return; // scope 0 at $DIR/const_allocation3.rs:6:2: 6:2 } } diff --git a/src/test/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir b/src/test/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir index 73c4288c32e9d..3d1858de22e75 100644 --- a/src/test/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir +++ b/src/test/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir @@ -18,7 +18,7 @@ fn main() -> () { _1 = (*_2); // scope 0 at $DIR/const_allocation3.rs:5:5: 5:8 StorageDead(_2); // scope 0 at $DIR/const_allocation3.rs:5:8: 5:9 StorageDead(_1); // scope 0 at $DIR/const_allocation3.rs:5:8: 5:9 - _0 = const (); // scope 0 at $DIR/const_allocation3.rs:4:11: 6:2 + nop; // scope 0 at $DIR/const_allocation3.rs:4:11: 6:2 return; // scope 0 at $DIR/const_allocation3.rs:6:2: 6:2 } } diff --git a/src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff b/src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff index 47c3239b8bf25..48e2bf8f7e461 100644 --- a/src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff +++ b/src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff @@ -99,7 +99,6 @@ _13 = const 64_u32; // scope 8 at $DIR/const_debuginfo.rs:21:13: 21:22 StorageDead(_15); // scope 8 at $DIR/const_debuginfo.rs:21:21: 21:22 StorageDead(_14); // scope 8 at $DIR/const_debuginfo.rs:21:21: 21:22 - _0 = const (); // scope 0 at $DIR/const_debuginfo.rs:8:11: 22:2 StorageDead(_13); // scope 8 at $DIR/const_debuginfo.rs:22:1: 22:2 StorageDead(_12); // scope 7 at $DIR/const_debuginfo.rs:22:1: 22:2 StorageDead(_11); // scope 6 at $DIR/const_debuginfo.rs:22:1: 22:2 diff --git a/src/test/mir-opt/const_prop/aggregate.main.ConstProp.diff b/src/test/mir-opt/const_prop/aggregate.main.ConstProp.diff index 54877f9f53c66..c3b2e535f0e16 100644 --- a/src/test/mir-opt/const_prop/aggregate.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/aggregate.main.ConstProp.diff @@ -23,7 +23,7 @@ + _1 = const 1_i32; // scope 0 at $DIR/aggregate.rs:5:13: 5:28 StorageDead(_2); // scope 0 at $DIR/aggregate.rs:5:27: 5:28 StorageDead(_3); // scope 0 at $DIR/aggregate.rs:5:28: 5:29 - _0 = const (); // scope 0 at $DIR/aggregate.rs:4:11: 6:2 + nop; // scope 0 at $DIR/aggregate.rs:4:11: 6:2 StorageDead(_1); // scope 0 at $DIR/aggregate.rs:6:1: 6:2 return; // scope 0 at $DIR/aggregate.rs:6:2: 6:2 } diff --git a/src/test/mir-opt/const_prop/array_index.main.ConstProp.32bit.diff b/src/test/mir-opt/const_prop/array_index.main.ConstProp.32bit.diff index 4664934690845..e69f887cea8fa 100644 --- a/src/test/mir-opt/const_prop/array_index.main.ConstProp.32bit.diff +++ b/src/test/mir-opt/const_prop/array_index.main.ConstProp.32bit.diff @@ -30,7 +30,7 @@ + _1 = const 2_u32; // scope 0 at $DIR/array_index.rs:5:18: 5:33 StorageDead(_3); // scope 0 at $DIR/array_index.rs:5:33: 5:34 StorageDead(_2); // scope 0 at $DIR/array_index.rs:5:33: 5:34 - _0 = const (); // scope 0 at $DIR/array_index.rs:4:11: 6:2 + nop; // scope 0 at $DIR/array_index.rs:4:11: 6:2 StorageDead(_1); // scope 0 at $DIR/array_index.rs:6:1: 6:2 return; // scope 0 at $DIR/array_index.rs:6:2: 6:2 } diff --git a/src/test/mir-opt/const_prop/array_index.main.ConstProp.64bit.diff b/src/test/mir-opt/const_prop/array_index.main.ConstProp.64bit.diff index 4664934690845..e69f887cea8fa 100644 --- a/src/test/mir-opt/const_prop/array_index.main.ConstProp.64bit.diff +++ b/src/test/mir-opt/const_prop/array_index.main.ConstProp.64bit.diff @@ -30,7 +30,7 @@ + _1 = const 2_u32; // scope 0 at $DIR/array_index.rs:5:18: 5:33 StorageDead(_3); // scope 0 at $DIR/array_index.rs:5:33: 5:34 StorageDead(_2); // scope 0 at $DIR/array_index.rs:5:33: 5:34 - _0 = const (); // scope 0 at $DIR/array_index.rs:4:11: 6:2 + nop; // scope 0 at $DIR/array_index.rs:4:11: 6:2 StorageDead(_1); // scope 0 at $DIR/array_index.rs:6:1: 6:2 return; // scope 0 at $DIR/array_index.rs:6:2: 6:2 } diff --git a/src/test/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.diff b/src/test/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.diff index ba081f95fa8a9..8d4852e3727e0 100644 --- a/src/test/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.diff @@ -45,7 +45,7 @@ - _2 = Div(const 1_i32, move _3); // scope 1 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19 + _2 = Div(const 1_i32, const 0_i32); // scope 1 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19 StorageDead(_3); // scope 1 at $DIR/bad_op_div_by_zero.rs:5:18: 5:19 - _0 = const (); // scope 0 at $DIR/bad_op_div_by_zero.rs:3:11: 6:2 + nop; // scope 0 at $DIR/bad_op_div_by_zero.rs:3:11: 6:2 StorageDead(_2); // scope 1 at $DIR/bad_op_div_by_zero.rs:6:1: 6:2 StorageDead(_1); // scope 0 at $DIR/bad_op_div_by_zero.rs:6:1: 6:2 return; // scope 0 at $DIR/bad_op_div_by_zero.rs:6:2: 6:2 diff --git a/src/test/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff b/src/test/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff index a843cacf4d93f..ae1fa64e745b4 100644 --- a/src/test/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff @@ -45,7 +45,7 @@ - _2 = Rem(const 1_i32, move _3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19 + _2 = Rem(const 1_i32, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19 StorageDead(_3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:18: 5:19 - _0 = const (); // scope 0 at $DIR/bad_op_mod_by_zero.rs:3:11: 6:2 + nop; // scope 0 at $DIR/bad_op_mod_by_zero.rs:3:11: 6:2 StorageDead(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:6:1: 6:2 StorageDead(_1); // scope 0 at $DIR/bad_op_mod_by_zero.rs:6:1: 6:2 return; // scope 0 at $DIR/bad_op_mod_by_zero.rs:6:2: 6:2 diff --git a/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff b/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff index 8c10b3518d8c8..59b26452f02b7 100644 --- a/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff +++ b/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff @@ -50,7 +50,7 @@ bb1: { _5 = (*_1)[_6]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25 StorageDead(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:25: 7:26 - _0 = const (); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:6:5: 8:6 + nop; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:6:5: 8:6 StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:8:5: 8:6 StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:9:1: 9:2 return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:9:2: 9:2 diff --git a/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff b/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff index 8c10b3518d8c8..59b26452f02b7 100644 --- a/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff +++ b/src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff @@ -50,7 +50,7 @@ bb1: { _5 = (*_1)[_6]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25 StorageDead(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:25: 7:26 - _0 = const (); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:6:5: 8:6 + nop; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:6:5: 8:6 StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:8:5: 8:6 StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:9:1: 9:2 return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:9:2: 9:2 diff --git a/src/test/mir-opt/const_prop/boxes.main.ConstProp.diff b/src/test/mir-opt/const_prop/boxes.main.ConstProp.diff index 1412162d78bff..9fcbd32ca686d 100644 --- a/src/test/mir-opt/const_prop/boxes.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/boxes.main.ConstProp.diff @@ -28,7 +28,7 @@ bb1: { StorageDead(_3); // scope 0 at $DIR/boxes.rs:12:26: 12:27 - _0 = const (); // scope 0 at $DIR/boxes.rs:11:11: 13:2 + nop; // scope 0 at $DIR/boxes.rs:11:11: 13:2 StorageDead(_1); // scope 0 at $DIR/boxes.rs:13:1: 13:2 return; // scope 0 at $DIR/boxes.rs:13:2: 13:2 } diff --git a/src/test/mir-opt/const_prop/cast.main.ConstProp.diff b/src/test/mir-opt/const_prop/cast.main.ConstProp.diff index 1ccc15458224a..21326d8b1cf57 100644 --- a/src/test/mir-opt/const_prop/cast.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/cast.main.ConstProp.diff @@ -19,7 +19,7 @@ StorageLive(_2); // scope 1 at $DIR/cast.rs:6:9: 6:10 - _2 = const 42_u32 as u8 (Misc); // scope 1 at $DIR/cast.rs:6:13: 6:24 + _2 = const 42_u8; // scope 1 at $DIR/cast.rs:6:13: 6:24 - _0 = const (); // scope 0 at $DIR/cast.rs:3:11: 7:2 + nop; // scope 0 at $DIR/cast.rs:3:11: 7:2 StorageDead(_2); // scope 1 at $DIR/cast.rs:7:1: 7:2 StorageDead(_1); // scope 0 at $DIR/cast.rs:7:1: 7:2 return; // scope 0 at $DIR/cast.rs:7:2: 7:2 diff --git a/src/test/mir-opt/const_prop/checked_add.main.ConstProp.diff b/src/test/mir-opt/const_prop/checked_add.main.ConstProp.diff index 3397ef95856a5..40705bece518c 100644 --- a/src/test/mir-opt/const_prop/checked_add.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/checked_add.main.ConstProp.diff @@ -23,7 +23,7 @@ bb1: { - _1 = move (_2.0: u32); // scope 0 at $DIR/checked_add.rs:5:18: 5:23 + _1 = const 2_u32; // scope 0 at $DIR/checked_add.rs:5:18: 5:23 - _0 = const (); // scope 0 at $DIR/checked_add.rs:4:11: 6:2 + nop; // scope 0 at $DIR/checked_add.rs:4:11: 6:2 StorageDead(_1); // scope 0 at $DIR/checked_add.rs:6:1: 6:2 return; // scope 0 at $DIR/checked_add.rs:6:2: 6:2 } diff --git a/src/test/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff b/src/test/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff index 6034645864656..e0e6947fdbf40 100644 --- a/src/test/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff @@ -39,7 +39,7 @@ bb1: { StorageDead(_5); // scope 1 at $DIR/const_prop_fails_gracefully.rs:8:11: 8:12 StorageDead(_4); // scope 1 at $DIR/const_prop_fails_gracefully.rs:8:12: 8:13 - _0 = const (); // scope 0 at $DIR/const_prop_fails_gracefully.rs:5:11: 9:2 + nop; // scope 0 at $DIR/const_prop_fails_gracefully.rs:5:11: 9:2 StorageDead(_1); // scope 0 at $DIR/const_prop_fails_gracefully.rs:9:1: 9:2 return; // scope 0 at $DIR/const_prop_fails_gracefully.rs:9:2: 9:2 } diff --git a/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff b/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff index e1f2fbe84434a..22042e69f877f 100644 --- a/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff +++ b/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff @@ -29,7 +29,7 @@ } bb2: { - _0 = const (); // scope 0 at $DIR/control-flow-simplification.rs:14:6: 14:6 + nop; // scope 0 at $DIR/control-flow-simplification.rs:14:6: 14:6 StorageDead(_1); // scope 0 at $DIR/control-flow-simplification.rs:14:5: 14:6 return; // scope 0 at $DIR/control-flow-simplification.rs:15:2: 15:2 } diff --git a/src/test/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff b/src/test/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff index 99fa0dcbc90c5..706cd63a73f6a 100644 --- a/src/test/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff +++ b/src/test/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff @@ -41,7 +41,7 @@ _1 = Add(move _2, const 0_i32); // scope 0 at $DIR/discriminant.rs:11:13: 11:68 StorageDead(_2); // scope 0 at $DIR/discriminant.rs:11:67: 11:68 StorageDead(_3); // scope 0 at $DIR/discriminant.rs:11:68: 11:69 - _0 = const (); // scope 0 at $DIR/discriminant.rs:10:11: 12:2 + nop; // scope 0 at $DIR/discriminant.rs:10:11: 12:2 StorageDead(_1); // scope 0 at $DIR/discriminant.rs:12:1: 12:2 return; // scope 0 at $DIR/discriminant.rs:12:2: 12:2 } diff --git a/src/test/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff b/src/test/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff index 99fa0dcbc90c5..706cd63a73f6a 100644 --- a/src/test/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff +++ b/src/test/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff @@ -41,7 +41,7 @@ _1 = Add(move _2, const 0_i32); // scope 0 at $DIR/discriminant.rs:11:13: 11:68 StorageDead(_2); // scope 0 at $DIR/discriminant.rs:11:67: 11:68 StorageDead(_3); // scope 0 at $DIR/discriminant.rs:11:68: 11:69 - _0 = const (); // scope 0 at $DIR/discriminant.rs:10:11: 12:2 + nop; // scope 0 at $DIR/discriminant.rs:10:11: 12:2 StorageDead(_1); // scope 0 at $DIR/discriminant.rs:12:1: 12:2 return; // scope 0 at $DIR/discriminant.rs:12:2: 12:2 } diff --git a/src/test/mir-opt/const_prop/indirect.main.ConstProp.diff b/src/test/mir-opt/const_prop/indirect.main.ConstProp.diff index 9ddb34e58e5a6..e39c164183921 100644 --- a/src/test/mir-opt/const_prop/indirect.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/indirect.main.ConstProp.diff @@ -28,7 +28,7 @@ - _1 = move (_3.0: u8); // scope 0 at $DIR/indirect.rs:5:13: 5:29 + _1 = const 3_u8; // scope 0 at $DIR/indirect.rs:5:13: 5:29 StorageDead(_2); // scope 0 at $DIR/indirect.rs:5:28: 5:29 - _0 = const (); // scope 0 at $DIR/indirect.rs:4:11: 6:2 + nop; // scope 0 at $DIR/indirect.rs:4:11: 6:2 StorageDead(_1); // scope 0 at $DIR/indirect.rs:6:1: 6:2 return; // scope 0 at $DIR/indirect.rs:6:2: 6:2 } diff --git a/src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff b/src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff index 6bf553bc58015..c5af2801b472b 100644 --- a/src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff @@ -11,8 +11,7 @@ StorageLive(_1); // scope 0 at $DIR/issue-66971.rs:16:5: 16:23 StorageLive(_2); // scope 0 at $DIR/issue-66971.rs:16:12: 16:22 StorageLive(_3); // scope 0 at $DIR/issue-66971.rs:16:13: 16:15 -- (_2.0: ()) = move _3; // scope 0 at $DIR/issue-66971.rs:16:12: 16:22 -+ (_2.0: ()) = const (); // scope 0 at $DIR/issue-66971.rs:16:12: 16:22 + nop; // scope 0 at $DIR/issue-66971.rs:16:12: 16:22 (_2.1: u8) = const 0_u8; // scope 0 at $DIR/issue-66971.rs:16:12: 16:22 (_2.2: u8) = const 0_u8; // scope 0 at $DIR/issue-66971.rs:16:12: 16:22 StorageDead(_3); // scope 0 at $DIR/issue-66971.rs:16:21: 16:22 @@ -25,7 +24,7 @@ bb1: { StorageDead(_2); // scope 0 at $DIR/issue-66971.rs:16:22: 16:23 StorageDead(_1); // scope 0 at $DIR/issue-66971.rs:16:23: 16:24 - _0 = const (); // scope 0 at $DIR/issue-66971.rs:15:11: 17:2 + nop; // scope 0 at $DIR/issue-66971.rs:15:11: 17:2 return; // scope 0 at $DIR/issue-66971.rs:17:2: 17:2 } } diff --git a/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff b/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff index da35bf18c7116..f20dc0785d230 100644 --- a/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff @@ -28,7 +28,7 @@ bb1: { StorageDead(_2); // scope 0 at $DIR/issue-67019.rs:11:19: 11:20 StorageDead(_1); // scope 0 at $DIR/issue-67019.rs:11:20: 11:21 - _0 = const (); // scope 0 at $DIR/issue-67019.rs:10:11: 12:2 + nop; // scope 0 at $DIR/issue-67019.rs:10:11: 12:2 return; // scope 0 at $DIR/issue-67019.rs:12:2: 12:2 } } diff --git a/src/test/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.diff b/src/test/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.diff index fa790822b6bff..8276318f1ef84 100644 --- a/src/test/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.diff +++ b/src/test/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.diff @@ -29,7 +29,7 @@ _1 = _2[_3]; // scope 0 at $DIR/large_array_index.rs:6:17: 6:32 StorageDead(_3); // scope 0 at $DIR/large_array_index.rs:6:32: 6:33 StorageDead(_2); // scope 0 at $DIR/large_array_index.rs:6:32: 6:33 - _0 = const (); // scope 0 at $DIR/large_array_index.rs:4:11: 7:2 + nop; // scope 0 at $DIR/large_array_index.rs:4:11: 7:2 StorageDead(_1); // scope 0 at $DIR/large_array_index.rs:7:1: 7:2 return; // scope 0 at $DIR/large_array_index.rs:7:2: 7:2 } diff --git a/src/test/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.diff b/src/test/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.diff index fa790822b6bff..8276318f1ef84 100644 --- a/src/test/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.diff +++ b/src/test/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.diff @@ -29,7 +29,7 @@ _1 = _2[_3]; // scope 0 at $DIR/large_array_index.rs:6:17: 6:32 StorageDead(_3); // scope 0 at $DIR/large_array_index.rs:6:32: 6:33 StorageDead(_2); // scope 0 at $DIR/large_array_index.rs:6:32: 6:33 - _0 = const (); // scope 0 at $DIR/large_array_index.rs:4:11: 7:2 + nop; // scope 0 at $DIR/large_array_index.rs:4:11: 7:2 StorageDead(_1); // scope 0 at $DIR/large_array_index.rs:7:1: 7:2 return; // scope 0 at $DIR/large_array_index.rs:7:2: 7:2 } diff --git a/src/test/mir-opt/const_prop/mutable_variable.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable.main.ConstProp.diff index 349f1557a86ef..f159cfa025cc8 100644 --- a/src/test/mir-opt/const_prop/mutable_variable.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable.main.ConstProp.diff @@ -19,7 +19,7 @@ StorageLive(_2); // scope 1 at $DIR/mutable_variable.rs:7:9: 7:10 - _2 = _1; // scope 1 at $DIR/mutable_variable.rs:7:13: 7:14 + _2 = const 99_i32; // scope 1 at $DIR/mutable_variable.rs:7:13: 7:14 - _0 = const (); // scope 0 at $DIR/mutable_variable.rs:4:11: 8:2 + nop; // scope 0 at $DIR/mutable_variable.rs:4:11: 8:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable.rs:8:1: 8:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable.rs:8:1: 8:2 return; // scope 0 at $DIR/mutable_variable.rs:8:2: 8:2 diff --git a/src/test/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff index 12b02e90345d9..b22eab05005c2 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff @@ -23,7 +23,7 @@ + // mir::Constant + // + span: $DIR/mutable_variable_aggregate.rs:7:13: 7:14 + // + literal: Const { ty: (i32, i32), val: Value(ByRef { alloc: Allocation { bytes: [42, 0, 0, 0, 99, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) } - _0 = const (); // scope 0 at $DIR/mutable_variable_aggregate.rs:4:11: 8:2 + nop; // scope 0 at $DIR/mutable_variable_aggregate.rs:4:11: 8:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:8:1: 8:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:8:1: 8:2 return; // scope 0 at $DIR/mutable_variable_aggregate.rs:8:2: 8:2 diff --git a/src/test/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff index 6dc0e8ab3cf74..32e425d9b1f78 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff @@ -25,7 +25,7 @@ ((*_2).1: i32) = const 99_i32; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:7:5: 7:13 StorageLive(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:8:9: 8:10 _3 = _1; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:8:13: 8:14 - _0 = const (); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:4:11: 9:2 + nop; // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:4:11: 9:2 StorageDead(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:9:1: 9:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:9:1: 9:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:9:1: 9:2 diff --git a/src/test/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff index 08dd2d4da31e1..86fac1270d0fc 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff @@ -26,7 +26,7 @@ StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:8:9: 8:10 - _2 = (_1.1: i32); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:8:13: 8:16 + _2 = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:8:13: 8:16 - _0 = const (); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:4:11: 9:2 + nop; // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:4:11: 9:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:9:1: 9:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:9:1: 9:2 return; // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:9:2: 9:2 diff --git a/src/test/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff index f6e173620ecb2..5dad8e721fb13 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff @@ -34,11 +34,11 @@ _1 = move _3; // scope 2 at $DIR/mutable_variable_no_prop.rs:9:9: 9:19 StorageDead(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:9:18: 9:19 StorageDead(_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:9:19: 9:20 - _2 = const (); // scope 2 at $DIR/mutable_variable_no_prop.rs:8:5: 10:6 + nop; // scope 2 at $DIR/mutable_variable_no_prop.rs:8:5: 10:6 StorageDead(_2); // scope 1 at $DIR/mutable_variable_no_prop.rs:10:5: 10:6 StorageLive(_5); // scope 1 at $DIR/mutable_variable_no_prop.rs:11:9: 11:10 _5 = _1; // scope 1 at $DIR/mutable_variable_no_prop.rs:11:13: 11:14 - _0 = const (); // scope 0 at $DIR/mutable_variable_no_prop.rs:6:11: 12:2 + nop; // scope 0 at $DIR/mutable_variable_no_prop.rs:6:11: 12:2 StorageDead(_5); // scope 1 at $DIR/mutable_variable_no_prop.rs:12:1: 12:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_no_prop.rs:12:1: 12:2 return; // scope 0 at $DIR/mutable_variable_no_prop.rs:12:2: 12:2 diff --git a/src/test/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff index 63bdcb2bc11b4..49854f7fba142 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff @@ -41,7 +41,7 @@ _4 = (_2.1: i32); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:8:13: 8:16 StorageLive(_5); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:9:9: 9:10 _5 = (_2.0: i32); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:9:13: 9:16 - _0 = const (); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:4:11: 10:2 + nop; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:4:11: 10:2 StorageDead(_5); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:10:1: 10:2 StorageDead(_4); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:10:1: 10:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:10:1: 10:2 diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff index a10bac4f3ea3b..df802294c0daf 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff @@ -60,7 +60,7 @@ - _8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38 + _8 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38 StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:14:38: 14:39 - _0 = const (); // scope 0 at $DIR/optimizes_into_variable.rs:11:11: 15:2 + nop; // scope 0 at $DIR/optimizes_into_variable.rs:11:11: 15:2 StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2 StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2 StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2 diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff index a10bac4f3ea3b..df802294c0daf 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff @@ -60,7 +60,7 @@ - _8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38 + _8 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38 StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:14:38: 14:39 - _0 = const (); // scope 0 at $DIR/optimizes_into_variable.rs:11:11: 15:2 + nop; // scope 0 at $DIR/optimizes_into_variable.rs:11:11: 15:2 StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2 StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2 StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2 diff --git a/src/test/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff b/src/test/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff index 07c78be69c0c3..0d141a070ff62 100644 --- a/src/test/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff @@ -42,7 +42,7 @@ StorageDead(_2); // scope 0 at $DIR/read_immutable_static.rs:7:21: 7:22 StorageDead(_5); // scope 0 at $DIR/read_immutable_static.rs:7:22: 7:23 StorageDead(_3); // scope 0 at $DIR/read_immutable_static.rs:7:22: 7:23 - _0 = const (); // scope 0 at $DIR/read_immutable_static.rs:6:11: 8:2 + nop; // scope 0 at $DIR/read_immutable_static.rs:6:11: 8:2 StorageDead(_1); // scope 0 at $DIR/read_immutable_static.rs:8:1: 8:2 return; // scope 0 at $DIR/read_immutable_static.rs:8:2: 8:2 } diff --git a/src/test/mir-opt/const_prop/ref_deref.main.ConstProp.diff b/src/test/mir-opt/const_prop/ref_deref.main.ConstProp.diff index 4fd1b8b227649..1f4460c6e3af6 100644 --- a/src/test/mir-opt/const_prop/ref_deref.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/ref_deref.main.ConstProp.diff @@ -23,7 +23,7 @@ + _1 = const 4_i32; // scope 0 at $DIR/ref_deref.rs:5:5: 5:10 StorageDead(_2); // scope 0 at $DIR/ref_deref.rs:5:10: 5:11 StorageDead(_1); // scope 0 at $DIR/ref_deref.rs:5:10: 5:11 - _0 = const (); // scope 0 at $DIR/ref_deref.rs:4:11: 6:2 + nop; // scope 0 at $DIR/ref_deref.rs:4:11: 6:2 return; // scope 0 at $DIR/ref_deref.rs:6:2: 6:2 } } diff --git a/src/test/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff b/src/test/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff index 812c7c9771801..c464813994291 100644 --- a/src/test/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff @@ -22,7 +22,7 @@ _1 = (*_2); // scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17 StorageDead(_2); // scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 StorageDead(_1); // scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 - _0 = const (); // scope 0 at $DIR/ref_deref_project.rs:4:11: 6:2 + nop; // scope 0 at $DIR/ref_deref_project.rs:4:11: 6:2 return; // scope 0 at $DIR/ref_deref_project.rs:6:2: 6:2 } } diff --git a/src/test/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff b/src/test/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff index 02eb3155be9f3..1aeeae91d203f 100644 --- a/src/test/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff @@ -22,7 +22,7 @@ _1 = move _2 as *const fn() (Misc); // scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:41 StorageDead(_2); // scope 0 at $DIR/reify_fn_ptr.rs:4:40: 4:41 StorageDead(_1); // scope 0 at $DIR/reify_fn_ptr.rs:4:41: 4:42 - _0 = const (); // scope 0 at $DIR/reify_fn_ptr.rs:3:11: 5:2 + nop; // scope 0 at $DIR/reify_fn_ptr.rs:3:11: 5:2 return; // scope 0 at $DIR/reify_fn_ptr.rs:5:2: 5:2 } } diff --git a/src/test/mir-opt/const_prop/repeat.main.ConstProp.32bit.diff b/src/test/mir-opt/const_prop/repeat.main.ConstProp.32bit.diff index 98f409f326a58..1d9e4712d5a22 100644 --- a/src/test/mir-opt/const_prop/repeat.main.ConstProp.32bit.diff +++ b/src/test/mir-opt/const_prop/repeat.main.ConstProp.32bit.diff @@ -35,7 +35,7 @@ StorageDead(_2); // scope 0 at $DIR/repeat.rs:6:31: 6:32 StorageDead(_4); // scope 0 at $DIR/repeat.rs:6:32: 6:33 StorageDead(_3); // scope 0 at $DIR/repeat.rs:6:32: 6:33 - _0 = const (); // scope 0 at $DIR/repeat.rs:5:11: 7:2 + nop; // scope 0 at $DIR/repeat.rs:5:11: 7:2 StorageDead(_1); // scope 0 at $DIR/repeat.rs:7:1: 7:2 return; // scope 0 at $DIR/repeat.rs:7:2: 7:2 } diff --git a/src/test/mir-opt/const_prop/repeat.main.ConstProp.64bit.diff b/src/test/mir-opt/const_prop/repeat.main.ConstProp.64bit.diff index 98f409f326a58..1d9e4712d5a22 100644 --- a/src/test/mir-opt/const_prop/repeat.main.ConstProp.64bit.diff +++ b/src/test/mir-opt/const_prop/repeat.main.ConstProp.64bit.diff @@ -35,7 +35,7 @@ StorageDead(_2); // scope 0 at $DIR/repeat.rs:6:31: 6:32 StorageDead(_4); // scope 0 at $DIR/repeat.rs:6:32: 6:33 StorageDead(_3); // scope 0 at $DIR/repeat.rs:6:32: 6:33 - _0 = const (); // scope 0 at $DIR/repeat.rs:5:11: 7:2 + nop; // scope 0 at $DIR/repeat.rs:5:11: 7:2 StorageDead(_1); // scope 0 at $DIR/repeat.rs:7:1: 7:2 return; // scope 0 at $DIR/repeat.rs:7:2: 7:2 } diff --git a/src/test/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff b/src/test/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff index a4232d178a32e..af48ff0b098e7 100644 --- a/src/test/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff @@ -27,7 +27,7 @@ bb1: { StorageDead(_3); // scope 1 at $DIR/scalar_literal_propagation.rs:4:14: 4:15 StorageDead(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:4:15: 4:16 - _0 = const (); // scope 0 at $DIR/scalar_literal_propagation.rs:2:11: 5:2 + nop; // scope 0 at $DIR/scalar_literal_propagation.rs:2:11: 5:2 StorageDead(_1); // scope 0 at $DIR/scalar_literal_propagation.rs:5:1: 5:2 return; // scope 0 at $DIR/scalar_literal_propagation.rs:5:2: 5:2 } diff --git a/src/test/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff b/src/test/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff index 240cc8e231168..2d7c58a605474 100644 --- a/src/test/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff +++ b/src/test/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff @@ -46,7 +46,7 @@ StorageDead(_4); // scope 0 at $DIR/slice_len.rs:5:33: 5:34 StorageDead(_2); // scope 0 at $DIR/slice_len.rs:5:33: 5:34 StorageDead(_1); // scope 0 at $DIR/slice_len.rs:5:33: 5:34 - _0 = const (); // scope 0 at $DIR/slice_len.rs:4:11: 6:2 + nop; // scope 0 at $DIR/slice_len.rs:4:11: 6:2 return; // scope 0 at $DIR/slice_len.rs:6:2: 6:2 } } diff --git a/src/test/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff b/src/test/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff index 240cc8e231168..2d7c58a605474 100644 --- a/src/test/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff +++ b/src/test/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff @@ -46,7 +46,7 @@ StorageDead(_4); // scope 0 at $DIR/slice_len.rs:5:33: 5:34 StorageDead(_2); // scope 0 at $DIR/slice_len.rs:5:33: 5:34 StorageDead(_1); // scope 0 at $DIR/slice_len.rs:5:33: 5:34 - _0 = const (); // scope 0 at $DIR/slice_len.rs:4:11: 6:2 + nop; // scope 0 at $DIR/slice_len.rs:4:11: 6:2 return; // scope 0 at $DIR/slice_len.rs:6:2: 6:2 } } diff --git a/src/test/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff b/src/test/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff index da4b135d4c6d6..176581fc5b998 100644 --- a/src/test/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff @@ -30,7 +30,7 @@ bb1: { StorageDead(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:5:14: 5:15 StorageDead(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:5:15: 5:16 - _0 = const (); // scope 0 at $DIR/tuple_literal_propagation.rs:2:11: 6:2 + nop; // scope 0 at $DIR/tuple_literal_propagation.rs:2:11: 6:2 StorageDead(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:6:1: 6:2 return; // scope 0 at $DIR/tuple_literal_propagation.rs:6:2: 6:2 } diff --git a/src/test/mir-opt/const_prop_miscompile.bar.ConstProp.diff b/src/test/mir-opt/const_prop_miscompile.bar.ConstProp.diff index 5a3a99e49311f..0864eaba7199d 100644 --- a/src/test/mir-opt/const_prop_miscompile.bar.ConstProp.diff +++ b/src/test/mir-opt/const_prop_miscompile.bar.ConstProp.diff @@ -25,14 +25,14 @@ _3 = &raw mut (_1.0: i32); // scope 2 at $DIR/const_prop_miscompile.rs:14:10: 14:22 (*_3) = const 5_i32; // scope 2 at $DIR/const_prop_miscompile.rs:14:9: 14:26 StorageDead(_3); // scope 2 at $DIR/const_prop_miscompile.rs:14:26: 14:27 - _2 = const (); // scope 2 at $DIR/const_prop_miscompile.rs:13:5: 15:6 + nop; // scope 2 at $DIR/const_prop_miscompile.rs:13:5: 15:6 StorageDead(_2); // scope 1 at $DIR/const_prop_miscompile.rs:15:5: 15:6 StorageLive(_4); // scope 1 at $DIR/const_prop_miscompile.rs:16:9: 16:10 StorageLive(_5); // scope 1 at $DIR/const_prop_miscompile.rs:16:13: 16:20 _5 = (_1.0: i32); // scope 1 at $DIR/const_prop_miscompile.rs:16:15: 16:18 _4 = Eq(move _5, const 5_i32); // scope 1 at $DIR/const_prop_miscompile.rs:16:13: 16:25 StorageDead(_5); // scope 1 at $DIR/const_prop_miscompile.rs:16:24: 16:25 - _0 = const (); // scope 0 at $DIR/const_prop_miscompile.rs:11:10: 17:2 + nop; // scope 0 at $DIR/const_prop_miscompile.rs:11:10: 17:2 StorageDead(_4); // scope 1 at $DIR/const_prop_miscompile.rs:17:1: 17:2 StorageDead(_1); // scope 0 at $DIR/const_prop_miscompile.rs:17:1: 17:2 return; // scope 0 at $DIR/const_prop_miscompile.rs:17:2: 17:2 diff --git a/src/test/mir-opt/const_prop_miscompile.foo.ConstProp.diff b/src/test/mir-opt/const_prop_miscompile.foo.ConstProp.diff index 648260c7c20d9..f7375cb611301 100644 --- a/src/test/mir-opt/const_prop_miscompile.foo.ConstProp.diff +++ b/src/test/mir-opt/const_prop_miscompile.foo.ConstProp.diff @@ -26,7 +26,7 @@ _4 = (_1.0: i32); // scope 1 at $DIR/const_prop_miscompile.rs:7:15: 7:18 _3 = Eq(move _4, const 5_i32); // scope 1 at $DIR/const_prop_miscompile.rs:7:13: 7:25 StorageDead(_4); // scope 1 at $DIR/const_prop_miscompile.rs:7:24: 7:25 - _0 = const (); // scope 0 at $DIR/const_prop_miscompile.rs:4:10: 8:2 + nop; // scope 0 at $DIR/const_prop_miscompile.rs:4:10: 8:2 StorageDead(_3); // scope 1 at $DIR/const_prop_miscompile.rs:8:1: 8:2 StorageDead(_1); // scope 0 at $DIR/const_prop_miscompile.rs:8:1: 8:2 return; // scope 0 at $DIR/const_prop_miscompile.rs:8:2: 8:2 diff --git a/src/test/mir-opt/dest-prop/branch.main.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/branch.main.DestinationPropagation.diff index e11d24cac8c2e..500d6d20db893 100644 --- a/src/test/mir-opt/dest-prop/branch.main.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/branch.main.DestinationPropagation.diff @@ -62,7 +62,7 @@ bb6: { StorageDead(_3); // scope 1 at $DIR/branch.rs:20:5: 20:6 - _0 = const (); // scope 0 at $DIR/branch.rs:12:11: 21:2 + nop; // scope 0 at $DIR/branch.rs:12:11: 21:2 - StorageDead(_2); // scope 1 at $DIR/branch.rs:21:1: 21:2 - StorageDead(_1); // scope 0 at $DIR/branch.rs:21:1: 21:2 + nop; // scope 1 at $DIR/branch.rs:21:1: 21:2 diff --git a/src/test/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff index dce8800e986c9..383f00f01253b 100644 --- a/src/test/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff @@ -21,7 +21,7 @@ StorageDead(_3); // scope 0 at $DIR/copy_propagation_arg.rs:16:12: 16:13 StorageDead(_2); // scope 0 at $DIR/copy_propagation_arg.rs:16:13: 16:14 _1 = const 5_u8; // scope 0 at $DIR/copy_propagation_arg.rs:17:5: 17:10 - _0 = const (); // scope 0 at $DIR/copy_propagation_arg.rs:15:19: 18:2 + nop; // scope 0 at $DIR/copy_propagation_arg.rs:15:19: 18:2 return; // scope 0 at $DIR/copy_propagation_arg.rs:18:2: 18:2 } } diff --git a/src/test/mir-opt/dest-prop/copy_propagation_arg.baz.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/copy_propagation_arg.baz.DestinationPropagation.diff index 2f8c76eb65a9d..2349d5b0771b5 100644 --- a/src/test/mir-opt/dest-prop/copy_propagation_arg.baz.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/copy_propagation_arg.baz.DestinationPropagation.diff @@ -15,7 +15,7 @@ + nop; // scope 0 at $DIR/copy_propagation_arg.rs:23:9: 23:10 + nop; // scope 0 at $DIR/copy_propagation_arg.rs:23:5: 23:10 + nop; // scope 0 at $DIR/copy_propagation_arg.rs:23:9: 23:10 - _0 = const (); // scope 0 at $DIR/copy_propagation_arg.rs:21:20: 24:2 + nop; // scope 0 at $DIR/copy_propagation_arg.rs:21:20: 24:2 return; // scope 0 at $DIR/copy_propagation_arg.rs:24:2: 24:2 } } diff --git a/src/test/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff index 2dea530db3d20..f955a9c043f76 100644 --- a/src/test/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff @@ -25,7 +25,7 @@ - StorageDead(_2); // scope 0 at $DIR/copy_propagation_arg.rs:11:16: 11:17 + nop; // scope 0 at $DIR/copy_propagation_arg.rs:11:5: 11:17 + nop; // scope 0 at $DIR/copy_propagation_arg.rs:11:16: 11:17 - _0 = const (); // scope 0 at $DIR/copy_propagation_arg.rs:9:19: 12:2 + nop; // scope 0 at $DIR/copy_propagation_arg.rs:9:19: 12:2 return; // scope 0 at $DIR/copy_propagation_arg.rs:12:2: 12:2 } } diff --git a/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff index 621a747e131dd..d03f536ec9e53 100644 --- a/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff @@ -58,7 +58,7 @@ + _6 = _4; // scope 3 at $DIR/cycle.rs:14:10: 14:11 StorageDead(_6); // scope 3 at $DIR/cycle.rs:14:11: 14:12 StorageDead(_5); // scope 3 at $DIR/cycle.rs:14:12: 14:13 - _0 = const (); // scope 0 at $DIR/cycle.rs:8:11: 15:2 + nop; // scope 0 at $DIR/cycle.rs:8:11: 15:2 - StorageDead(_3); // scope 2 at $DIR/cycle.rs:15:1: 15:2 - StorageDead(_2); // scope 1 at $DIR/cycle.rs:15:1: 15:2 - StorageDead(_1); // scope 0 at $DIR/cycle.rs:15:1: 15:2 diff --git a/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff index a3368dcfcc6c7..0050ed0d1c63a 100644 --- a/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff @@ -33,7 +33,7 @@ _4 = (_1.0: u32); // scope 2 at $DIR/union.rs:15:19: 15:24 StorageDead(_4); // scope 1 at $DIR/union.rs:15:26: 15:27 StorageDead(_3); // scope 1 at $DIR/union.rs:15:27: 15:28 - _0 = const (); // scope 0 at $DIR/union.rs:8:11: 16:2 + nop; // scope 0 at $DIR/union.rs:8:11: 16:2 StorageDead(_1); // scope 0 at $DIR/union.rs:16:1: 16:2 return; // scope 0 at $DIR/union.rs:16:2: 16:2 } diff --git a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff index 1b292cdd796e5..59bf5a185e077 100644 --- a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff +++ b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff @@ -98,7 +98,7 @@ - bb2: { + StorageDead(_35); // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:25: 27:27 StorageLive(_33); // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:25: 27:27 - ((_0 as Err).0: ()) = const (); // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:21: 27:28 +- nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:21: 27:28 discriminant(_0) = 1; // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:21: 27:28 StorageDead(_33); // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:27: 27:28 - StorageDead(_3); // scope 0 at $DIR/early_otherwise_branch_68867.rs:28:6: 28:7 diff --git a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff index d20ee78459103..2d320786ea920 100644 --- a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff @@ -84,7 +84,7 @@ - bb2: { + StorageDead(_35); // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:25: 27:27 StorageLive(_33); // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:25: 27:27 - ((_0 as Err).0: ()) = const (); // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:21: 27:28 +- nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:21: 27:28 discriminant(_0) = 1; // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:21: 27:28 StorageDead(_33); // scope 0 at $DIR/early_otherwise_branch_68867.rs:27:27: 27:28 StorageDead(_3); // scope 0 at $DIR/early_otherwise_branch_68867.rs:28:6: 28:7 diff --git a/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir b/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir index e5ce03a453ba1..d62f78eaa322b 100644 --- a/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir +++ b/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir @@ -28,7 +28,6 @@ fn main() -> () { StorageLive(_5); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 _5 = move (_3.0: ()); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 StorageLive(_6); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 - _6 = const (); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 StorageDead(_6); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 StorageDead(_5); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 StorageDead(_4); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:6:9: 6:10 diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff index bd24522271b93..bc142de794ba0 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff @@ -58,7 +58,7 @@ } bb1: { - _0 = const (); // scope 0 at $DIR/issue-73223.rs:4:17: 4:23 + nop; // scope 0 at $DIR/issue-73223.rs:4:17: 4:23 StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 @@ -146,13 +146,13 @@ } bb4: { - _8 = const (); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + nop; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 + nop; // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 StorageDead(_6); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff index bd24522271b93..bc142de794ba0 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff @@ -58,7 +58,7 @@ } bb1: { - _0 = const (); // scope 0 at $DIR/issue-73223.rs:4:17: 4:23 + nop; // scope 0 at $DIR/issue-73223.rs:4:17: 4:23 StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 @@ -146,13 +146,13 @@ } bb4: { - _8 = const (); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + nop; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 + nop; // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 StorageDead(_6); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 diff --git a/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff b/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff index 7913ad260e893..1fa324c33d2e3 100644 --- a/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff @@ -107,7 +107,7 @@ StorageDead(_14); // scope 1 at $DIR/issue_76432.rs:9:84: 9:85 StorageDead(_13); // scope 1 at $DIR/issue_76432.rs:9:84: 9:85 StorageDead(_9); // scope 1 at $DIR/issue_76432.rs:11:6: 11:7 - _0 = const (); // scope 0 at $DIR/issue_76432.rs:6:44: 12:2 + nop; // scope 0 at $DIR/issue_76432.rs:6:44: 12:2 StorageDead(_5); // scope 0 at $DIR/issue_76432.rs:12:1: 12:2 StorageDead(_2); // scope 0 at $DIR/issue_76432.rs:12:1: 12:2 return; // scope 0 at $DIR/issue_76432.rs:12:2: 12:2 diff --git a/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.32bit.diff b/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.32bit.diff index 9f0db1db1b28e..6ee8e6b774832 100644 --- a/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.32bit.diff +++ b/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.32bit.diff @@ -5,25 +5,22 @@ debug bar => _1; // in scope 0 at $DIR/matches_reduce_branches.rs:7:8: 7:11 let mut _0: (); // return place in scope 0 at $DIR/matches_reduce_branches.rs:7:25: 7:25 let mut _2: isize; // in scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 -+ let mut _3: isize; // in scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 bb0: { _2 = discriminant(_1); // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 -- switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 -- } -- -- bb1: { -- goto -> bb3; // scope 0 at $DIR/matches_reduce_branches.rs:8:5: 10:6 -- } -- -- bb2: { -- goto -> bb3; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL -- } -- -- bb3: { -+ StorageLive(_3); // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 -+ _3 = move _2; // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 -+ StorageDead(_3); // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 + switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 + } + + bb1: { + _0 = const (); // scope 0 at $DIR/matches_reduce_branches.rs:10:6: 10:6 + goto -> bb3; // scope 0 at $DIR/matches_reduce_branches.rs:8:5: 10:6 + } + + bb2: { + goto -> bb3; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } + + bb3: { return; // scope 0 at $DIR/matches_reduce_branches.rs:11:2: 11:2 } } diff --git a/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.64bit.diff b/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.64bit.diff index 9f0db1db1b28e..6ee8e6b774832 100644 --- a/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.64bit.diff +++ b/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.64bit.diff @@ -5,25 +5,22 @@ debug bar => _1; // in scope 0 at $DIR/matches_reduce_branches.rs:7:8: 7:11 let mut _0: (); // return place in scope 0 at $DIR/matches_reduce_branches.rs:7:25: 7:25 let mut _2: isize; // in scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 -+ let mut _3: isize; // in scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 bb0: { _2 = discriminant(_1); // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 -- switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 -- } -- -- bb1: { -- goto -> bb3; // scope 0 at $DIR/matches_reduce_branches.rs:8:5: 10:6 -- } -- -- bb2: { -- goto -> bb3; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL -- } -- -- bb3: { -+ StorageLive(_3); // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 -+ _3 = move _2; // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 -+ StorageDead(_3); // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 + switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 + } + + bb1: { + _0 = const (); // scope 0 at $DIR/matches_reduce_branches.rs:10:6: 10:6 + goto -> bb3; // scope 0 at $DIR/matches_reduce_branches.rs:8:5: 10:6 + } + + bb2: { + goto -> bb3; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } + + bb3: { return; // scope 0 at $DIR/matches_reduce_branches.rs:11:2: 11:2 } } diff --git a/src/test/mir-opt/matches_reduce_branches.foo.PreCodegen.before.32bit.mir b/src/test/mir-opt/matches_reduce_branches.foo.PreCodegen.before.32bit.mir index e3b318c949fc6..ffd274480bd04 100644 --- a/src/test/mir-opt/matches_reduce_branches.foo.PreCodegen.before.32bit.mir +++ b/src/test/mir-opt/matches_reduce_branches.foo.PreCodegen.before.32bit.mir @@ -3,8 +3,10 @@ fn foo(_1: Option<()>) -> () { debug bar => _1; // in scope 0 at $DIR/matches_reduce_branches.rs:7:8: 7:11 let mut _0: (); // return place in scope 0 at $DIR/matches_reduce_branches.rs:7:25: 7:25 + let mut _2: isize; // in scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 bb0: { - return; // scope 0 at $DIR/matches_reduce_branches.rs:11:2: 11:2 + _2 = discriminant(_1); // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 + return; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } } diff --git a/src/test/mir-opt/matches_reduce_branches.foo.PreCodegen.before.64bit.mir b/src/test/mir-opt/matches_reduce_branches.foo.PreCodegen.before.64bit.mir index e3b318c949fc6..ffd274480bd04 100644 --- a/src/test/mir-opt/matches_reduce_branches.foo.PreCodegen.before.64bit.mir +++ b/src/test/mir-opt/matches_reduce_branches.foo.PreCodegen.before.64bit.mir @@ -3,8 +3,10 @@ fn foo(_1: Option<()>) -> () { debug bar => _1; // in scope 0 at $DIR/matches_reduce_branches.rs:7:8: 7:11 let mut _0: (); // return place in scope 0 at $DIR/matches_reduce_branches.rs:7:25: 7:25 + let mut _2: isize; // in scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 bb0: { - return; // scope 0 at $DIR/matches_reduce_branches.rs:11:2: 11:2 + _2 = discriminant(_1); // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 + return; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } } diff --git a/src/test/mir-opt/multiple_return_terminators.test.MultipleReturnTerminators.diff b/src/test/mir-opt/multiple_return_terminators.test.MultipleReturnTerminators.diff index 3dd526cfbc5e2..dbcb8813d5458 100644 --- a/src/test/mir-opt/multiple_return_terminators.test.MultipleReturnTerminators.diff +++ b/src/test/mir-opt/multiple_return_terminators.test.MultipleReturnTerminators.diff @@ -4,24 +4,8 @@ fn test(_1: bool) -> () { debug x => _1; // in scope 0 at $DIR/multiple_return_terminators.rs:4:9: 4:10 let mut _0: (); // return place in scope 0 at $DIR/multiple_return_terminators.rs:4:18: 4:18 - let mut _2: bool; // in scope 0 at $DIR/multiple_return_terminators.rs:5:8: 5:9 bb0: { - StorageLive(_2); // scope 0 at $DIR/multiple_return_terminators.rs:5:8: 5:9 - _2 = _1; // scope 0 at $DIR/multiple_return_terminators.rs:5:8: 5:9 - switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/multiple_return_terminators.rs:5:5: 9:6 - } - - bb1: { - goto -> bb3; // scope 0 at $DIR/multiple_return_terminators.rs:5:5: 9:6 - } - - bb2: { - goto -> bb3; // scope 0 at $DIR/multiple_return_terminators.rs:5:5: 9:6 - } - - bb3: { - StorageDead(_2); // scope 0 at $DIR/multiple_return_terminators.rs:9:5: 9:6 return; // scope 0 at $DIR/multiple_return_terminators.rs:10:2: 10:2 } } diff --git a/src/test/mir-opt/simplify_arm_identity.main.SimplifyArmIdentity.32bit.diff b/src/test/mir-opt/simplify_arm_identity.main.SimplifyArmIdentity.32bit.diff index adcda7fcde0f9..7495b0d407d2c 100644 --- a/src/test/mir-opt/simplify_arm_identity.main.SimplifyArmIdentity.32bit.diff +++ b/src/test/mir-opt/simplify_arm_identity.main.SimplifyArmIdentity.32bit.diff @@ -50,7 +50,7 @@ bb4: { StorageDead(_2); // scope 1 at $DIR/simplify-arm-identity.rs:22:6: 22:7 - _0 = const (); // scope 0 at $DIR/simplify-arm-identity.rs:17:11: 23:2 + nop; // scope 0 at $DIR/simplify-arm-identity.rs:17:11: 23:2 StorageDead(_1); // scope 0 at $DIR/simplify-arm-identity.rs:23:1: 23:2 return; // scope 0 at $DIR/simplify-arm-identity.rs:23:2: 23:2 } diff --git a/src/test/mir-opt/simplify_arm_identity.main.SimplifyArmIdentity.64bit.diff b/src/test/mir-opt/simplify_arm_identity.main.SimplifyArmIdentity.64bit.diff index adcda7fcde0f9..7495b0d407d2c 100644 --- a/src/test/mir-opt/simplify_arm_identity.main.SimplifyArmIdentity.64bit.diff +++ b/src/test/mir-opt/simplify_arm_identity.main.SimplifyArmIdentity.64bit.diff @@ -50,7 +50,7 @@ bb4: { StorageDead(_2); // scope 1 at $DIR/simplify-arm-identity.rs:22:6: 22:7 - _0 = const (); // scope 0 at $DIR/simplify-arm-identity.rs:17:11: 23:2 + nop; // scope 0 at $DIR/simplify-arm-identity.rs:17:11: 23:2 StorageDead(_1); // scope 0 at $DIR/simplify-arm-identity.rs:23:1: 23:2 return; // scope 0 at $DIR/simplify-arm-identity.rs:23:2: 23:2 } diff --git a/src/test/mir-opt/simplify_if.main.SimplifyBranches-after-const-prop.diff b/src/test/mir-opt/simplify_if.main.SimplifyBranches-after-const-prop.diff index 2cd57cb8474ec..b6ce74d72898a 100644 --- a/src/test/mir-opt/simplify_if.main.SimplifyBranches-after-const-prop.diff +++ b/src/test/mir-opt/simplify_if.main.SimplifyBranches-after-const-prop.diff @@ -22,13 +22,13 @@ } bb2: { - _0 = const (); // scope 0 at $DIR/simplify_if.rs:8:6: 8:6 + nop; // scope 0 at $DIR/simplify_if.rs:8:6: 8:6 goto -> bb4; // scope 0 at $DIR/simplify_if.rs:6:5: 8:6 } bb3: { StorageDead(_2); // scope 0 at $DIR/simplify_if.rs:7:15: 7:16 - _0 = const (); // scope 0 at $DIR/simplify_if.rs:6:14: 8:6 + nop; // scope 0 at $DIR/simplify_if.rs:6:14: 8:6 goto -> bb4; // scope 0 at $DIR/simplify_if.rs:6:5: 8:6 } diff --git a/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff index ff9e2671adc7b..2995d1e86e3bf 100644 --- a/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff @@ -25,7 +25,6 @@ - StorageDead(_3); // scope 1 at $DIR/simplify-locals.rs:16:25: 16:26 - StorageDead(_4); // scope 1 at $DIR/simplify-locals.rs:16:26: 16:27 - StorageDead(_2); // scope 1 at $DIR/simplify-locals.rs:16:26: 16:27 -- _0 = const (); // scope 0 at $DIR/simplify-locals.rs:13:8: 17:2 StorageDead(_1); // scope 0 at $DIR/simplify-locals.rs:17:1: 17:2 return; // scope 0 at $DIR/simplify-locals.rs:17:2: 17:2 } diff --git a/src/test/mir-opt/simplify_locals.d1.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.d1.SimplifyLocals.diff index caa2a17700bcc..97cbf2acf06ce 100644 --- a/src/test/mir-opt/simplify_locals.d1.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.d1.SimplifyLocals.diff @@ -11,7 +11,6 @@ - StorageLive(_1); // scope 0 at $DIR/simplify-locals.rs:22:13: 22:17 - discriminant(_1) = 0; // scope 0 at $DIR/simplify-locals.rs:22:13: 22:17 - StorageDead(_1); // scope 0 at $DIR/simplify-locals.rs:22:17: 22:18 -- _0 = const (); // scope 0 at $DIR/simplify-locals.rs:20:9: 23:2 return; // scope 0 at $DIR/simplify-locals.rs:23:2: 23:2 } } diff --git a/src/test/mir-opt/simplify_locals.d2.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.d2.SimplifyLocals.diff index 80496d9a42ab3..1448001dd415c 100644 --- a/src/test/mir-opt/simplify_locals.d2.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.d2.SimplifyLocals.diff @@ -31,7 +31,6 @@ - // + literal: Const { ty: E, val: Value(Scalar(0x01)) } - StorageDead(_1); // scope 0 at $DIR/simplify-locals.rs:28:25: 28:26 - StorageDead(_2); // scope 0 at $DIR/simplify-locals.rs:28:26: 28:27 -- _0 = const (); // scope 0 at $DIR/simplify-locals.rs:26:9: 29:2 return; // scope 0 at $DIR/simplify-locals.rs:29:2: 29:2 } } diff --git a/src/test/mir-opt/simplify_locals.r.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.r.SimplifyLocals.diff index 7d36e1a992855..cf5785438be87 100644 --- a/src/test/mir-opt/simplify_locals.r.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.r.SimplifyLocals.diff @@ -23,7 +23,6 @@ - StorageLive(_3); // scope 2 at $DIR/simplify-locals.rs:36:13: 36:19 - _3 = &mut _1; // scope 2 at $DIR/simplify-locals.rs:36:13: 36:19 - StorageDead(_3); // scope 2 at $DIR/simplify-locals.rs:36:19: 36:20 -- _0 = const (); // scope 0 at $DIR/simplify-locals.rs:32:8: 37:2 StorageDead(_1); // scope 0 at $DIR/simplify-locals.rs:37:1: 37:2 return; // scope 0 at $DIR/simplify-locals.rs:37:2: 37:2 } diff --git a/src/test/mir-opt/simplify_locals.t1.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.t1.SimplifyLocals.diff index 89275418d68f0..54b167bc68e11 100644 --- a/src/test/mir-opt/simplify_locals.t1.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.t1.SimplifyLocals.diff @@ -15,7 +15,6 @@ - _1 = (*_2); // scope 1 at $DIR/simplify-locals.rs:44:14: 44:15 - StorageDead(_2); // scope 0 at $DIR/simplify-locals.rs:44:17: 44:18 - StorageDead(_1); // scope 0 at $DIR/simplify-locals.rs:44:17: 44:18 -- _0 = const (); // scope 0 at $DIR/simplify-locals.rs:42:9: 45:2 return; // scope 0 at $DIR/simplify-locals.rs:45:2: 45:2 } } diff --git a/src/test/mir-opt/simplify_locals.t2.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.t2.SimplifyLocals.diff index b2344c871e423..06216efcec04e 100644 --- a/src/test/mir-opt/simplify_locals.t2.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.t2.SimplifyLocals.diff @@ -15,7 +15,6 @@ - _1 = &mut (*_2); // scope 1 at $DIR/simplify-locals.rs:50:14: 50:20 - StorageDead(_2); // scope 0 at $DIR/simplify-locals.rs:50:22: 50:23 - StorageDead(_1); // scope 0 at $DIR/simplify-locals.rs:50:22: 50:23 -- _0 = const (); // scope 0 at $DIR/simplify-locals.rs:48:9: 51:2 return; // scope 0 at $DIR/simplify-locals.rs:51:2: 51:2 } } diff --git a/src/test/mir-opt/simplify_locals.t3.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.t3.SimplifyLocals.diff index 95982f0a9cffe..ee9d2934afd40 100644 --- a/src/test/mir-opt/simplify_locals.t3.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.t3.SimplifyLocals.diff @@ -19,7 +19,6 @@ - StorageDead(_3); // scope 0 at $DIR/simplify-locals.rs:56:23: 56:24 - StorageDead(_2); // scope 0 at $DIR/simplify-locals.rs:56:23: 56:24 - StorageDead(_1); // scope 0 at $DIR/simplify-locals.rs:56:23: 56:24 -- _0 = const (); // scope 0 at $DIR/simplify-locals.rs:54:9: 57:2 return; // scope 0 at $DIR/simplify-locals.rs:57:2: 57:2 } } diff --git a/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff index 69da1c7be8842..8b6e38843a862 100644 --- a/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff @@ -9,8 +9,8 @@ let mut _4: isize; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26 let mut _5: isize; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20 let _6: u8; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19 - let mut _7: bool; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20 - let mut _8: u8; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13 +- let mut _7: bool; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20 +- let mut _8: u8; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13 scope 1 { debug a => _6; // in scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19 } @@ -26,51 +26,32 @@ StorageDead(_3); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:68: 4:69 StorageDead(_2); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:68: 4:69 _5 = discriminant((_1.0: std::option::Option)); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20 - switchInt(move _5) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20 + switchInt(move _5) -> [1_isize: bb1, otherwise: bb3]; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20 } bb1: { -- _0 = const (); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:8:6: 8:6 - goto -> bb7; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6 - } - - bb2: { _4 = discriminant((_1.1: std::option::Option)); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26 - switchInt(move _4) -> [0_isize: bb3, otherwise: bb1]; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26 + switchInt(move _4) -> [0_isize: bb2, otherwise: bb3]; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26 } - bb3: { + bb2: { StorageLive(_6); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19 _6 = (((_1.0: std::option::Option) as Some).0: u8); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19 - StorageLive(_7); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20 - StorageLive(_8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13 - _8 = _6; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13 - _7 = Gt(move _8, const 42_u8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20 - StorageDead(_8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:19: 5:20 - switchInt(move _7) -> [false: bb5, otherwise: bb4]; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10 - } - - bb4: { -- _0 = const (); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:21: 7:10 - goto -> bb6; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10 - } - - bb5: { -- _0 = const (); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:7:10: 7:10 - goto -> bb6; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10 - } - - bb6: { - StorageDead(_7); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:7:9: 7:10 +- StorageLive(_7); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20 +- StorageLive(_8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13 +- _8 = _6; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13 +- _7 = Gt(move _8, const 42_u8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20 +- StorageDead(_8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:19: 5:20 +- StorageDead(_7); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:7:9: 7:10 StorageDead(_6); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:8:5: 8:6 - goto -> bb7; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6 + goto -> bb3; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6 } - bb7: { - drop(_1) -> bb8; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:1: 9:2 + bb3: { + drop(_1) -> bb4; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:1: 9:2 } - bb8: { + bb4: { StorageDead(_1); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:1: 9:2 return; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:2: 9:2 } diff --git a/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff index 8d6d531bd34e0..a698d8abcdb5a 100644 --- a/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff @@ -23,8 +23,6 @@ - StorageLive(_1); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28 - StorageLive(_2); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23 - StorageLive(_3); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27 -- (_1.0: ()) = const (); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28 -- (_1.1: ()) = const (); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28 - StorageDead(_3); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:27: 13:28 - StorageDead(_2); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:27: 13:28 - StorageDead(_1); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:28: 13:29 @@ -32,8 +30,6 @@ - StorageLive(_5); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21 - StorageLive(_6); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16 - StorageLive(_7); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20 -- (_5.0: ()) = const (); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21 -- (_5.1: ()) = const (); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21 - StorageDead(_7); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:20: 14:21 - StorageDead(_6); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:20: 14:21 - _4 = use_zst(const ((), ())) -> bb1; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22 @@ -71,7 +67,6 @@ - StorageDead(_9); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:34: 16:35 - StorageDead(_11); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:35: 16:36 - StorageDead(_8); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:35: 16:36 -- _0 = const (); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:12:11: 17:2 + StorageDead(_2); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:35: 16:36 return; // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:17:2: 17:2 } diff --git a/src/test/mir-opt/simplify_match.main.ConstProp.diff b/src/test/mir-opt/simplify_match.main.ConstProp.diff index 0fdc364514b4b..3f5efcffc1995 100644 --- a/src/test/mir-opt/simplify_match.main.ConstProp.diff +++ b/src/test/mir-opt/simplify_match.main.ConstProp.diff @@ -21,7 +21,7 @@ } bb1: { - _0 = const (); // scope 0 at $DIR/simplify_match.rs:8:18: 8:20 + nop; // scope 0 at $DIR/simplify_match.rs:8:18: 8:20 goto -> bb3; // scope 0 at $DIR/simplify_match.rs:6:5: 9:6 } diff --git a/src/test/mir-opt/tls_access.main.SimplifyCfg-final.after.mir b/src/test/mir-opt/tls_access.main.SimplifyCfg-final.after.mir index 06161373be284..78ddabd0d31fe 100644 --- a/src/test/mir-opt/tls_access.main.SimplifyCfg-final.after.mir +++ b/src/test/mir-opt/tls_access.main.SimplifyCfg-final.after.mir @@ -20,7 +20,6 @@ fn main() -> () { _3 = &/*tls*/ mut FOO; // scope 2 at $DIR/tls-access.rs:9:9: 9:12 (*_3) = const 42_u8; // scope 2 at $DIR/tls-access.rs:9:9: 9:17 StorageDead(_3); // scope 2 at $DIR/tls-access.rs:9:17: 9:18 - _0 = const (); // scope 1 at $DIR/tls-access.rs:7:5: 10:6 StorageDead(_2); // scope 1 at $DIR/tls-access.rs:10:5: 10:6 StorageDead(_1); // scope 1 at $DIR/tls-access.rs:10:5: 10:6 return; // scope 0 at $DIR/tls-access.rs:11:2: 11:2 diff --git a/src/test/mir-opt/while_let_loops.change_loop_body.ConstProp.32bit.diff b/src/test/mir-opt/while_let_loops.change_loop_body.ConstProp.32bit.diff index 2d53fefca5590..de8a29ea25fcd 100644 --- a/src/test/mir-opt/while_let_loops.change_loop_body.ConstProp.32bit.diff +++ b/src/test/mir-opt/while_let_loops.change_loop_body.ConstProp.32bit.diff @@ -25,7 +25,7 @@ } bb1: { - _0 = const (); // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6 + nop; // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6 goto -> bb4; // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6 } @@ -35,7 +35,7 @@ bb3: { _1 = const 1_i32; // scope 1 at $DIR/while_let_loops.rs:8:9: 8:15 - _0 = const (); // scope 1 at $DIR/while_let_loops.rs:9:9: 9:14 + nop; // scope 1 at $DIR/while_let_loops.rs:9:9: 9:14 goto -> bb4; // scope 1 at $DIR/while_let_loops.rs:9:9: 9:14 } diff --git a/src/test/mir-opt/while_let_loops.change_loop_body.ConstProp.64bit.diff b/src/test/mir-opt/while_let_loops.change_loop_body.ConstProp.64bit.diff index 2d53fefca5590..de8a29ea25fcd 100644 --- a/src/test/mir-opt/while_let_loops.change_loop_body.ConstProp.64bit.diff +++ b/src/test/mir-opt/while_let_loops.change_loop_body.ConstProp.64bit.diff @@ -25,7 +25,7 @@ } bb1: { - _0 = const (); // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6 + nop; // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6 goto -> bb4; // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6 } @@ -35,7 +35,7 @@ bb3: { _1 = const 1_i32; // scope 1 at $DIR/while_let_loops.rs:8:9: 8:15 - _0 = const (); // scope 1 at $DIR/while_let_loops.rs:9:9: 9:14 + nop; // scope 1 at $DIR/while_let_loops.rs:9:9: 9:14 goto -> bb4; // scope 1 at $DIR/while_let_loops.rs:9:9: 9:14 } diff --git a/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir b/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir index eb3ab1c31e36c..b91aae054de9d 100644 --- a/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir +++ b/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir @@ -20,40 +20,36 @@ fn while_loop(_1: bool) -> () { bb1: { StorageDead(_3); // scope 0 at $DIR/while-storage.rs:10:21: 10:22 - switchInt(_2) -> [false: bb2, otherwise: bb3]; // scope 0 at $DIR/while-storage.rs:10:5: 14:6 + switchInt(_2) -> [false: bb6, otherwise: bb2]; // scope 0 at $DIR/while-storage.rs:10:5: 14:6 } bb2: { - goto -> bb7; // scope 0 at $DIR/while-storage.rs:10:5: 14:6 - } - - bb3: { StorageLive(_4); // scope 0 at $DIR/while-storage.rs:11:12: 11:23 StorageLive(_5); // scope 0 at $DIR/while-storage.rs:11:21: 11:22 _5 = _1; // scope 0 at $DIR/while-storage.rs:11:21: 11:22 - _4 = get_bool(move _5) -> bb4; // scope 0 at $DIR/while-storage.rs:11:12: 11:23 + _4 = get_bool(move _5) -> bb3; // scope 0 at $DIR/while-storage.rs:11:12: 11:23 // mir::Constant // + span: $DIR/while-storage.rs:11:12: 11:20 // + literal: Const { ty: fn(bool) -> bool {get_bool}, val: Value(Scalar()) } } - bb4: { + bb3: { StorageDead(_5); // scope 0 at $DIR/while-storage.rs:11:22: 11:23 - switchInt(move _4) -> [false: bb6, otherwise: bb5]; // scope 0 at $DIR/while-storage.rs:11:9: 13:10 + switchInt(move _4) -> [false: bb5, otherwise: bb4]; // scope 0 at $DIR/while-storage.rs:11:9: 13:10 } - bb5: { + bb4: { StorageDead(_4); // scope 0 at $DIR/while-storage.rs:13:9: 13:10 - goto -> bb7; // scope 0 at $DIR/while-storage.rs:1:1: 1:1 + goto -> bb6; // scope 0 at $DIR/while-storage.rs:1:1: 1:1 } - bb6: { + bb5: { StorageDead(_4); // scope 0 at $DIR/while-storage.rs:13:9: 13:10 StorageDead(_2); // scope 0 at $DIR/while-storage.rs:14:5: 14:6 goto -> bb0; // scope 0 at $DIR/while-storage.rs:10:5: 14:6 } - bb7: { + bb6: { StorageDead(_2); // scope 0 at $DIR/while-storage.rs:14:5: 14:6 return; // scope 0 at $DIR/while-storage.rs:15:2: 15:2 } diff --git a/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr b/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr index 7f197a238e5a0..be55890c08c88 100644 --- a/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr +++ b/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr @@ -1,7 +1,7 @@ -error[E0391]: cycle detected when computing layout of `S` +error[E0391]: cycle detected when computing layout of `std::option::Option` | - = note: ...which requires computing layout of `std::option::Option`... - = note: ...which again requires computing layout of `S`, completing the cycle + = note: ...which requires computing layout of `S`... + = note: ...which again requires computing layout of `std::option::Option`, completing the cycle note: cycle used when optimizing MIR for `main` --> $DIR/issue-26548-recursion-via-normalize.rs:15:1 | From bca761dc5d6d13fadc7a2f3c222ebdc86b3da4d3 Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Tue, 16 Mar 2021 21:30:37 -0400 Subject: [PATCH 4/9] move to separate pass, cache layouts --- .../rustc_mir/src/transform/instcombine.rs | 27 +--------- compiler/rustc_mir/src/transform/mod.rs | 2 + .../rustc_mir/src/transform/remove_zsts.rs | 49 +++++++++++++++++++ 3 files changed, 52 insertions(+), 26 deletions(-) create mode 100644 compiler/rustc_mir/src/transform/remove_zsts.rs diff --git a/compiler/rustc_mir/src/transform/instcombine.rs b/compiler/rustc_mir/src/transform/instcombine.rs index 5ac2ff1fc9a16..bad82fe893eb8 100644 --- a/compiler/rustc_mir/src/transform/instcombine.rs +++ b/compiler/rustc_mir/src/transform/instcombine.rs @@ -12,12 +12,10 @@ pub struct InstCombine; impl<'tcx> MirPass<'tcx> for InstCombine { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { - let param_env = tcx.param_env(body.source.def_id()); let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut(); - let ctx = InstCombineContext { tcx, local_decls, param_env }; + let ctx = InstCombineContext { tcx, local_decls }; for block in basic_blocks.iter_mut() { for statement in block.statements.iter_mut() { - ctx.combine_zst(&statement.source_info, &mut statement.kind); match statement.kind { StatementKind::Assign(box (_place, ref mut rvalue)) => { ctx.combine_bool_cmp(&statement.source_info, rvalue); @@ -34,7 +32,6 @@ impl<'tcx> MirPass<'tcx> for InstCombine { struct InstCombineContext<'tcx, 'a> { tcx: TyCtxt<'tcx>, local_decls: &'a LocalDecls<'tcx>, - param_env: ty::ParamEnv<'tcx>, } impl<'tcx, 'a> InstCombineContext<'tcx, 'a> { @@ -44,28 +41,6 @@ impl<'tcx, 'a> InstCombineContext<'tcx, 'a> { }) } - /// Remove assignments to inhabited ZST places. - fn combine_zst(&self, source_info: &SourceInfo, kind: &mut StatementKind<'tcx>) { - match kind { - StatementKind::Assign(box (place, _)) => { - let place_ty = place.ty(self.local_decls, self.tcx).ty; - if let Ok(layout) = self.tcx.layout_of(self.param_env.and(place_ty)) { - if layout.is_zst() && !layout.abi.is_uninhabited() { - if self.tcx.consider_optimizing(|| { - format!( - "InstCombine ZST - Place: {:?} SourceInfo: {:?}", - place, source_info - ) - }) { - *kind = StatementKind::Nop; - } - } - } - } - _ => {} - } - } - /// Transform boolean comparisons into logical operations. fn combine_bool_cmp(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) { match rvalue { diff --git a/compiler/rustc_mir/src/transform/mod.rs b/compiler/rustc_mir/src/transform/mod.rs index 13546442f6652..c9187fdecedaf 100644 --- a/compiler/rustc_mir/src/transform/mod.rs +++ b/compiler/rustc_mir/src/transform/mod.rs @@ -44,6 +44,7 @@ pub mod promote_consts; pub mod remove_noop_landing_pads; pub mod remove_storage_markers; pub mod remove_unneeded_drops; +pub mod remove_zsts; pub mod required_consts; pub mod rustc_peek; pub mod simplify; @@ -494,6 +495,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { // The main optimizations that we do on MIR. let optimizations: &[&dyn MirPass<'tcx>] = &[ &remove_storage_markers::RemoveStorageMarkers, + &remove_zsts::RemoveZsts, &const_goto::ConstGoto, &remove_unneeded_drops::RemoveUnneededDrops, &match_branches::MatchBranchSimplification, diff --git a/compiler/rustc_mir/src/transform/remove_zsts.rs b/compiler/rustc_mir/src/transform/remove_zsts.rs new file mode 100644 index 0000000000000..838ffe9b596eb --- /dev/null +++ b/compiler/rustc_mir/src/transform/remove_zsts.rs @@ -0,0 +1,49 @@ +//! Removes assignments to ZST places. + +use crate::transform::MirPass; +use rustc_data_structures::fx::FxHashMap; +use rustc_middle::mir::{Body, StatementKind}; +use rustc_middle::ty::TyCtxt; + +pub struct RemoveZsts; + +impl<'tcx> MirPass<'tcx> for RemoveZsts { + fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { + let param_env = tcx.param_env(body.source.def_id()); + + let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut(); + + let mut is_zst_cache = FxHashMap::default(); + + for block in basic_blocks.iter_mut() { + for statement in block.statements.iter_mut() { + match statement.kind { + StatementKind::Assign(box (place, _)) => { + let place_ty = place.ty(local_decls, tcx).ty; + + let is_inhabited_zst = *is_zst_cache.entry(place_ty).or_insert_with(|| { + if let Ok(layout) = tcx.layout_of(param_env.and(place_ty)) { + if layout.is_zst() && !layout.abi.is_uninhabited() { + return true; + } + } + false + }); + + if is_inhabited_zst { + if tcx.consider_optimizing(|| { + format!( + "RemoveZsts - Place: {:?} SourceInfo: {:?}", + place, statement.source_info + ) + }) { + statement.make_nop(); + } + } + } + _ => {} + } + } + } + } +} From b6d5b728b38669233c684dbca8d09f249b429446 Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Tue, 16 Mar 2021 21:32:53 -0400 Subject: [PATCH 5/9] bless tests --- .../cycle.main.DestinationPropagation.diff | 1 - .../union.main.DestinationPropagation.diff | 1 - ...s.foo.MatchBranchSimplification.32bit.diff | 29 ++++++++++--------- ...s.foo.MatchBranchSimplification.64bit.diff | 29 ++++++++++--------- ...e_branches.foo.PreCodegen.before.32bit.mir | 4 +-- ...e_branches.foo.PreCodegen.before.64bit.mir | 4 +-- ...annot_opt_generic.RemoveUnneededDrops.diff | 2 +- ...ed_drops.dont_opt.RemoveUnneededDrops.diff | 2 +- ...nneeded_drops.opt.RemoveUnneededDrops.diff | 2 +- ....opt_generic_copy.RemoveUnneededDrops.diff | 2 +- 10 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff index d03f536ec9e53..32d7e301c1a1d 100644 --- a/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff @@ -58,7 +58,6 @@ + _6 = _4; // scope 3 at $DIR/cycle.rs:14:10: 14:11 StorageDead(_6); // scope 3 at $DIR/cycle.rs:14:11: 14:12 StorageDead(_5); // scope 3 at $DIR/cycle.rs:14:12: 14:13 - nop; // scope 0 at $DIR/cycle.rs:8:11: 15:2 - StorageDead(_3); // scope 2 at $DIR/cycle.rs:15:1: 15:2 - StorageDead(_2); // scope 1 at $DIR/cycle.rs:15:1: 15:2 - StorageDead(_1); // scope 0 at $DIR/cycle.rs:15:1: 15:2 diff --git a/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff index 0050ed0d1c63a..9be0738ea96ee 100644 --- a/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff @@ -33,7 +33,6 @@ _4 = (_1.0: u32); // scope 2 at $DIR/union.rs:15:19: 15:24 StorageDead(_4); // scope 1 at $DIR/union.rs:15:26: 15:27 StorageDead(_3); // scope 1 at $DIR/union.rs:15:27: 15:28 - nop; // scope 0 at $DIR/union.rs:8:11: 16:2 StorageDead(_1); // scope 0 at $DIR/union.rs:16:1: 16:2 return; // scope 0 at $DIR/union.rs:16:2: 16:2 } diff --git a/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.32bit.diff b/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.32bit.diff index 6ee8e6b774832..96b03477d0108 100644 --- a/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.32bit.diff +++ b/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.32bit.diff @@ -5,22 +5,25 @@ debug bar => _1; // in scope 0 at $DIR/matches_reduce_branches.rs:7:8: 7:11 let mut _0: (); // return place in scope 0 at $DIR/matches_reduce_branches.rs:7:25: 7:25 let mut _2: isize; // in scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 ++ let mut _3: isize; // in scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 bb0: { _2 = discriminant(_1); // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 - switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 - } - - bb1: { - _0 = const (); // scope 0 at $DIR/matches_reduce_branches.rs:10:6: 10:6 - goto -> bb3; // scope 0 at $DIR/matches_reduce_branches.rs:8:5: 10:6 - } - - bb2: { - goto -> bb3; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - - bb3: { +- switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 +- } +- +- bb1: { +- goto -> bb3; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- } +- +- bb2: { +- goto -> bb3; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- } +- +- bb3: { ++ StorageLive(_3); // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 ++ _3 = move _2; // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 ++ StorageDead(_3); // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 return; // scope 0 at $DIR/matches_reduce_branches.rs:11:2: 11:2 } } diff --git a/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.64bit.diff b/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.64bit.diff index 6ee8e6b774832..96b03477d0108 100644 --- a/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.64bit.diff +++ b/src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.64bit.diff @@ -5,22 +5,25 @@ debug bar => _1; // in scope 0 at $DIR/matches_reduce_branches.rs:7:8: 7:11 let mut _0: (); // return place in scope 0 at $DIR/matches_reduce_branches.rs:7:25: 7:25 let mut _2: isize; // in scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 ++ let mut _3: isize; // in scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 bb0: { _2 = discriminant(_1); // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 - switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 - } - - bb1: { - _0 = const (); // scope 0 at $DIR/matches_reduce_branches.rs:10:6: 10:6 - goto -> bb3; // scope 0 at $DIR/matches_reduce_branches.rs:8:5: 10:6 - } - - bb2: { - goto -> bb3; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - - bb3: { +- switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 +- } +- +- bb1: { +- goto -> bb3; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- } +- +- bb2: { +- goto -> bb3; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- } +- +- bb3: { ++ StorageLive(_3); // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 ++ _3 = move _2; // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 ++ StorageDead(_3); // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 return; // scope 0 at $DIR/matches_reduce_branches.rs:11:2: 11:2 } } diff --git a/src/test/mir-opt/matches_reduce_branches.foo.PreCodegen.before.32bit.mir b/src/test/mir-opt/matches_reduce_branches.foo.PreCodegen.before.32bit.mir index ffd274480bd04..e3b318c949fc6 100644 --- a/src/test/mir-opt/matches_reduce_branches.foo.PreCodegen.before.32bit.mir +++ b/src/test/mir-opt/matches_reduce_branches.foo.PreCodegen.before.32bit.mir @@ -3,10 +3,8 @@ fn foo(_1: Option<()>) -> () { debug bar => _1; // in scope 0 at $DIR/matches_reduce_branches.rs:7:8: 7:11 let mut _0: (); // return place in scope 0 at $DIR/matches_reduce_branches.rs:7:25: 7:25 - let mut _2: isize; // in scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 bb0: { - _2 = discriminant(_1); // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 - return; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + return; // scope 0 at $DIR/matches_reduce_branches.rs:11:2: 11:2 } } diff --git a/src/test/mir-opt/matches_reduce_branches.foo.PreCodegen.before.64bit.mir b/src/test/mir-opt/matches_reduce_branches.foo.PreCodegen.before.64bit.mir index ffd274480bd04..e3b318c949fc6 100644 --- a/src/test/mir-opt/matches_reduce_branches.foo.PreCodegen.before.64bit.mir +++ b/src/test/mir-opt/matches_reduce_branches.foo.PreCodegen.before.64bit.mir @@ -3,10 +3,8 @@ fn foo(_1: Option<()>) -> () { debug bar => _1; // in scope 0 at $DIR/matches_reduce_branches.rs:7:8: 7:11 let mut _0: (); // return place in scope 0 at $DIR/matches_reduce_branches.rs:7:25: 7:25 - let mut _2: isize; // in scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 bb0: { - _2 = discriminant(_1); // scope 0 at $DIR/matches_reduce_branches.rs:8:22: 8:26 - return; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + return; // scope 0 at $DIR/matches_reduce_branches.rs:11:2: 11:2 } } diff --git a/src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff index 2fc64fa8f524d..546a95a86fa66 100644 --- a/src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff @@ -24,7 +24,7 @@ bb2: { StorageDead(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:21:11: 21:12 StorageDead(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:21:12: 21:13 - _0 = const (); // scope 0 at $DIR/remove_unneeded_drops.rs:20:32: 22:2 + nop; // scope 0 at $DIR/remove_unneeded_drops.rs:20:32: 22:2 return; // scope 0 at $DIR/remove_unneeded_drops.rs:22:2: 22:2 } } diff --git a/src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff index 18fdac1bc0044..b42813447b151 100644 --- a/src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff @@ -24,7 +24,7 @@ bb2: { StorageDead(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:9:11: 9:12 StorageDead(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:9:12: 9:13 - _0 = const (); // scope 0 at $DIR/remove_unneeded_drops.rs:8:27: 10:2 + nop; // scope 0 at $DIR/remove_unneeded_drops.rs:8:27: 10:2 return; // scope 0 at $DIR/remove_unneeded_drops.rs:10:2: 10:2 } } diff --git a/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff index 1eb3d736765ed..ee52254f08b8e 100644 --- a/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff @@ -20,7 +20,7 @@ - bb1: { StorageDead(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:4:11: 4:12 StorageDead(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:4:12: 4:13 - _0 = const (); // scope 0 at $DIR/remove_unneeded_drops.rs:3:17: 5:2 +- nop; // scope 0 at $DIR/remove_unneeded_drops.rs:3:17: 5:2 return; // scope 0 at $DIR/remove_unneeded_drops.rs:5:2: 5:2 } } diff --git a/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff index 9b8a50e85416b..21bc90b0eb703 100644 --- a/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff @@ -20,7 +20,7 @@ - bb1: { StorageDead(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:14:11: 14:12 StorageDead(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:14:12: 14:13 - _0 = const (); // scope 0 at $DIR/remove_unneeded_drops.rs:13:36: 15:2 +- nop; // scope 0 at $DIR/remove_unneeded_drops.rs:13:36: 15:2 return; // scope 0 at $DIR/remove_unneeded_drops.rs:15:2: 15:2 } } From 1205e82578bec0ff5fd84dc1a90afa4f8e4e548d Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Wed, 17 Mar 2021 20:24:29 -0400 Subject: [PATCH 6/9] remove unnecessary and ineffective caching --- .../rustc_mir/src/transform/remove_zsts.rs | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/compiler/rustc_mir/src/transform/remove_zsts.rs b/compiler/rustc_mir/src/transform/remove_zsts.rs index 838ffe9b596eb..5b1dcba670437 100644 --- a/compiler/rustc_mir/src/transform/remove_zsts.rs +++ b/compiler/rustc_mir/src/transform/remove_zsts.rs @@ -1,7 +1,6 @@ //! Removes assignments to ZST places. use crate::transform::MirPass; -use rustc_data_structures::fx::FxHashMap; use rustc_middle::mir::{Body, StatementKind}; use rustc_middle::ty::TyCtxt; @@ -10,35 +9,23 @@ pub struct RemoveZsts; impl<'tcx> MirPass<'tcx> for RemoveZsts { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { let param_env = tcx.param_env(body.source.def_id()); - let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut(); - - let mut is_zst_cache = FxHashMap::default(); - for block in basic_blocks.iter_mut() { for statement in block.statements.iter_mut() { match statement.kind { StatementKind::Assign(box (place, _)) => { let place_ty = place.ty(local_decls, tcx).ty; - - let is_inhabited_zst = *is_zst_cache.entry(place_ty).or_insert_with(|| { - if let Ok(layout) = tcx.layout_of(param_env.and(place_ty)) { - if layout.is_zst() && !layout.abi.is_uninhabited() { - return true; + if let Ok(layout) = tcx.layout_of(param_env.and(place_ty)) { + if layout.is_zst() && !layout.abi.is_uninhabited() { + if tcx.consider_optimizing(|| { + format!( + "RemoveZsts - Place: {:?} SourceInfo: {:?}", + place, statement.source_info + ) + }) { + statement.make_nop(); } } - false - }); - - if is_inhabited_zst { - if tcx.consider_optimizing(|| { - format!( - "RemoveZsts - Place: {:?} SourceInfo: {:?}", - place, statement.source_info - ) - }) { - statement.make_nop(); - } } } _ => {} From 93c1380e0bbbc4939df7e25d888755f68aaf64f6 Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Wed, 17 Mar 2021 20:31:00 -0400 Subject: [PATCH 7/9] remove inhabitedness check --- compiler/rustc_mir/src/transform/remove_zsts.rs | 2 +- src/test/ui/consts/const-eval/panic-assoc-never-type.rs | 2 +- src/test/ui/consts/const-eval/panic-assoc-never-type.stderr | 5 ++--- src/test/ui/consts/const-eval/panic-never-type.rs | 2 +- src/test/ui/consts/const-eval/panic-never-type.stderr | 5 ++--- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_mir/src/transform/remove_zsts.rs b/compiler/rustc_mir/src/transform/remove_zsts.rs index 5b1dcba670437..4c9dc43df9b57 100644 --- a/compiler/rustc_mir/src/transform/remove_zsts.rs +++ b/compiler/rustc_mir/src/transform/remove_zsts.rs @@ -16,7 +16,7 @@ impl<'tcx> MirPass<'tcx> for RemoveZsts { StatementKind::Assign(box (place, _)) => { let place_ty = place.ty(local_decls, tcx).ty; if let Ok(layout) = tcx.layout_of(param_env.and(place_ty)) { - if layout.is_zst() && !layout.abi.is_uninhabited() { + if layout.is_zst() { if tcx.consider_optimizing(|| { format!( "RemoveZsts - Place: {:?} SourceInfo: {:?}", diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs index f76440298b3ca..85425324eec04 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs @@ -15,5 +15,5 @@ impl PrintName { fn main() { let _ = PrintName::VOID; - //~^ ERROR erroneous constant used + //~^ ERROR erroneous constant encountered } diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr index 28a3ebede5038..5495a2a0121f7 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -15,12 +15,11 @@ LL | #![warn(const_err)] = note: for more information, see issue #71800 = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: erroneous constant used +error: erroneous constant encountered --> $DIR/panic-assoc-never-type.rs:17:13 | LL | let _ = PrintName::VOID; - | ^^^^^^^^^^^^^^^ referenced constant has errors + | ^^^^^^^^^^^^^^^ error: aborting due to previous error; 1 warning emitted -For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/panic-never-type.rs b/src/test/ui/consts/const-eval/panic-never-type.rs index c5139c575b15f..0283b94f76d73 100644 --- a/src/test/ui/consts/const-eval/panic-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-never-type.rs @@ -11,5 +11,5 @@ const VOID: ! = panic!(); fn main() { let _ = VOID; - //~^ ERROR erroneous constant used + //~^ ERROR erroneous constant encountered } diff --git a/src/test/ui/consts/const-eval/panic-never-type.stderr b/src/test/ui/consts/const-eval/panic-never-type.stderr index 8f67dd6a8ba42..d8f68f530fc94 100644 --- a/src/test/ui/consts/const-eval/panic-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-never-type.stderr @@ -15,12 +15,11 @@ LL | #![warn(const_err)] = note: for more information, see issue #71800 = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: erroneous constant used +error: erroneous constant encountered --> $DIR/panic-never-type.rs:13:13 | LL | let _ = VOID; - | ^^^^ referenced constant has errors + | ^^^^ error: aborting due to previous error; 1 warning emitted -For more information about this error, try `rustc --explain E0080`. From 46fd49cdc366ebf74c1b2bcb3a0e3d22585f267f Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Fri, 19 Mar 2021 22:25:56 -0400 Subject: [PATCH 8/9] avoid calling for types which can't be ZSTs --- .../rustc_mir/src/transform/remove_zsts.rs | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_mir/src/transform/remove_zsts.rs b/compiler/rustc_mir/src/transform/remove_zsts.rs index 4c9dc43df9b57..f039385303045 100644 --- a/compiler/rustc_mir/src/transform/remove_zsts.rs +++ b/compiler/rustc_mir/src/transform/remove_zsts.rs @@ -2,7 +2,7 @@ use crate::transform::MirPass; use rustc_middle::mir::{Body, StatementKind}; -use rustc_middle::ty::TyCtxt; +use rustc_middle::ty::{self, Ty, TyCtxt}; pub struct RemoveZsts; @@ -15,17 +15,23 @@ impl<'tcx> MirPass<'tcx> for RemoveZsts { match statement.kind { StatementKind::Assign(box (place, _)) => { let place_ty = place.ty(local_decls, tcx).ty; - if let Ok(layout) = tcx.layout_of(param_env.and(place_ty)) { - if layout.is_zst() { - if tcx.consider_optimizing(|| { - format!( - "RemoveZsts - Place: {:?} SourceInfo: {:?}", - place, statement.source_info - ) - }) { - statement.make_nop(); - } - } + if !maybe_zst(place_ty) { + continue; + } + let layout = match tcx.layout_of(param_env.and(place_ty)) { + Ok(layout) => layout, + Err(_) => continue, + }; + if !layout.is_zst() { + continue; + } + if tcx.consider_optimizing(|| { + format!( + "RemoveZsts - Place: {:?} SourceInfo: {:?}", + place, statement.source_info + ) + }) { + statement.make_nop(); } } _ => {} @@ -34,3 +40,15 @@ impl<'tcx> MirPass<'tcx> for RemoveZsts { } } } + +/// A cheap, approximate check to avoid unnecessary `layout_of` calls. +fn maybe_zst(ty: Ty<'_>) -> bool { + match ty.kind() { + // maybe ZST (could be more precise) + ty::Adt(..) | ty::Array(..) | ty::Closure(..) | ty::Tuple(..) | ty::Opaque(..) => true, + // definitely ZST + ty::FnDef(..) | ty::Never => true, + // unreachable or can't be ZST + _ => false, + } +} From 6960bc9696b05b15d8d89ece2fef14e6e62a43fc Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Mon, 22 Mar 2021 18:30:56 -0400 Subject: [PATCH 9/9] only run RemoveZsts at mir-opt-level 3 and above --- .../rustc_mir/src/transform/remove_zsts.rs | 3 ++ ...l_flow_simplification.hello.ConstProp.diff | 2 +- ...simplification.hello.PreCodegen.before.mir | 1 + ...annot_opt_generic.RemoveUnneededDrops.diff | 1 + ...ed_drops.dont_opt.RemoveUnneededDrops.diff | 1 + ...nneeded_drops.opt.RemoveUnneededDrops.diff | 1 + ....opt_generic_copy.RemoveUnneededDrops.diff | 1 + ..._locals_fixedpoint.foo.SimplifyLocals.diff | 49 +++++++++++++------ src/test/run-make/const_fn_mir/dump.mir | 1 + .../const-eval/panic-assoc-never-type.rs | 2 +- .../const-eval/panic-assoc-never-type.stderr | 5 +- .../ui/consts/const-eval/panic-never-type.rs | 2 +- .../consts/const-eval/panic-never-type.stderr | 5 +- ...issue-26548-recursion-via-normalize.stderr | 6 +-- 14 files changed, 55 insertions(+), 25 deletions(-) diff --git a/compiler/rustc_mir/src/transform/remove_zsts.rs b/compiler/rustc_mir/src/transform/remove_zsts.rs index f039385303045..144cedf593ede 100644 --- a/compiler/rustc_mir/src/transform/remove_zsts.rs +++ b/compiler/rustc_mir/src/transform/remove_zsts.rs @@ -8,6 +8,9 @@ pub struct RemoveZsts; impl<'tcx> MirPass<'tcx> for RemoveZsts { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { + if tcx.sess.mir_opt_level() < 3 { + return; + } let param_env = tcx.param_env(body.source.def_id()); let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut(); for block in basic_blocks.iter_mut() { diff --git a/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff b/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff index 22042e69f877f..e1f2fbe84434a 100644 --- a/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff +++ b/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff @@ -29,7 +29,7 @@ } bb2: { - nop; // scope 0 at $DIR/control-flow-simplification.rs:14:6: 14:6 + _0 = const (); // scope 0 at $DIR/control-flow-simplification.rs:14:6: 14:6 StorageDead(_1); // scope 0 at $DIR/control-flow-simplification.rs:14:5: 14:6 return; // scope 0 at $DIR/control-flow-simplification.rs:15:2: 15:2 } diff --git a/src/test/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.mir b/src/test/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.mir index 30512d0bbe874..c2f75e5daeeb2 100644 --- a/src/test/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.mir +++ b/src/test/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.mir @@ -4,6 +4,7 @@ fn hello() -> () { let mut _0: (); // return place in scope 0 at $DIR/control-flow-simplification.rs:11:14: 11:14 bb0: { + _0 = const (); // scope 0 at $DIR/control-flow-simplification.rs:14:6: 14:6 return; // scope 0 at $DIR/control-flow-simplification.rs:15:2: 15:2 } } diff --git a/src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff index 546a95a86fa66..8793af5c074d5 100644 --- a/src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff @@ -14,6 +14,7 @@ StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:21:5: 21:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:21:10: 21:11 _3 = move _1; // scope 0 at $DIR/remove_unneeded_drops.rs:21:10: 21:11 + nop; // scope 1 at $DIR/remove_unneeded_drops.rs:21:5: 21:12 drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $DIR/remove_unneeded_drops.rs:21:5: 21:12 } diff --git a/src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff index b42813447b151..2377abdb153ba 100644 --- a/src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff @@ -14,6 +14,7 @@ StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:9:5: 9:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:9:10: 9:11 _3 = move _1; // scope 0 at $DIR/remove_unneeded_drops.rs:9:10: 9:11 + nop; // scope 1 at $DIR/remove_unneeded_drops.rs:9:5: 9:12 drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $DIR/remove_unneeded_drops.rs:9:5: 9:12 } diff --git a/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff index ee52254f08b8e..75bd732e3c03a 100644 --- a/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff @@ -14,6 +14,7 @@ StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:4:5: 4:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:4:10: 4:11 _3 = _1; // scope 0 at $DIR/remove_unneeded_drops.rs:4:10: 4:11 +- nop; // scope 1 at $DIR/remove_unneeded_drops.rs:4:5: 4:12 - drop(_3) -> bb1; // scope 1 at $DIR/remove_unneeded_drops.rs:4:5: 4:12 - } - diff --git a/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff index 21bc90b0eb703..b3da2cfb24c75 100644 --- a/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff @@ -14,6 +14,7 @@ StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:14:5: 14:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:14:10: 14:11 _3 = _1; // scope 0 at $DIR/remove_unneeded_drops.rs:14:10: 14:11 +- nop; // scope 1 at $DIR/remove_unneeded_drops.rs:14:5: 14:12 - drop(_3) -> bb1; // scope 1 at $DIR/remove_unneeded_drops.rs:14:5: 14:12 - } - diff --git a/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff index 8b6e38843a862..70725e5f14f7d 100644 --- a/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff @@ -9,8 +9,8 @@ let mut _4: isize; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26 let mut _5: isize; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20 let _6: u8; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19 -- let mut _7: bool; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20 -- let mut _8: u8; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13 + let mut _7: bool; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20 + let mut _8: u8; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13 scope 1 { debug a => _6; // in scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19 } @@ -26,32 +26,51 @@ StorageDead(_3); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:68: 4:69 StorageDead(_2); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:68: 4:69 _5 = discriminant((_1.0: std::option::Option)); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20 - switchInt(move _5) -> [1_isize: bb1, otherwise: bb3]; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20 + switchInt(move _5) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20 } bb1: { - _4 = discriminant((_1.1: std::option::Option)); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26 - switchInt(move _4) -> [0_isize: bb2, otherwise: bb3]; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26 + _0 = const (); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:8:6: 8:6 + goto -> bb7; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6 } bb2: { + _4 = discriminant((_1.1: std::option::Option)); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26 + switchInt(move _4) -> [0_isize: bb3, otherwise: bb1]; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26 + } + + bb3: { StorageLive(_6); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19 _6 = (((_1.0: std::option::Option) as Some).0: u8); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19 -- StorageLive(_7); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20 -- StorageLive(_8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13 -- _8 = _6; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13 -- _7 = Gt(move _8, const 42_u8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20 -- StorageDead(_8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:19: 5:20 -- StorageDead(_7); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:7:9: 7:10 + StorageLive(_7); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20 + StorageLive(_8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13 + _8 = _6; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13 + _7 = Gt(move _8, const 42_u8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20 + StorageDead(_8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:19: 5:20 + switchInt(move _7) -> [false: bb5, otherwise: bb4]; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10 + } + + bb4: { + _0 = const (); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:21: 7:10 + goto -> bb6; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10 + } + + bb5: { + _0 = const (); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:7:10: 7:10 + goto -> bb6; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10 + } + + bb6: { + StorageDead(_7); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:7:9: 7:10 StorageDead(_6); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:8:5: 8:6 - goto -> bb3; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6 + goto -> bb7; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6 } - bb3: { - drop(_1) -> bb4; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:1: 9:2 + bb7: { + drop(_1) -> bb8; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:1: 9:2 } - bb4: { + bb8: { StorageDead(_1); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:1: 9:2 return; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:2: 9:2 } diff --git a/src/test/run-make/const_fn_mir/dump.mir b/src/test/run-make/const_fn_mir/dump.mir index 724b26300839e..45d018cf305c6 100644 --- a/src/test/run-make/const_fn_mir/dump.mir +++ b/src/test/run-make/const_fn_mir/dump.mir @@ -12,6 +12,7 @@ fn main() -> () { } bb1: { + _0 = const (); // scope 0 at main.rs:8:11: 10:2 return; // scope 0 at main.rs:10:2: 10:2 } } diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs index 85425324eec04..f76440298b3ca 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs @@ -15,5 +15,5 @@ impl PrintName { fn main() { let _ = PrintName::VOID; - //~^ ERROR erroneous constant encountered + //~^ ERROR erroneous constant used } diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr index 5495a2a0121f7..28a3ebede5038 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -15,11 +15,12 @@ LL | #![warn(const_err)] = note: for more information, see issue #71800 = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) -error: erroneous constant encountered +error[E0080]: erroneous constant used --> $DIR/panic-assoc-never-type.rs:17:13 | LL | let _ = PrintName::VOID; - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ referenced constant has errors error: aborting due to previous error; 1 warning emitted +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/panic-never-type.rs b/src/test/ui/consts/const-eval/panic-never-type.rs index 0283b94f76d73..c5139c575b15f 100644 --- a/src/test/ui/consts/const-eval/panic-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-never-type.rs @@ -11,5 +11,5 @@ const VOID: ! = panic!(); fn main() { let _ = VOID; - //~^ ERROR erroneous constant encountered + //~^ ERROR erroneous constant used } diff --git a/src/test/ui/consts/const-eval/panic-never-type.stderr b/src/test/ui/consts/const-eval/panic-never-type.stderr index d8f68f530fc94..8f67dd6a8ba42 100644 --- a/src/test/ui/consts/const-eval/panic-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-never-type.stderr @@ -15,11 +15,12 @@ LL | #![warn(const_err)] = note: for more information, see issue #71800 = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) -error: erroneous constant encountered +error[E0080]: erroneous constant used --> $DIR/panic-never-type.rs:13:13 | LL | let _ = VOID; - | ^^^^ + | ^^^^ referenced constant has errors error: aborting due to previous error; 1 warning emitted +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr b/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr index be55890c08c88..7f197a238e5a0 100644 --- a/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr +++ b/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr @@ -1,7 +1,7 @@ -error[E0391]: cycle detected when computing layout of `std::option::Option` +error[E0391]: cycle detected when computing layout of `S` | - = note: ...which requires computing layout of `S`... - = note: ...which again requires computing layout of `std::option::Option`, completing the cycle + = note: ...which requires computing layout of `std::option::Option`... + = note: ...which again requires computing layout of `S`, completing the cycle note: cycle used when optimizing MIR for `main` --> $DIR/issue-26548-recursion-via-normalize.rs:15:1 |