diff --git a/compiler/rustc_mir/src/transform/copy_propagation.rs b/compiler/rustc_mir/src/transform/copy_propagation.rs new file mode 100644 index 0000000000000..c00ad16e2cf6b --- /dev/null +++ b/compiler/rustc_mir/src/transform/copy_propagation.rs @@ -0,0 +1,242 @@ +//! A intra-block copy propagation pass. +//! +//! Given an assignment `_a = _b` replaces subsequent uses of destination `_a` with source `_b`, as +//! long as neither `a` nor `_b` had been modified in the intervening statements. +//! +//! The implementation processes block statements & terminator in the execution order. For each +//! local it keeps track of a source that defined its current value. When it encounters a copy use +//! of a local, it verifies that source had not been modified since the assignment and replaces the +//! local with the source. +//! +//! To detect modifications, each local has a generation number that is increased after each direct +//! modification. The local generation number is recorded at the time of the assignment and +//! verified before the propagation to ensure that the local remains unchanged since the +//! assignment. +//! +//! Instead of detecting indirect modifications, locals that have their address taken never +//! participate in copy propagation. +//! +//! When moving in-between the blocks, all recorded values are invalidated. To do that in O(1) +//! time, generation numbers have a global component that is increased after each block. + +use crate::transform::MirPass; +use crate::util::ever_borrowed_locals; +use rustc_index::bit_set::BitSet; +use rustc_index::vec::IndexVec; +use rustc_middle::mir::visit::*; +use rustc_middle::mir::*; +use rustc_middle::ty::TyCtxt; + +pub struct CopyPropagation; + +impl<'tcx> MirPass<'tcx> for CopyPropagation { + fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { + copy_move_operands(tcx, body); + propagate_copies(tcx, body); + } +} + +fn propagate_copies(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { + let mut values = LocalValues { + borrowed_locals: ever_borrowed_locals(body), + values: IndexVec::from_elem_n(LocalValue::default(), body.local_decls.len()), + block_generation: 0, + }; + for (block, data) in body.basic_blocks_mut().iter_enumerated_mut() { + for (statement_index, statement) in data.statements.iter_mut().enumerate() { + let location = Location { block, statement_index }; + InvalidateModifiedLocals { values: &mut values }.visit_statement(statement, location); + CopyPropagate { tcx, values: &mut values }.visit_statement(statement, location); + values.record_assignment(statement); + } + + let location = Location { block, statement_index: data.statements.len() }; + InvalidateModifiedLocals { values: &mut values } + .visit_terminator(data.terminator_mut(), location); + CopyPropagate { tcx, values: &mut values } + .visit_terminator(data.terminator_mut(), location); + values.invalidate_all(); + } +} + +struct LocalValues { + /// Locals that have their address taken. They do not participate in copy propagation. + borrowed_locals: BitSet, + /// A symbolic value of each local. + values: IndexVec, + /// Block generation number. Used to invalidate locals' values in-between the blocks in O(1) time. + block_generation: u32, +} + +/// A symbolic value of a local variable. +#[derive(Copy, Clone, Default)] +struct LocalValue { + /// Generation of the current value. + generation: Generation, + /// Generation of the source value at the time of the assignment. + src_generation: Generation, + /// If present the current value of this local is a result of assignment `this = src`. + src: Option, +} + +#[derive(Copy, Clone, Default, PartialEq, Eq)] +struct Generation { + /// Local generation number. Increased after each mutation. + local: u32, + /// Block generation number. Increased in-between the blocks. + block: u32, +} + +impl LocalValues { + /// Invalidates all locals' values. + fn invalidate_all(&mut self) { + assert!(self.block_generation != u32::MAX); + self.block_generation += 1; + } + + /// Invalidates the local's value. + fn invalidate_local(&mut self, local: Local) { + let value = &mut self.values[local]; + assert!(value.generation.local != u32::MAX); + value.generation.local += 1; + value.src_generation = Generation::default(); + value.src = None; + } + + fn record_assignment(&mut self, statement: &Statement<'tcx>) { + let (place, rvalue) = match statement.kind { + StatementKind::Assign(box (ref place, ref rvalue)) => (place, rvalue), + _ => return, + }; + + // Record only complete definitions of local variables. + let dst = match place.as_local() { + Some(dst) => dst, + None => return, + }; + // Reject borrowed destinations. + if self.borrowed_locals.contains(dst) { + return; + } + + let src = match rvalue { + Rvalue::Use(Operand::Copy(src)) => src, + _ => return, + }; + let src = match src.as_local() { + Some(src) => src, + None => return, + }; + // Reject borrowed sources. + if self.borrowed_locals.contains(src) { + return; + } + + // Record `dst = src` assignment. + let src_generation = self.values[src].generation; + let value = &mut self.values[dst]; + value.generation.local += 1; + value.generation.block = self.block_generation; + value.src = Some(src); + value.src_generation = src_generation; + } + + /// Replaces a use of dst with its current value. + fn propagate_local(&mut self, dst: &mut Local) { + let dst_value = &self.values[*dst]; + + let src = match dst_value.src { + Some(src) => src, + None => return, + }; + // Last definition of dst was of the form `dst = src`. + + // Check that dst was defined in this block. + if dst_value.generation.block != self.block_generation { + return; + } + // Check that src still has the same value. + if dst_value.src_generation != self.values[src].generation { + return; + } + + // Propagate + *dst = src; + } +} + +/// Invalidates locals that could be modified during execution of visited MIR. +struct InvalidateModifiedLocals<'a> { + values: &'a mut LocalValues, +} + +impl<'tcx, 'a> Visitor<'tcx> for InvalidateModifiedLocals<'a> { + fn visit_local(&mut self, local: &Local, context: PlaceContext, _location: Location) { + match context { + PlaceContext::MutatingUse(_) + | PlaceContext::NonMutatingUse(NonMutatingUseContext::Move) + | PlaceContext::NonUse(NonUseContext::StorageLive | NonUseContext::StorageDead) => { + self.values.invalidate_local(*local) + } + + PlaceContext::NonMutatingUse(_) + | PlaceContext::NonUse(NonUseContext::AscribeUserTy | NonUseContext::VarDebugInfo) => {} + } + } +} + +/// Replaces copy uses of locals with their current value. +struct CopyPropagate<'tcx, 'a> { + tcx: TyCtxt<'tcx>, + values: &'a mut LocalValues, +} + +impl<'tcx, 'a> MutVisitor<'tcx> for CopyPropagate<'tcx, 'a> { + fn tcx(&self) -> TyCtxt<'tcx> { + self.tcx + } + + fn visit_local(&mut self, local: &mut Local, context: PlaceContext, _location: Location) { + match context { + PlaceContext::NonMutatingUse( + NonMutatingUseContext::Copy | NonMutatingUseContext::Inspect, + ) => self.values.propagate_local(local), + _ => {} + } + } +} + +/// Transforms move operands into copy operands. +fn copy_move_operands<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { + let mut visitor = CopyMoveOperands { tcx }; + for (block, data) in body.basic_blocks_mut().iter_enumerated_mut() { + visitor.visit_basic_block_data(block, data); + } +} + +struct CopyMoveOperands<'tcx> { + tcx: TyCtxt<'tcx>, +} + +impl<'tcx> MutVisitor<'tcx> for CopyMoveOperands<'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { + self.tcx + } + + fn visit_operand(&mut self, operand: &mut Operand<'tcx>, _location: Location) { + if let Operand::Move(place) = operand { + *operand = Operand::Copy(*place); + } + } + + fn visit_terminator(&mut self, terminator: &mut Terminator<'tcx>, location: Location) { + if let TerminatorKind::Call { .. } = terminator.kind { + // When a move operand is used in a call terminator and ABI passes value by a + // reference, the code generation uses provided operand in place instead of making a + // copy. To avoid introducing extra copies, we retain move operands in call + // terminators. + } else { + self.super_terminator(terminator, location) + } + } +} diff --git a/compiler/rustc_mir/src/transform/dest_prop.rs b/compiler/rustc_mir/src/transform/dest_prop.rs index 4f5a467a6ee62..9c990ba8104d9 100644 --- a/compiler/rustc_mir/src/transform/dest_prop.rs +++ b/compiler/rustc_mir/src/transform/dest_prop.rs @@ -100,7 +100,7 @@ use crate::dataflow::impls::{MaybeInitializedLocals, MaybeLiveLocals}; use crate::dataflow::Analysis; use crate::{ transform::MirPass, - util::{dump_mir, PassWhere}, + util::{dump_mir, ever_borrowed_locals, PassWhere}, }; use itertools::Itertools; use rustc_data_structures::unify::{InPlaceUnificationTable, UnifyKey}; @@ -946,68 +946,6 @@ fn is_local_required(local: Local, body: &Body<'_>) -> bool { } } -/// Walks MIR to find all locals that have their address taken anywhere. -fn ever_borrowed_locals(body: &Body<'_>) -> BitSet { - let mut visitor = BorrowCollector { locals: BitSet::new_empty(body.local_decls.len()) }; - visitor.visit_body(body); - visitor.locals -} - -struct BorrowCollector { - locals: BitSet, -} - -impl<'tcx> Visitor<'tcx> for BorrowCollector { - fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) { - self.super_rvalue(rvalue, location); - - match rvalue { - Rvalue::AddressOf(_, borrowed_place) | Rvalue::Ref(_, _, borrowed_place) => { - if !borrowed_place.is_indirect() { - self.locals.insert(borrowed_place.local); - } - } - - Rvalue::Cast(..) - | Rvalue::Use(..) - | Rvalue::Repeat(..) - | Rvalue::Len(..) - | Rvalue::BinaryOp(..) - | Rvalue::CheckedBinaryOp(..) - | Rvalue::NullaryOp(..) - | Rvalue::UnaryOp(..) - | Rvalue::Discriminant(..) - | Rvalue::Aggregate(..) - | Rvalue::ThreadLocalRef(..) => {} - } - } - - fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) { - self.super_terminator(terminator, location); - - match terminator.kind { - TerminatorKind::Drop { place: dropped_place, .. } - | TerminatorKind::DropAndReplace { place: dropped_place, .. } => { - self.locals.insert(dropped_place.local); - } - - TerminatorKind::Abort - | TerminatorKind::Assert { .. } - | TerminatorKind::Call { .. } - | TerminatorKind::FalseEdge { .. } - | TerminatorKind::FalseUnwind { .. } - | TerminatorKind::GeneratorDrop - | TerminatorKind::Goto { .. } - | TerminatorKind::Resume - | TerminatorKind::Return - | TerminatorKind::SwitchInt { .. } - | TerminatorKind::Unreachable - | TerminatorKind::Yield { .. } - | TerminatorKind::InlineAsm { .. } => {} - } - } -} - /// `PlaceElem::Index` only stores a `Local`, so we can't replace that with a full `Place`. /// /// Collect locals used as indices so we don't generate candidates that are impossible to apply diff --git a/compiler/rustc_mir/src/transform/mod.rs b/compiler/rustc_mir/src/transform/mod.rs index e58a7d903082e..b7528aecdd40a 100644 --- a/compiler/rustc_mir/src/transform/mod.rs +++ b/compiler/rustc_mir/src/transform/mod.rs @@ -24,6 +24,7 @@ pub mod cleanup_post_borrowck; pub mod const_debuginfo; pub mod const_goto; pub mod const_prop; +pub mod copy_propagation; pub mod coverage; pub mod deaggregator; pub mod deduplicate_blocks; @@ -517,6 +518,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { &simplify::SimplifyCfg::new("final"), &nrvo::RenameReturnPlace, &const_debuginfo::ConstDebugInfo, + ©_propagation::CopyPropagation, &simplify::SimplifyLocals, &multiple_return_terminators::MultipleReturnTerminators, &deduplicate_blocks::DeduplicateBlocks, diff --git a/compiler/rustc_mir/src/transform/validate.rs b/compiler/rustc_mir/src/transform/validate.rs index 835789069bb2e..99c0344ec8cdd 100644 --- a/compiler/rustc_mir/src/transform/validate.rs +++ b/compiler/rustc_mir/src/transform/validate.rs @@ -203,8 +203,11 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) { // This check is somewhat expensive, so only run it when -Zvalidate-mir is passed. - if self.tcx.sess.opts.debugging_opts.validate_mir { - // `Operand::Copy` is only supposed to be used with `Copy` types. + if self.tcx.sess.opts.debugging_opts.validate_mir + && self.mir_phase < MirPhase::GeneratorLowering + { + // `Operand::Copy` is only supposed to be used with `Copy` types before MIR + // optimizations. if let Operand::Copy(place) = operand { let ty = place.ty(&self.body.local_decls, self.tcx).ty; let span = self.body.source_info(location).span; diff --git a/compiler/rustc_mir/src/util/borrowed.rs b/compiler/rustc_mir/src/util/borrowed.rs new file mode 100644 index 0000000000000..dd5ddee4f855f --- /dev/null +++ b/compiler/rustc_mir/src/util/borrowed.rs @@ -0,0 +1,65 @@ +use rustc_index::bit_set::BitSet; +use rustc_middle::mir::visit::Visitor; +use rustc_middle::mir::*; + +/// Walks MIR to find all locals that have their address taken anywhere. +pub fn ever_borrowed_locals(body: &Body<'_>) -> BitSet { + let mut visitor = BorrowCollector { locals: BitSet::new_empty(body.local_decls.len()) }; + for (block, data) in body.basic_blocks().iter_enumerated() { + visitor.visit_basic_block_data(block, data); + } + visitor.locals +} + +struct BorrowCollector { + locals: BitSet, +} + +impl<'tcx> Visitor<'tcx> for BorrowCollector { + fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, _location: Location) { + match rvalue { + Rvalue::AddressOf(_, borrowed_place) | Rvalue::Ref(_, _, borrowed_place) => { + if !borrowed_place.is_indirect() { + self.locals.insert(borrowed_place.local); + } + } + + Rvalue::Cast(..) + | Rvalue::Use(..) + | Rvalue::Repeat(..) + | Rvalue::Len(..) + | Rvalue::BinaryOp(..) + | Rvalue::CheckedBinaryOp(..) + | Rvalue::NullaryOp(..) + | Rvalue::UnaryOp(..) + | Rvalue::Discriminant(..) + | Rvalue::Aggregate(..) + | Rvalue::ThreadLocalRef(..) => {} + } + } + + fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) { + self.super_terminator(terminator, location); + + match terminator.kind { + TerminatorKind::Drop { place: dropped_place, .. } + | TerminatorKind::DropAndReplace { place: dropped_place, .. } => { + self.locals.insert(dropped_place.local); + } + + TerminatorKind::Abort + | TerminatorKind::Assert { .. } + | TerminatorKind::Call { .. } + | TerminatorKind::FalseEdge { .. } + | TerminatorKind::FalseUnwind { .. } + | TerminatorKind::GeneratorDrop + | TerminatorKind::Goto { .. } + | TerminatorKind::Resume + | TerminatorKind::Return + | TerminatorKind::SwitchInt { .. } + | TerminatorKind::Unreachable + | TerminatorKind::Yield { .. } + | TerminatorKind::InlineAsm { .. } => {} + } + } +} diff --git a/compiler/rustc_mir/src/util/mod.rs b/compiler/rustc_mir/src/util/mod.rs index b7b702431bc2a..fe42fc37ca9f2 100644 --- a/compiler/rustc_mir/src/util/mod.rs +++ b/compiler/rustc_mir/src/util/mod.rs @@ -5,6 +5,7 @@ pub mod patch; pub mod storage; mod alignment; +mod borrowed; pub mod collect_writes; mod find_self_call; mod generic_graph; @@ -15,6 +16,7 @@ pub(crate) mod spanview; pub use self::aggregate::expand_aggregate; pub use self::alignment::is_disaligned; +pub use self::borrowed::ever_borrowed_locals; pub use self::find_self_call::find_self_call; pub use self::generic_graph::graphviz_safe_def_name; pub use self::graphviz::write_mir_graphviz; diff --git a/src/test/codegen/try_identity.rs b/src/test/codegen/try_identity.rs deleted file mode 100644 index 3ff77163b9f3d..0000000000000 --- a/src/test/codegen/try_identity.rs +++ /dev/null @@ -1,34 +0,0 @@ -// compile-flags: -C no-prepopulate-passes -O -Z mir-opt-level=3 -Zunsound-mir-opts - -// Ensure that `x?` has no overhead on `Result` due to identity `match`es in lowering. -// This requires inlining to trigger the MIR optimizations in `SimplifyArmIdentity`. - -#![crate_type = "lib"] - -type R = Result; - -// This was written to the `?` from `try_trait`, but `try_trait_v2` uses a different structure, -// so the relevant desugar is copied inline in order to keep the test testing the same thing. -// FIXME(#85133): while this might be useful for `r#try!`, it would be nice to have a MIR -// optimization that picks up the `?` desugaring, as `SimplifyArmIdentity` does not. -#[no_mangle] -pub fn try_identity(x: R) -> R { -// CHECK: start: -// CHECK-NOT: br {{.*}} -// CHECK ret void - let y = match into_result(x) { - Err(e) => return from_error(From::from(e)), - Ok(v) => v, - }; - Ok(y) -} - -#[inline] -fn into_result(r: Result) -> Result { - r -} - -#[inline] -fn from_error(e: E) -> Result { - Err(e) -} diff --git a/src/test/mir-opt/copy_propagation.chain.CopyPropagation.diff b/src/test/mir-opt/copy_propagation.chain.CopyPropagation.diff new file mode 100644 index 0000000000000..bf9e6f65ac036 --- /dev/null +++ b/src/test/mir-opt/copy_propagation.chain.CopyPropagation.diff @@ -0,0 +1,63 @@ +- // MIR for `chain` before CopyPropagation ++ // MIR for `chain` after CopyPropagation + + fn chain(_1: T) -> T { + debug a => _1; // in scope 0 at $DIR/copy_propagation.rs:16:23: 16:28 + let mut _2: T; // in scope 0 at $DIR/copy_propagation.rs:17:9: 17:14 + let mut _4: T; // in scope 0 at $DIR/copy_propagation.rs:19:9: 19:10 + let mut _5: T; // in scope 0 at $DIR/copy_propagation.rs:20:9: 20:10 + let mut _6: T; // in scope 0 at $DIR/copy_propagation.rs:21:9: 21:10 + let mut _7: T; // in scope 0 at $DIR/copy_propagation.rs:22:9: 22:10 + let mut _8: T; // in scope 0 at $DIR/copy_propagation.rs:23:9: 23:10 + scope 1 { + debug b => _2; // in scope 1 at $DIR/copy_propagation.rs:17:9: 17:14 + let mut _3: T; // in scope 1 at $DIR/copy_propagation.rs:18:9: 18:14 + scope 2 { + debug c => _3; // in scope 2 at $DIR/copy_propagation.rs:18:9: 18:14 + let mut _0: T; // return place in scope 2 at $DIR/copy_propagation.rs:25:9: 25:10 + let _9: T; // in scope 2 at $DIR/copy_propagation.rs:25:9: 25:10 + scope 3 { + debug d => _0; // in scope 3 at $DIR/copy_propagation.rs:25:9: 25:10 + } + } + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/copy_propagation.rs:17:9: 17:14 + StorageLive(_3); // scope 1 at $DIR/copy_propagation.rs:18:9: 18:14 + StorageLive(_4); // scope 2 at $DIR/copy_propagation.rs:19:9: 19:10 + _4 = _1; // scope 2 at $DIR/copy_propagation.rs:19:9: 19:10 +- _2 = move _4; // scope 2 at $DIR/copy_propagation.rs:19:5: 19:10 ++ _2 = _1; // scope 2 at $DIR/copy_propagation.rs:19:5: 19:10 + StorageDead(_4); // scope 2 at $DIR/copy_propagation.rs:19:9: 19:10 + StorageLive(_5); // scope 2 at $DIR/copy_propagation.rs:20:9: 20:10 +- _5 = _2; // scope 2 at $DIR/copy_propagation.rs:20:9: 20:10 +- _3 = move _5; // scope 2 at $DIR/copy_propagation.rs:20:5: 20:10 ++ _5 = _1; // scope 2 at $DIR/copy_propagation.rs:20:9: 20:10 ++ _3 = _1; // scope 2 at $DIR/copy_propagation.rs:20:5: 20:10 + StorageDead(_5); // scope 2 at $DIR/copy_propagation.rs:20:9: 20:10 + StorageLive(_6); // scope 2 at $DIR/copy_propagation.rs:21:9: 21:10 +- _6 = _3; // scope 2 at $DIR/copy_propagation.rs:21:9: 21:10 +- _1 = move _6; // scope 2 at $DIR/copy_propagation.rs:21:5: 21:10 ++ _6 = _1; // scope 2 at $DIR/copy_propagation.rs:21:9: 21:10 ++ _1 = _6; // scope 2 at $DIR/copy_propagation.rs:21:5: 21:10 + StorageDead(_6); // scope 2 at $DIR/copy_propagation.rs:21:9: 21:10 + StorageLive(_7); // scope 2 at $DIR/copy_propagation.rs:22:9: 22:10 + _7 = _1; // scope 2 at $DIR/copy_propagation.rs:22:9: 22:10 +- _2 = move _7; // scope 2 at $DIR/copy_propagation.rs:22:5: 22:10 ++ _2 = _1; // scope 2 at $DIR/copy_propagation.rs:22:5: 22:10 + StorageDead(_7); // scope 2 at $DIR/copy_propagation.rs:22:9: 22:10 + StorageLive(_8); // scope 2 at $DIR/copy_propagation.rs:23:9: 23:10 +- _8 = _2; // scope 2 at $DIR/copy_propagation.rs:23:9: 23:10 +- _3 = move _8; // scope 2 at $DIR/copy_propagation.rs:23:5: 23:10 ++ _8 = _1; // scope 2 at $DIR/copy_propagation.rs:23:9: 23:10 ++ _3 = _1; // scope 2 at $DIR/copy_propagation.rs:23:5: 23:10 + StorageDead(_8); // scope 2 at $DIR/copy_propagation.rs:23:9: 23:10 +- _0 = _3; // scope 2 at $DIR/copy_propagation.rs:25:13: 25:14 ++ _0 = _1; // scope 2 at $DIR/copy_propagation.rs:25:13: 25:14 + StorageDead(_3); // scope 1 at $DIR/copy_propagation.rs:27:1: 27:2 + StorageDead(_2); // scope 0 at $DIR/copy_propagation.rs:27:1: 27:2 + return; // scope 0 at $DIR/copy_propagation.rs:27:2: 27:2 + } + } + diff --git a/src/test/mir-opt/copy_propagation.id.CopyPropagation.diff b/src/test/mir-opt/copy_propagation.id.CopyPropagation.diff new file mode 100644 index 0000000000000..6107701eee510 --- /dev/null +++ b/src/test/mir-opt/copy_propagation.id.CopyPropagation.diff @@ -0,0 +1,19 @@ +- // MIR for `id` before CopyPropagation ++ // MIR for `id` after CopyPropagation + + fn id(_1: T) -> T { + debug a => _1; // in scope 0 at $DIR/copy_propagation.rs:9:20: 9:25 + let mut _0: T; // return place in scope 0 at $DIR/copy_propagation.rs:9:33: 9:34 + let mut _2: T; // in scope 0 at $DIR/copy_propagation.rs:11:9: 11:10 + + bb0: { + StorageLive(_2); // scope 0 at $DIR/copy_propagation.rs:11:9: 11:10 + _2 = _1; // scope 0 at $DIR/copy_propagation.rs:11:9: 11:10 +- _1 = move _2; // scope 0 at $DIR/copy_propagation.rs:11:5: 11:10 ++ _1 = _2; // scope 0 at $DIR/copy_propagation.rs:11:5: 11:10 + StorageDead(_2); // scope 0 at $DIR/copy_propagation.rs:11:9: 11:10 + _0 = _1; // scope 0 at $DIR/copy_propagation.rs:12:5: 12:6 + return; // scope 0 at $DIR/copy_propagation.rs:13:2: 13:2 + } + } + diff --git a/src/test/mir-opt/copy_propagation.rs b/src/test/mir-opt/copy_propagation.rs new file mode 100644 index 0000000000000..14e87451a329a --- /dev/null +++ b/src/test/mir-opt/copy_propagation.rs @@ -0,0 +1,27 @@ +// compile-flags: --crate-type=lib + +// EMIT_MIR copy_propagation.write.CopyPropagation.diff +pub fn write(dst: &mut T, value: T) { + *dst = value; +} + +// EMIT_MIR copy_propagation.id.CopyPropagation.diff +pub fn id(mut a: T) -> T { + // Not optimized. + a = a; + a +} + +// EMIT_MIR copy_propagation.chain.CopyPropagation.diff +pub fn chain(mut a: T) -> T { + let mut b; + let mut c; + b = a; + c = b; + a = c; + b = a; + c = b; + + let d = c; + d +} diff --git a/src/test/mir-opt/copy_propagation.write.CopyPropagation.diff b/src/test/mir-opt/copy_propagation.write.CopyPropagation.diff new file mode 100644 index 0000000000000..55dd72ca96524 --- /dev/null +++ b/src/test/mir-opt/copy_propagation.write.CopyPropagation.diff @@ -0,0 +1,19 @@ +- // MIR for `write` before CopyPropagation ++ // MIR for `write` after CopyPropagation + + fn write(_1: &mut T, _2: T) -> () { + debug dst => _1; // in scope 0 at $DIR/copy_propagation.rs:4:23: 4:26 + debug value => _2; // in scope 0 at $DIR/copy_propagation.rs:4:36: 4:41 + let mut _0: (); // return place in scope 0 at $DIR/copy_propagation.rs:4:46: 4:46 + let mut _3: T; // in scope 0 at $DIR/copy_propagation.rs:5:12: 5:17 + + bb0: { + StorageLive(_3); // scope 0 at $DIR/copy_propagation.rs:5:12: 5:17 + _3 = _2; // scope 0 at $DIR/copy_propagation.rs:5:12: 5:17 +- (*_1) = move _3; // scope 0 at $DIR/copy_propagation.rs:5:5: 5:17 ++ (*_1) = _2; // scope 0 at $DIR/copy_propagation.rs:5:5: 5:17 + StorageDead(_3); // scope 0 at $DIR/copy_propagation.rs:5:16: 5:17 + return; // scope 0 at $DIR/copy_propagation.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff b/src/test/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff index b0c97f4237818..5bf87c96b0aed 100644 --- a/src/test/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff +++ b/src/test/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff @@ -22,7 +22,7 @@ StorageLive(_3); // scope 0 at $DIR/deduplicate_blocks.rs:3:11: 3:12 _3 = _1; // scope 0 at $DIR/deduplicate_blocks.rs:3:11: 3:12 StorageLive(_8); // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23 - _8 = _3; // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23 + _8 = _1; // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23 - _2 = transmute::<&str, &[u8]>(move _8) -> bb14; // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23 + _2 = transmute::<&str, &[u8]>(move _8) -> bb12; // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23 // mir::Constant @@ -49,8 +49,8 @@ bb5: { _4 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31 - _5 = Ge(move _4, const 3_usize); // scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31 - switchInt(move _5) -> [false: bb9, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31 + _5 = Ge(_4, const 3_usize); // scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31 + switchInt(_5) -> [false: bb9, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31 } bb6: { @@ -100,8 +100,8 @@ StorageDead(_8); // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23 StorageDead(_3); // scope 0 at $DIR/deduplicate_blocks.rs:3:22: 3:23 _6 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37 - _7 = Ge(move _6, const 4_usize); // scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37 - switchInt(move _7) -> [false: bb5, otherwise: bb1]; // scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37 + _7 = Ge(_6, const 4_usize); // scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37 + switchInt(_7) -> [false: bb5, otherwise: bb1]; // scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37 } } diff --git a/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir b/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir index 815d02c73d1e2..da977c395c6dc 100644 --- a/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir @@ -11,8 +11,6 @@ fn bar() -> bool { scope 2 (inlined foo) { // at $DIR/inline-any-operand.rs:12:5: 12:13 debug x => _3; // in scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 debug y => _4; // in scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 - let mut _5: i32; // in scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 - let mut _6: i32; // in scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 } } @@ -28,13 +26,7 @@ fn bar() -> bool { _3 = const 1_i32; // scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 StorageLive(_4); // scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 _4 = const -1_i32; // scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 - StorageLive(_5); // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 - _5 = _3; // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 - StorageLive(_6); // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 - _6 = _4; // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 - _0 = Eq(move _5, move _6); // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 - StorageDead(_6); // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 - StorageDead(_5); // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 + _0 = Eq(_3, _4); // scope 2 at $DIR/inline-any-operand.rs:12:5: 12:13 StorageDead(_4); // scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 StorageDead(_3); // scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 StorageDead(_2); // scope 1 at $DIR/inline-any-operand.rs:12:12: 12:13 diff --git a/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir index 4bda9ae383c22..db504b416fe1d 100644 --- a/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir @@ -40,7 +40,7 @@ fn foo(_1: T, _2: &i32) -> i32 { _9 = move (_5.1: &i32); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 StorageLive(_10); // scope 2 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 _10 = _8; // scope 2 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 - _0 = (*_10); // scope 3 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + _0 = (*_8); // scope 3 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 StorageDead(_10); // scope 2 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 StorageDead(_9); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 StorageDead(_8); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 diff --git a/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir index a7c2c93aad23a..40b6070ba41c2 100644 --- a/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir @@ -44,8 +44,8 @@ fn foo(_1: T, _2: i32) -> (i32, T) { _10 = (*((*_6).0: &i32)); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 StorageLive(_11); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 _11 = (*((*_6).1: &T)); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 - (_0.0: i32) = move _10; // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 - (_0.1: T) = move _11; // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + (_0.0: i32) = _10; // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + (_0.1: T) = _11; // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 StorageDead(_11); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 StorageDead(_10); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 StorageDead(_9); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 diff --git a/src/test/mir-opt/inline/inline_cycle.two.Inline.diff b/src/test/mir-opt/inline/inline_cycle.two.Inline.diff index aaf65c5d0a5f3..a379d30c37533 100644 --- a/src/test/mir-opt/inline/inline_cycle.two.Inline.diff +++ b/src/test/mir-opt/inline/inline_cycle.two.Inline.diff @@ -27,7 +27,7 @@ // + literal: Const { ty: fn() {f}, val: Value(Scalar()) } + StorageLive(_3); // scope 1 at $DIR/inline-cycle.rs:49:5: 49:12 + StorageLive(_4); // scope 1 at $DIR/inline-cycle.rs:49:5: 49:12 -+ _4 = move _2; // scope 1 at $DIR/inline-cycle.rs:49:5: 49:12 ++ _4 = _2; // scope 1 at $DIR/inline-cycle.rs:49:5: 49:12 + StorageLive(_5); // scope 1 at $DIR/inline-cycle.rs:49:5: 49:12 + _5 = const (); // scope 1 at $DIR/inline-cycle.rs:49:5: 49:12 + _3 = move _4() -> bb1; // scope 2 at $DIR/inline-cycle.rs:49:5: 49:12 diff --git a/src/test/mir-opt/inline/inline_diverging.h.Inline.diff b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff index e2fad5b60ebfa..fcd6a58852042 100644 --- a/src/test/mir-opt/inline/inline_diverging.h.Inline.diff +++ b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff @@ -5,15 +5,14 @@ let mut _0: (); // return place in scope 0 at $DIR/inline-diverging.rs:21:12: 21:12 let _1: (!, !); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 + let mut _2: fn() -> ! {sleep}; // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 ++ let mut _8: (); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 + let mut _9: (); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 -+ let mut _10: (); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 + scope 1 (inlined call_twice:: ! {sleep}>) { // at $DIR/inline-diverging.rs:22:5: 22:22 + debug f => _2; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + let _3: !; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + let mut _4: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + let mut _6: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + let mut _7: !; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 -+ let mut _8: !; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + scope 2 { + debug a => _3; // in scope 2 at $DIR/inline-diverging.rs:22:5: 22:22 + let _5: !; // in scope 2 at $DIR/inline-diverging.rs:22:5: 22:22 @@ -45,8 +44,8 @@ + StorageLive(_3); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + StorageLive(_4); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + _4 = &_2; // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 -+ StorageLive(_9); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 -+ _9 = const (); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 ++ StorageLive(_8); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 ++ _8 = const (); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + goto -> bb1; // scope 4 at $DIR/inline-diverging.rs:22:5: 22:22 } diff --git a/src/test/mir-opt/inline/inline_generator.main.Inline.diff b/src/test/mir-opt/inline/inline_generator.main.Inline.diff index 9035b46f4c69d..1aa99fe0112cc 100644 --- a/src/test/mir-opt/inline/inline_generator.main.Inline.diff +++ b/src/test/mir-opt/inline/inline_generator.main.Inline.diff @@ -7,7 +7,7 @@ let mut _2: std::pin::Pin<&mut impl std::ops::Generator>; // in scope 0 at $DIR/inline-generator.rs:9:14: 9:32 let mut _3: &mut impl std::ops::Generator; // in scope 0 at $DIR/inline-generator.rs:9:23: 9:31 let mut _4: impl std::ops::Generator; // in scope 0 at $DIR/inline-generator.rs:9:28: 9:31 -+ let mut _7: bool; // in scope 0 at $DIR/inline-generator.rs:9:14: 9:46 ++ let mut _6: bool; // in scope 0 at $DIR/inline-generator.rs:9:14: 9:46 scope 1 { debug _r => _1; // in scope 1 at $DIR/inline-generator.rs:9:9: 9:11 } @@ -19,17 +19,14 @@ + scope 4 { + scope 5 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41]>::new_unchecked) { // at $DIR/inline-generator.rs:9:14: 9:32 + debug pointer => _5; // in scope 5 at $DIR/inline-generator.rs:9:14: 9:32 -+ let mut _6: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 5 at $DIR/inline-generator.rs:9:14: 9:32 + } + } + } + scope 6 (inlined g::{closure#0}) { // at $DIR/inline-generator.rs:9:14: 9:46 -+ debug a => _11; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ let mut _8: i32; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ let mut _9: bool; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ let mut _10: bool; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ let _11: bool; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ let mut _12: u32; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ debug a => _8; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ let mut _7: i32; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ let _8: bool; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ let mut _9: u32; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + } bb0: { @@ -55,32 +52,27 @@ - - bb2: { + StorageLive(_5); // scope 4 at $DIR/inline-generator.rs:9:14: 9:32 -+ _5 = move _3; // scope 4 at $DIR/inline-generator.rs:9:14: 9:32 -+ StorageLive(_6); // scope 5 at $DIR/inline-generator.rs:9:14: 9:32 -+ _6 = move _5; // scope 5 at $DIR/inline-generator.rs:9:14: 9:32 -+ (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]) = move _6; // scope 5 at $DIR/inline-generator.rs:9:14: 9:32 -+ StorageDead(_6); // scope 5 at $DIR/inline-generator.rs:9:14: 9:32 ++ _5 = _3; // scope 4 at $DIR/inline-generator.rs:9:14: 9:32 ++ (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]) = _5; // scope 5 at $DIR/inline-generator.rs:9:14: 9:32 + StorageDead(_5); // scope 4 at $DIR/inline-generator.rs:9:14: 9:32 StorageDead(_3); // scope 0 at $DIR/inline-generator.rs:9:31: 9:32 - _1 = as Generator>::resume(move _2, const false) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 - // mir::Constant - // + span: $DIR/inline-generator.rs:9:33: 9:39 - // + literal: Const { ty: for<'r> fn(std::pin::Pin<&'r mut impl std::ops::Generator>, bool) -> std::ops::GeneratorState< as std::ops::Generator>::Yield, as std::ops::Generator>::Return> { as std::ops::Generator>::resume}, val: Value(Scalar()) } -+ StorageLive(_7); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 -+ _7 = const false; // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 -+ StorageLive(_10); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 -+ StorageLive(_11); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 -+ StorageLive(_12); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 -+ _12 = discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]))); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ switchInt(move _12) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageLive(_6); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 ++ _6 = const false; // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageLive(_8); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageLive(_9); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 ++ _9 = discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]))); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ switchInt(_9) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 } - bb3: { + bb1: { -+ StorageDead(_12); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 -+ StorageDead(_11); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 -+ StorageDead(_10); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 -+ StorageDead(_7); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageDead(_9); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageDead(_8); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageDead(_6); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 StorageDead(_2); // scope 0 at $DIR/inline-generator.rs:9:45: 9:46 StorageDead(_4); // scope 0 at $DIR/inline-generator.rs:9:46: 9:47 _0 = const (); // scope 0 at $DIR/inline-generator.rs:8:11: 10:2 @@ -94,36 +86,32 @@ + } + + bb3: { -+ _11 = move _7; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ StorageLive(_8); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ StorageLive(_9); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ _9 = _11; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ switchInt(move _9) -> [false: bb5, otherwise: bb4]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ _8 = _6; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageLive(_7); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ switchInt(_6) -> [false: bb5, otherwise: bb4]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + } + + bb4: { -+ _8 = const 7_i32; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ _7 = const 7_i32; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + goto -> bb6; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + } + + bb5: { -+ _8 = const 13_i32; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ _7 = const 13_i32; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + goto -> bb6; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + } + + bb6: { -+ StorageDead(_9); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ ((_1 as Yielded).0: i32) = move _8; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ ((_1 as Yielded).0: i32) = _7; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + discriminant(_1) = 0; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]))) = 3; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + goto -> bb1; // scope 0 at $DIR/inline-generator.rs:15:11: 15:39 + } + + bb7: { -+ StorageLive(_8); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ _10 = move _7; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ StorageDead(_8); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ ((_1 as Complete).0: bool) = move _10; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageLive(_7); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageDead(_7); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ ((_1 as Complete).0: bool) = _6; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + discriminant(_1) = 1; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]))) = 1; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + goto -> bb1; // scope 0 at $DIR/inline-generator.rs:15:41: 15:41 diff --git a/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir b/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir index 5ceefce6114f0..3bb7febb37369 100644 --- a/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir @@ -64,7 +64,7 @@ fn bar() -> bool { _11 = (*_3); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 StorageLive(_12); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 _12 = (*_6); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 - _0 = Eq(move _11, move _12); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + _0 = Eq(_11, _12); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 StorageDead(_12); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 StorageDead(_11); // scope 2 at $DIR/inline-retag.rs:12:5: 12:15 StorageDead(_6); // scope 1 at $DIR/inline-retag.rs:12:14: 12:15 diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff index e955feb7d1f41..ca7ce6a2f965c 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff @@ -9,29 +9,26 @@ let mut _5: i32; // in scope 0 at $DIR/issue-73223.rs:7:22: 7:27 let mut _6: (&i32, &i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _7: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _8: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _10: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _11: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _12: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _13: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _12: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _14: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _15: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _16: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _17: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _18: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _19: std::option::Option; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _16: std::option::Option; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 1 { debug split => _1; // in scope 1 at $DIR/issue-73223.rs:2:9: 2:14 let _4: std::option::Option; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 scope 3 { debug _prev => _4; // in scope 3 at $DIR/issue-73223.rs:7:9: 7:14 + let _8: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _9: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _10: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _20: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _17: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 4 { - debug left_val => _9; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - debug right_val => _10; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _14: core::panicking::AssertKind; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug left_val => _8; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug right_val => _9; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _13: core::panicking::AssertKind; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 5 { - debug kind => _14; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug kind => _13; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } } } @@ -53,54 +50,47 @@ StorageLive(_4); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 StorageLive(_5); // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 _5 = _1; // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 - ((_4 as Some).0: i32) = move _5; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 + ((_4 as Some).0: i32) = _5; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 discriminant(_4) = 1; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 StorageDead(_5); // scope 1 at $DIR/issue-73223.rs:7:27: 7:28 StorageLive(_6); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _7 = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _20 = const main::promoted[0]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _17 = const main::promoted[0]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // ty::Const // + ty: &i32 // + val: Unevaluated(main, [], Some(promoted[0])) // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: &i32, val: Unevaluated(Unevaluated { def: WithOptConstParam { did: DefId(0:3 ~ issue_73223[2d0f]::main), const_param_did: None }, substs: [], promoted: Some(promoted[0]) }) } - _8 = _20; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_6.0: &i32) = move _7; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_6.1: &i32) = move _8; // 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 + (_6.0: &i32) = _7; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_6.1: &i32) = _17; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _8 = (_6.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _9 = (_6.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _10 = (_6.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _9 = (_6.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_10); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _13 = (*_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _12 = Eq(move _13, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _11 = Not(move _12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _12 = (*_8); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _11 = Eq(_12, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - switchInt(move _11) -> [false: bb2, otherwise: bb1]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _10 = Not(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + switchInt(_10) -> [false: bb2, otherwise: bb1]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } bb1: { - StorageLive(_14); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_14) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_13) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_14); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _14 = _8; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_15); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _15 = _9; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_16); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _16 = _9; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _15 = _16; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_17); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_18); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _18 = _10; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _17 = _18; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_19); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_19) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - core::panicking::assert_failed::(const core::panicking::AssertKind::Eq, move _15, move _17, move _19); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_16) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + core::panicking::assert_failed::(const core::panicking::AssertKind::Eq, move _14, move _15, move _16); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(core::panicking::AssertKind, &'r i32, &'s i32, std::option::Option>) -> ! {core::panicking::assert_failed::}, val: Value(Scalar()) } @@ -113,9 +103,9 @@ } bb2: { - StorageDead(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_10); // scope 4 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 StorageDead(_6); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_4); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff index e955feb7d1f41..ca7ce6a2f965c 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff @@ -9,29 +9,26 @@ let mut _5: i32; // in scope 0 at $DIR/issue-73223.rs:7:22: 7:27 let mut _6: (&i32, &i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _7: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _8: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _10: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _11: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _12: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _13: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _12: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _14: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _15: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _16: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _17: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _18: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _19: std::option::Option; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _16: std::option::Option; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 1 { debug split => _1; // in scope 1 at $DIR/issue-73223.rs:2:9: 2:14 let _4: std::option::Option; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 scope 3 { debug _prev => _4; // in scope 3 at $DIR/issue-73223.rs:7:9: 7:14 + let _8: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _9: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _10: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _20: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _17: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 4 { - debug left_val => _9; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - debug right_val => _10; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _14: core::panicking::AssertKind; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug left_val => _8; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug right_val => _9; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _13: core::panicking::AssertKind; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 5 { - debug kind => _14; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug kind => _13; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } } } @@ -53,54 +50,47 @@ StorageLive(_4); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 StorageLive(_5); // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 _5 = _1; // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 - ((_4 as Some).0: i32) = move _5; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 + ((_4 as Some).0: i32) = _5; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 discriminant(_4) = 1; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 StorageDead(_5); // scope 1 at $DIR/issue-73223.rs:7:27: 7:28 StorageLive(_6); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _7 = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _20 = const main::promoted[0]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _17 = const main::promoted[0]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // ty::Const // + ty: &i32 // + val: Unevaluated(main, [], Some(promoted[0])) // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: &i32, val: Unevaluated(Unevaluated { def: WithOptConstParam { did: DefId(0:3 ~ issue_73223[2d0f]::main), const_param_did: None }, substs: [], promoted: Some(promoted[0]) }) } - _8 = _20; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_6.0: &i32) = move _7; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_6.1: &i32) = move _8; // 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 + (_6.0: &i32) = _7; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_6.1: &i32) = _17; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _8 = (_6.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _9 = (_6.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _10 = (_6.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _9 = (_6.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_10); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _13 = (*_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _12 = Eq(move _13, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _11 = Not(move _12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _12 = (*_8); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _11 = Eq(_12, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - switchInt(move _11) -> [false: bb2, otherwise: bb1]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _10 = Not(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + switchInt(_10) -> [false: bb2, otherwise: bb1]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } bb1: { - StorageLive(_14); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_14) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_13) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_14); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _14 = _8; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_15); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _15 = _9; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_16); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _16 = _9; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _15 = _16; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_17); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_18); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _18 = _10; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _17 = _18; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_19); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_19) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - core::panicking::assert_failed::(const core::panicking::AssertKind::Eq, move _15, move _17, move _19); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_16) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + core::panicking::assert_failed::(const core::panicking::AssertKind::Eq, move _14, move _15, move _16); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(core::panicking::AssertKind, &'r i32, &'s i32, std::option::Option>) -> ! {core::panicking::assert_failed::}, val: Value(Scalar()) } @@ -113,9 +103,9 @@ } bb2: { - StorageDead(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_10); // scope 4 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 StorageDead(_6); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_4); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 diff --git a/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir b/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir index 86ec31ce47eda..4288021c7ddef 100644 --- a/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir +++ b/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir @@ -35,7 +35,7 @@ fn num_to_digit(_1: char) -> u32 { StorageLive(_6); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 StorageLive(_7); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 StorageLive(_8); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 - _8 = _2; // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 + _8 = _1; // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 _7 = char::methods::::to_digit(move _8, const 8_u32) -> bb5; // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 // mir::Constant // + span: $DIR/issue-59352.rs:14:8: 14:23 @@ -63,7 +63,7 @@ fn num_to_digit(_1: char) -> u32 { StorageDead(_4); // scope 0 at $DIR/issue-59352.rs:14:40: 14:41 StorageLive(_10); // scope 0 at $DIR/issue-59352.rs:14:26: 14:50 _10 = discriminant(_3); // scope 3 at $DIR/issue-59352.rs:14:26: 14:50 - switchInt(move _10) -> [0_isize: bb6, 1_isize: bb8, otherwise: bb7]; // scope 3 at $DIR/issue-59352.rs:14:26: 14:50 + switchInt(_10) -> [0_isize: bb6, 1_isize: bb8, otherwise: bb7]; // scope 3 at $DIR/issue-59352.rs:14:26: 14:50 } bb4: { @@ -76,13 +76,13 @@ fn num_to_digit(_1: char) -> u32 { StorageLive(_9); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 _9 = discriminant((*_6)); // scope 2 at $DIR/issue-59352.rs:14:8: 14:23 StorageLive(_11); // scope 2 at $DIR/issue-59352.rs:14:8: 14:23 - _11 = move _9; // scope 2 at $DIR/issue-59352.rs:14:8: 14:23 + _11 = _9; // scope 2 at $DIR/issue-59352.rs:14:8: 14:23 StorageDead(_9); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 StorageDead(_6); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 StorageDead(_7); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 StorageDead(_5); // scope 0 at $DIR/issue-59352.rs:14:8: 14:23 StorageDead(_2); // scope 0 at $DIR/issue-59352.rs:14:22: 14:23 - switchInt(move _11) -> [1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/issue-59352.rs:14:5: 14:63 + switchInt(_11) -> [1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/issue-59352.rs:14:5: 14:63 } bb6: { @@ -103,7 +103,7 @@ fn num_to_digit(_1: char) -> u32 { } bb8: { - _0 = move ((_3 as Some).0: u32); // scope 3 at $DIR/issue-59352.rs:14:26: 14:50 + _0 = ((_3 as Some).0: u32); // scope 3 at $DIR/issue-59352.rs:14:26: 14:50 StorageDead(_10); // scope 0 at $DIR/issue-59352.rs:14:26: 14:50 StorageDead(_3); // scope 0 at $DIR/issue-59352.rs:14:49: 14:50 goto -> bb4; // scope 0 at $DIR/issue-59352.rs:14:5: 14:63 diff --git a/src/test/mir-opt/lower_intrinsics.f_u64.PreCodegen.before.mir b/src/test/mir-opt/lower_intrinsics.f_u64.PreCodegen.before.mir index 380f6ce9ba73e..ed0aad06b1108 100644 --- a/src/test/mir-opt/lower_intrinsics.f_u64.PreCodegen.before.mir +++ b/src/test/mir-opt/lower_intrinsics.f_u64.PreCodegen.before.mir @@ -16,7 +16,7 @@ fn f_u64() -> () { _1 = const 0_u64; // scope 0 at $DIR/lower_intrinsics.rs:35:5: 35:21 StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 - _3 = move _1; // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 + _3 = _1; // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 _2 = f_non_zst::(move _3) -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 // mir::Constant // + span: $DIR/lower_intrinsics.rs:35:5: 35:21 diff --git a/src/test/mir-opt/partial.rs b/src/test/mir-opt/partial.rs new file mode 100644 index 0000000000000..efaf54ecfc715 --- /dev/null +++ b/src/test/mir-opt/partial.rs @@ -0,0 +1,13 @@ +// compile-flags: --crate-type=lib -Copt-level=0 -Zmir-opt-level=1 + +// EMIT_MIR partial.{impl#1}-eq.LowerIntrinsics.diff +// EMIT_MIR partial.{impl#1}-eq.CopyPropagation.diff +// EMIT_MIR partial.{impl#1}-eq.PreCodegen.before.mir +// EMIT_MIR partial.{impl#2}-partial_cmp.LowerIntrinsics.diff +// EMIT_MIR partial.{impl#2}-partial_cmp.CopyPropagation.diff +// EMIT_MIR partial.{impl#2}-partial_cmp.PreCodegen.before.mir +#[derive(PartialEq, PartialOrd)] +pub enum E { + A, + B, +} diff --git a/src/test/mir-opt/partial.{impl#1}-eq.CopyPropagation.diff b/src/test/mir-opt/partial.{impl#1}-eq.CopyPropagation.diff new file mode 100644 index 0000000000000..7a190128ebaf8 --- /dev/null +++ b/src/test/mir-opt/partial.{impl#1}-eq.CopyPropagation.diff @@ -0,0 +1,69 @@ +- // MIR for `::eq` before CopyPropagation ++ // MIR for `::eq` after CopyPropagation + + fn ::eq(_1: &E, _2: &E) -> bool { + debug self => _1; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + debug other => _2; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _0: bool; // return place in scope 0 at $DIR/partial.rs:9:10: 9:19 + let _3: isize; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _4: &E; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let _5: &E; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _7: &E; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let _8: &E; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _9: bool; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _10: bool; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _11: isize; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _12: isize; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _13: (&E, &E); // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _14: &E; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _15: &E; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + scope 1 { + debug __self_vi => _3; // in scope 1 at $DIR/partial.rs:9:10: 9:19 + let _6: isize; // in scope 1 at $DIR/partial.rs:9:10: 9:19 + scope 2 { + debug __arg_1_vi => _6; // in scope 2 at $DIR/partial.rs:9:10: 9:19 + } + } + + bb0: { + _5 = _1; // scope 0 at $DIR/partial.rs:9:10: 9:19 +- _4 = _5; // scope 0 at $DIR/partial.rs:9:10: 9:19 +- _3 = discriminant((*_4)); // scope 0 at $DIR/partial.rs:9:10: 9:19 ++ _4 = _1; // scope 0 at $DIR/partial.rs:9:10: 9:19 ++ _3 = discriminant((*_1)); // scope 0 at $DIR/partial.rs:9:10: 9:19 + _8 = _2; // scope 1 at $DIR/partial.rs:9:10: 9:19 +- _7 = _8; // scope 1 at $DIR/partial.rs:9:10: 9:19 +- _6 = discriminant((*_7)); // scope 1 at $DIR/partial.rs:9:10: 9:19 ++ _7 = _2; // scope 1 at $DIR/partial.rs:9:10: 9:19 ++ _6 = discriminant((*_2)); // scope 1 at $DIR/partial.rs:9:10: 9:19 + _11 = _3; // scope 2 at $DIR/partial.rs:9:10: 9:19 + _12 = _6; // scope 2 at $DIR/partial.rs:9:10: 9:19 +- _10 = Eq(move _11, move _12); // scope 2 at $DIR/partial.rs:9:10: 9:19 +- _9 = move _10; // scope 2 at $DIR/partial.rs:9:10: 9:19 +- switchInt(move _9) -> [false: bb2, otherwise: bb1]; // scope 2 at $DIR/partial.rs:9:10: 9:19 ++ _10 = Eq(_3, _6); // scope 2 at $DIR/partial.rs:9:10: 9:19 ++ _9 = _10; // scope 2 at $DIR/partial.rs:9:10: 9:19 ++ switchInt(_10) -> [false: bb2, otherwise: bb1]; // scope 2 at $DIR/partial.rs:9:10: 9:19 + } + + bb1: { + _14 = _1; // scope 2 at $DIR/partial.rs:9:10: 9:19 + _15 = _2; // scope 2 at $DIR/partial.rs:9:10: 9:19 +- (_13.0: &E) = move _14; // scope 2 at $DIR/partial.rs:9:10: 9:19 +- (_13.1: &E) = move _15; // scope 2 at $DIR/partial.rs:9:10: 9:19 ++ (_13.0: &E) = _1; // scope 2 at $DIR/partial.rs:9:10: 9:19 ++ (_13.1: &E) = _2; // scope 2 at $DIR/partial.rs:9:10: 9:19 + _0 = const true; // scope 2 at $DIR/partial.rs:9:10: 9:19 + goto -> bb3; // scope 2 at $DIR/partial.rs:9:10: 9:19 + } + + bb2: { + _0 = const false; // scope 2 at $DIR/partial.rs:9:10: 9:19 + goto -> bb3; // scope 2 at $DIR/partial.rs:9:10: 9:19 + } + + bb3: { + return; // scope 0 at $DIR/partial.rs:9:19: 9:19 + } + } + diff --git a/src/test/mir-opt/partial.{impl#1}-eq.LowerIntrinsics.diff b/src/test/mir-opt/partial.{impl#1}-eq.LowerIntrinsics.diff new file mode 100644 index 0000000000000..17797cc351030 --- /dev/null +++ b/src/test/mir-opt/partial.{impl#1}-eq.LowerIntrinsics.diff @@ -0,0 +1,105 @@ +- // MIR for `::eq` before LowerIntrinsics ++ // MIR for `::eq` after LowerIntrinsics + + fn ::eq(_1: &E, _2: &E) -> bool { + debug self => _1; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + debug other => _2; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _0: bool; // return place in scope 0 at $DIR/partial.rs:9:10: 9:19 + let _3: isize; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _4: &E; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let _5: &E; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _7: &E; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let _8: &E; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _9: bool; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _10: bool; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _11: isize; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _12: isize; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _13: (&E, &E); // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _14: &E; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _15: &E; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + scope 1 { + debug __self_vi => _3; // in scope 1 at $DIR/partial.rs:9:10: 9:19 + let _6: isize; // in scope 1 at $DIR/partial.rs:9:10: 9:19 + scope 2 { + debug __arg_1_vi => _6; // in scope 2 at $DIR/partial.rs:9:10: 9:19 + } + } + + bb0: { + StorageLive(_3); // scope 0 at $DIR/partial.rs:9:10: 9:19 + StorageLive(_4); // scope 0 at $DIR/partial.rs:9:10: 9:19 + StorageLive(_5); // scope 0 at $DIR/partial.rs:9:10: 9:19 + _5 = &(*_1); // scope 0 at $DIR/partial.rs:9:10: 9:19 + _4 = &(*_5); // scope 0 at $DIR/partial.rs:9:10: 9:19 +- _3 = discriminant_value::(move _4) -> bb1; // scope 0 at $DIR/partial.rs:9:10: 9:19 +- // mir::Constant +- // + span: $DIR/partial.rs:9:10: 9:19 +- // + literal: Const { ty: for<'r> extern "rust-intrinsic" fn(&'r E) -> ::Discriminant {std::intrinsics::discriminant_value::}, val: Value(Scalar()) } ++ _3 = discriminant((*_4)); // scope 0 at $DIR/partial.rs:9:10: 9:19 ++ goto -> bb1; // scope 0 at $DIR/partial.rs:9:10: 9:19 + } + + bb1: { + StorageDead(_4); // scope 0 at $DIR/partial.rs:9:18: 9:19 + StorageDead(_5); // scope 0 at $DIR/partial.rs:9:18: 9:19 + StorageLive(_6); // scope 1 at $DIR/partial.rs:9:10: 9:19 + StorageLive(_7); // scope 1 at $DIR/partial.rs:9:10: 9:19 + StorageLive(_8); // scope 1 at $DIR/partial.rs:9:10: 9:19 + _8 = &(*_2); // scope 1 at $DIR/partial.rs:9:10: 9:19 + _7 = &(*_8); // scope 1 at $DIR/partial.rs:9:10: 9:19 +- _6 = discriminant_value::(move _7) -> bb2; // scope 1 at $DIR/partial.rs:9:10: 9:19 +- // mir::Constant +- // + span: $DIR/partial.rs:9:10: 9:19 +- // + literal: Const { ty: for<'r> extern "rust-intrinsic" fn(&'r E) -> ::Discriminant {std::intrinsics::discriminant_value::}, val: Value(Scalar()) } ++ _6 = discriminant((*_7)); // scope 1 at $DIR/partial.rs:9:10: 9:19 ++ goto -> bb2; // scope 1 at $DIR/partial.rs:9:10: 9:19 + } + + bb2: { + StorageDead(_7); // scope 1 at $DIR/partial.rs:9:18: 9:19 + StorageDead(_8); // scope 1 at $DIR/partial.rs:9:18: 9:19 + StorageLive(_9); // scope 2 at $DIR/partial.rs:9:10: 9:19 + StorageLive(_10); // scope 2 at $DIR/partial.rs:9:10: 9:19 + StorageLive(_11); // scope 2 at $DIR/partial.rs:9:10: 9:19 + _11 = _3; // scope 2 at $DIR/partial.rs:9:10: 9:19 + StorageLive(_12); // scope 2 at $DIR/partial.rs:9:10: 9:19 + _12 = _6; // scope 2 at $DIR/partial.rs:9:10: 9:19 + _10 = Eq(move _11, move _12); // scope 2 at $DIR/partial.rs:9:10: 9:19 + StorageDead(_12); // scope 2 at $DIR/partial.rs:9:18: 9:19 + StorageDead(_11); // scope 2 at $DIR/partial.rs:9:18: 9:19 + _9 = move _10; // scope 2 at $DIR/partial.rs:9:10: 9:19 + StorageDead(_10); // scope 2 at $DIR/partial.rs:9:18: 9:19 + switchInt(move _9) -> [false: bb4, otherwise: bb3]; // scope 2 at $DIR/partial.rs:9:10: 9:19 + } + + bb3: { + StorageLive(_13); // scope 2 at $DIR/partial.rs:9:10: 9:19 + StorageLive(_14); // scope 2 at $DIR/partial.rs:9:10: 9:19 + _14 = &(*_1); // scope 2 at $DIR/partial.rs:9:10: 9:19 + StorageLive(_15); // scope 2 at $DIR/partial.rs:9:10: 9:19 + _15 = &(*_2); // scope 2 at $DIR/partial.rs:9:10: 9:19 + _13 = (move _14, move _15); // scope 2 at $DIR/partial.rs:9:10: 9:19 + StorageDead(_15); // scope 2 at $DIR/partial.rs:9:18: 9:19 + StorageDead(_14); // scope 2 at $DIR/partial.rs:9:18: 9:19 + _0 = const true; // scope 2 at $DIR/partial.rs:9:10: 9:19 + StorageDead(_13); // scope 2 at $DIR/partial.rs:9:18: 9:19 + goto -> bb5; // scope 2 at $DIR/partial.rs:9:10: 9:19 + } + + bb4: { + _0 = const false; // scope 2 at $DIR/partial.rs:9:10: 9:19 + goto -> bb5; // scope 2 at $DIR/partial.rs:9:10: 9:19 + } + + bb5: { + StorageDead(_9); // scope 2 at $DIR/partial.rs:9:18: 9:19 + StorageDead(_6); // scope 1 at $DIR/partial.rs:9:18: 9:19 + StorageDead(_3); // scope 0 at $DIR/partial.rs:9:18: 9:19 + return; // scope 0 at $DIR/partial.rs:9:19: 9:19 + } + + bb6 (cleanup): { + resume; // scope 0 at $DIR/partial.rs:9:10: 9:19 + } + } + diff --git a/src/test/mir-opt/partial.{impl#1}-eq.PreCodegen.before.mir b/src/test/mir-opt/partial.{impl#1}-eq.PreCodegen.before.mir new file mode 100644 index 0000000000000..d07d54e6848e8 --- /dev/null +++ b/src/test/mir-opt/partial.{impl#1}-eq.PreCodegen.before.mir @@ -0,0 +1,37 @@ +// MIR for `::eq` before PreCodegen + +fn ::eq(_1: &E, _2: &E) -> bool { + debug self => _1; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + debug other => _2; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _0: bool; // return place in scope 0 at $DIR/partial.rs:9:10: 9:19 + let _3: isize; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + let mut _5: bool; // in scope 0 at $DIR/partial.rs:9:10: 9:19 + scope 1 { + debug __self_vi => _3; // in scope 1 at $DIR/partial.rs:9:10: 9:19 + let _4: isize; // in scope 1 at $DIR/partial.rs:9:10: 9:19 + scope 2 { + debug __arg_1_vi => _4; // in scope 2 at $DIR/partial.rs:9:10: 9:19 + } + } + + bb0: { + _3 = discriminant((*_1)); // scope 0 at $DIR/partial.rs:9:10: 9:19 + _4 = discriminant((*_2)); // scope 1 at $DIR/partial.rs:9:10: 9:19 + _5 = Eq(_3, _4); // scope 2 at $DIR/partial.rs:9:10: 9:19 + switchInt(_5) -> [false: bb2, otherwise: bb1]; // scope 2 at $DIR/partial.rs:9:10: 9:19 + } + + bb1: { + _0 = const true; // scope 2 at $DIR/partial.rs:9:10: 9:19 + goto -> bb3; // scope 2 at $DIR/partial.rs:9:10: 9:19 + } + + bb2: { + _0 = const false; // scope 2 at $DIR/partial.rs:9:10: 9:19 + goto -> bb3; // scope 2 at $DIR/partial.rs:9:10: 9:19 + } + + bb3: { + return; // scope 0 at $DIR/partial.rs:9:19: 9:19 + } +} diff --git a/src/test/mir-opt/partial.{impl#2}-partial_cmp.CopyPropagation.diff b/src/test/mir-opt/partial.{impl#2}-partial_cmp.CopyPropagation.diff new file mode 100644 index 0000000000000..aa3bf9f34a982 --- /dev/null +++ b/src/test/mir-opt/partial.{impl#2}-partial_cmp.CopyPropagation.diff @@ -0,0 +1,88 @@ +- // MIR for `::partial_cmp` before CopyPropagation ++ // MIR for `::partial_cmp` after CopyPropagation + + fn ::partial_cmp(_1: &E, _2: &E) -> Option { + debug self => _1; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + debug other => _2; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _0: std::option::Option; // return place in scope 0 at $DIR/partial.rs:9:21: 9:31 + let _3: isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _4: &E; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let _5: &E; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _7: &E; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let _8: &E; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _9: bool; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _10: bool; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _11: isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _12: isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _13: (&E, &E); // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _14: &E; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _15: &E; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _16: std::cmp::Ordering; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _17: &isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let _18: &isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _19: &isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let _20: &isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + scope 1 { + debug __self_vi => _3; // in scope 1 at $DIR/partial.rs:9:21: 9:31 + let _6: isize; // in scope 1 at $DIR/partial.rs:9:21: 9:31 + scope 2 { + debug __arg_1_vi => _6; // in scope 2 at $DIR/partial.rs:9:21: 9:31 + } + } + + bb0: { + _5 = _1; // scope 0 at $DIR/partial.rs:9:21: 9:31 +- _4 = _5; // scope 0 at $DIR/partial.rs:9:21: 9:31 +- _3 = discriminant((*_4)); // scope 0 at $DIR/partial.rs:9:21: 9:31 ++ _4 = _1; // scope 0 at $DIR/partial.rs:9:21: 9:31 ++ _3 = discriminant((*_1)); // scope 0 at $DIR/partial.rs:9:21: 9:31 + _8 = _2; // scope 1 at $DIR/partial.rs:9:21: 9:31 +- _7 = _8; // scope 1 at $DIR/partial.rs:9:21: 9:31 +- _6 = discriminant((*_7)); // scope 1 at $DIR/partial.rs:9:21: 9:31 ++ _7 = _2; // scope 1 at $DIR/partial.rs:9:21: 9:31 ++ _6 = discriminant((*_2)); // scope 1 at $DIR/partial.rs:9:21: 9:31 + _11 = _3; // scope 2 at $DIR/partial.rs:9:21: 9:31 + _12 = _6; // scope 2 at $DIR/partial.rs:9:21: 9:31 +- _10 = Eq(move _11, move _12); // scope 2 at $DIR/partial.rs:9:21: 9:31 +- _9 = move _10; // scope 2 at $DIR/partial.rs:9:21: 9:31 +- switchInt(move _9) -> [false: bb2, otherwise: bb1]; // scope 2 at $DIR/partial.rs:9:21: 9:31 ++ _10 = Eq(_11, _12); // scope 2 at $DIR/partial.rs:9:21: 9:31 ++ _9 = _10; // scope 2 at $DIR/partial.rs:9:21: 9:31 ++ switchInt(_10) -> [false: bb2, otherwise: bb1]; // scope 2 at $DIR/partial.rs:9:21: 9:31 + } + + bb1: { + _14 = _1; // scope 2 at $DIR/partial.rs:9:21: 9:31 + _15 = _2; // scope 2 at $DIR/partial.rs:9:21: 9:31 +- (_13.0: &E) = move _14; // scope 2 at $DIR/partial.rs:9:21: 9:31 +- (_13.1: &E) = move _15; // scope 2 at $DIR/partial.rs:9:21: 9:31 ++ (_13.0: &E) = _1; // scope 2 at $DIR/partial.rs:9:21: 9:31 ++ (_13.1: &E) = _2; // scope 2 at $DIR/partial.rs:9:21: 9:31 + discriminant(_16) = 1; // scope 2 at $DIR/partial.rs:9:21: 9:31 + ((_0 as Some).0: std::cmp::Ordering) = const Equal; // scope 2 at $DIR/partial.rs:9:21: 9:31 + // ty::Const + // + ty: std::cmp::Ordering + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/partial.rs:9:21: 9:31 + // + literal: Const { ty: std::cmp::Ordering, val: Value(Scalar(0x00)) } + discriminant(_0) = 1; // scope 2 at $DIR/partial.rs:9:21: 9:31 + goto -> bb3; // scope 2 at $DIR/partial.rs:9:21: 9:31 + } + + bb2: { + _18 = &_3; // scope 2 at $DIR/partial.rs:9:21: 9:31 + _17 = _18; // scope 2 at $DIR/partial.rs:9:21: 9:31 + _20 = &_6; // scope 2 at $DIR/partial.rs:9:21: 9:31 + _19 = _20; // scope 2 at $DIR/partial.rs:9:21: 9:31 + _0 = ::partial_cmp(move _17, move _19) -> bb3; // scope 2 at $DIR/partial.rs:9:21: 9:31 + // mir::Constant + // + span: $DIR/partial.rs:9:21: 9:31 + // + literal: Const { ty: for<'r, 's> fn(&'r isize, &'s isize) -> std::option::Option {::partial_cmp}, val: Value(Scalar()) } + } + + bb3: { + return; // scope 0 at $DIR/partial.rs:9:31: 9:31 + } + } + diff --git a/src/test/mir-opt/partial.{impl#2}-partial_cmp.LowerIntrinsics.diff b/src/test/mir-opt/partial.{impl#2}-partial_cmp.LowerIntrinsics.diff new file mode 100644 index 0000000000000..b43f2666bfda5 --- /dev/null +++ b/src/test/mir-opt/partial.{impl#2}-partial_cmp.LowerIntrinsics.diff @@ -0,0 +1,131 @@ +- // MIR for `::partial_cmp` before LowerIntrinsics ++ // MIR for `::partial_cmp` after LowerIntrinsics + + fn ::partial_cmp(_1: &E, _2: &E) -> Option { + debug self => _1; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + debug other => _2; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _0: std::option::Option; // return place in scope 0 at $DIR/partial.rs:9:21: 9:31 + let _3: isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _4: &E; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let _5: &E; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _7: &E; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let _8: &E; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _9: bool; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _10: bool; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _11: isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _12: isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _13: (&E, &E); // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _14: &E; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _15: &E; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _16: std::cmp::Ordering; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _17: &isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let _18: &isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _19: &isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let _20: &isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + scope 1 { + debug __self_vi => _3; // in scope 1 at $DIR/partial.rs:9:21: 9:31 + let _6: isize; // in scope 1 at $DIR/partial.rs:9:21: 9:31 + scope 2 { + debug __arg_1_vi => _6; // in scope 2 at $DIR/partial.rs:9:21: 9:31 + } + } + + bb0: { + StorageLive(_3); // scope 0 at $DIR/partial.rs:9:21: 9:31 + StorageLive(_4); // scope 0 at $DIR/partial.rs:9:21: 9:31 + StorageLive(_5); // scope 0 at $DIR/partial.rs:9:21: 9:31 + _5 = &(*_1); // scope 0 at $DIR/partial.rs:9:21: 9:31 + _4 = &(*_5); // scope 0 at $DIR/partial.rs:9:21: 9:31 +- _3 = discriminant_value::(move _4) -> bb1; // scope 0 at $DIR/partial.rs:9:21: 9:31 +- // mir::Constant +- // + span: $DIR/partial.rs:9:21: 9:31 +- // + literal: Const { ty: for<'r> extern "rust-intrinsic" fn(&'r E) -> ::Discriminant {std::intrinsics::discriminant_value::}, val: Value(Scalar()) } ++ _3 = discriminant((*_4)); // scope 0 at $DIR/partial.rs:9:21: 9:31 ++ goto -> bb1; // scope 0 at $DIR/partial.rs:9:21: 9:31 + } + + bb1: { + StorageDead(_4); // scope 0 at $DIR/partial.rs:9:30: 9:31 + StorageDead(_5); // scope 0 at $DIR/partial.rs:9:30: 9:31 + StorageLive(_6); // scope 1 at $DIR/partial.rs:9:21: 9:31 + StorageLive(_7); // scope 1 at $DIR/partial.rs:9:21: 9:31 + StorageLive(_8); // scope 1 at $DIR/partial.rs:9:21: 9:31 + _8 = &(*_2); // scope 1 at $DIR/partial.rs:9:21: 9:31 + _7 = &(*_8); // scope 1 at $DIR/partial.rs:9:21: 9:31 +- _6 = discriminant_value::(move _7) -> bb2; // scope 1 at $DIR/partial.rs:9:21: 9:31 +- // mir::Constant +- // + span: $DIR/partial.rs:9:21: 9:31 +- // + literal: Const { ty: for<'r> extern "rust-intrinsic" fn(&'r E) -> ::Discriminant {std::intrinsics::discriminant_value::}, val: Value(Scalar()) } ++ _6 = discriminant((*_7)); // scope 1 at $DIR/partial.rs:9:21: 9:31 ++ goto -> bb2; // scope 1 at $DIR/partial.rs:9:21: 9:31 + } + + bb2: { + StorageDead(_7); // scope 1 at $DIR/partial.rs:9:30: 9:31 + StorageDead(_8); // scope 1 at $DIR/partial.rs:9:30: 9:31 + StorageLive(_9); // scope 2 at $DIR/partial.rs:9:21: 9:31 + StorageLive(_10); // scope 2 at $DIR/partial.rs:9:21: 9:31 + StorageLive(_11); // scope 2 at $DIR/partial.rs:9:21: 9:31 + _11 = _3; // scope 2 at $DIR/partial.rs:9:21: 9:31 + StorageLive(_12); // scope 2 at $DIR/partial.rs:9:21: 9:31 + _12 = _6; // scope 2 at $DIR/partial.rs:9:21: 9:31 + _10 = Eq(move _11, move _12); // scope 2 at $DIR/partial.rs:9:21: 9:31 + StorageDead(_12); // scope 2 at $DIR/partial.rs:9:30: 9:31 + StorageDead(_11); // scope 2 at $DIR/partial.rs:9:30: 9:31 + _9 = move _10; // scope 2 at $DIR/partial.rs:9:21: 9:31 + StorageDead(_10); // scope 2 at $DIR/partial.rs:9:30: 9:31 + switchInt(move _9) -> [false: bb4, otherwise: bb3]; // scope 2 at $DIR/partial.rs:9:21: 9:31 + } + + bb3: { + StorageLive(_13); // scope 2 at $DIR/partial.rs:9:21: 9:31 + StorageLive(_14); // scope 2 at $DIR/partial.rs:9:21: 9:31 + _14 = &(*_1); // scope 2 at $DIR/partial.rs:9:21: 9:31 + StorageLive(_15); // scope 2 at $DIR/partial.rs:9:21: 9:31 + _15 = &(*_2); // scope 2 at $DIR/partial.rs:9:21: 9:31 + _13 = (move _14, move _15); // scope 2 at $DIR/partial.rs:9:21: 9:31 + StorageDead(_15); // scope 2 at $DIR/partial.rs:9:30: 9:31 + StorageDead(_14); // scope 2 at $DIR/partial.rs:9:30: 9:31 + StorageLive(_16); // scope 2 at $DIR/partial.rs:9:21: 9:31 + _16 = Equal; // scope 2 at $DIR/partial.rs:9:21: 9:31 + _0 = Option::::Some(move _16); // scope 2 at $DIR/partial.rs:9:21: 9:31 + StorageDead(_16); // scope 2 at $DIR/partial.rs:9:30: 9:31 + StorageDead(_13); // scope 2 at $DIR/partial.rs:9:30: 9:31 + goto -> bb6; // scope 2 at $DIR/partial.rs:9:21: 9:31 + } + + bb4: { + StorageLive(_17); // scope 2 at $DIR/partial.rs:9:21: 9:31 + StorageLive(_18); // scope 2 at $DIR/partial.rs:9:21: 9:31 + _18 = &_3; // scope 2 at $DIR/partial.rs:9:21: 9:31 + _17 = &(*_18); // scope 2 at $DIR/partial.rs:9:21: 9:31 + StorageLive(_19); // scope 2 at $DIR/partial.rs:9:21: 9:31 + StorageLive(_20); // scope 2 at $DIR/partial.rs:9:21: 9:31 + _20 = &_6; // scope 2 at $DIR/partial.rs:9:21: 9:31 + _19 = &(*_20); // scope 2 at $DIR/partial.rs:9:21: 9:31 + _0 = ::partial_cmp(move _17, move _19) -> bb5; // scope 2 at $DIR/partial.rs:9:21: 9:31 + // mir::Constant + // + span: $DIR/partial.rs:9:21: 9:31 + // + literal: Const { ty: for<'r, 's> fn(&'r isize, &'s isize) -> std::option::Option {::partial_cmp}, val: Value(Scalar()) } + } + + bb5: { + StorageDead(_19); // scope 2 at $DIR/partial.rs:9:30: 9:31 + StorageDead(_17); // scope 2 at $DIR/partial.rs:9:30: 9:31 + StorageDead(_20); // scope 2 at $DIR/partial.rs:9:30: 9:31 + StorageDead(_18); // scope 2 at $DIR/partial.rs:9:30: 9:31 + goto -> bb6; // scope 2 at $DIR/partial.rs:9:21: 9:31 + } + + bb6: { + StorageDead(_9); // scope 2 at $DIR/partial.rs:9:30: 9:31 + StorageDead(_6); // scope 1 at $DIR/partial.rs:9:30: 9:31 + StorageDead(_3); // scope 0 at $DIR/partial.rs:9:30: 9:31 + return; // scope 0 at $DIR/partial.rs:9:31: 9:31 + } + + bb7 (cleanup): { + resume; // scope 0 at $DIR/partial.rs:9:21: 9:31 + } + } + diff --git a/src/test/mir-opt/partial.{impl#2}-partial_cmp.PreCodegen.before.mir b/src/test/mir-opt/partial.{impl#2}-partial_cmp.PreCodegen.before.mir new file mode 100644 index 0000000000000..001822640d3dd --- /dev/null +++ b/src/test/mir-opt/partial.{impl#2}-partial_cmp.PreCodegen.before.mir @@ -0,0 +1,58 @@ +// MIR for `::partial_cmp` before PreCodegen + +fn ::partial_cmp(_1: &E, _2: &E) -> Option { + debug self => _1; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + debug other => _2; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _0: std::option::Option; // return place in scope 0 at $DIR/partial.rs:9:21: 9:31 + let _3: isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _5: bool; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _6: isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _7: isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _8: &isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let _9: &isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let mut _10: &isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + let _11: &isize; // in scope 0 at $DIR/partial.rs:9:21: 9:31 + scope 1 { + debug __self_vi => _3; // in scope 1 at $DIR/partial.rs:9:21: 9:31 + let _4: isize; // in scope 1 at $DIR/partial.rs:9:21: 9:31 + scope 2 { + debug __arg_1_vi => _4; // in scope 2 at $DIR/partial.rs:9:21: 9:31 + } + } + + bb0: { + _3 = discriminant((*_1)); // scope 0 at $DIR/partial.rs:9:21: 9:31 + _4 = discriminant((*_2)); // scope 1 at $DIR/partial.rs:9:21: 9:31 + _6 = _3; // scope 2 at $DIR/partial.rs:9:21: 9:31 + _7 = _4; // scope 2 at $DIR/partial.rs:9:21: 9:31 + _5 = Eq(_6, _7); // scope 2 at $DIR/partial.rs:9:21: 9:31 + switchInt(_5) -> [false: bb2, otherwise: bb1]; // scope 2 at $DIR/partial.rs:9:21: 9:31 + } + + bb1: { + ((_0 as Some).0: std::cmp::Ordering) = const Equal; // scope 2 at $DIR/partial.rs:9:21: 9:31 + // ty::Const + // + ty: std::cmp::Ordering + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/partial.rs:9:21: 9:31 + // + literal: Const { ty: std::cmp::Ordering, val: Value(Scalar(0x00)) } + discriminant(_0) = 1; // scope 2 at $DIR/partial.rs:9:21: 9:31 + goto -> bb3; // scope 2 at $DIR/partial.rs:9:21: 9:31 + } + + bb2: { + _9 = &_3; // scope 2 at $DIR/partial.rs:9:21: 9:31 + _8 = _9; // scope 2 at $DIR/partial.rs:9:21: 9:31 + _11 = &_4; // scope 2 at $DIR/partial.rs:9:21: 9:31 + _10 = _11; // scope 2 at $DIR/partial.rs:9:21: 9:31 + _0 = ::partial_cmp(move _8, move _10) -> bb3; // scope 2 at $DIR/partial.rs:9:21: 9:31 + // mir::Constant + // + span: $DIR/partial.rs:9:21: 9:31 + // + literal: Const { ty: for<'r, 's> fn(&'r isize, &'s isize) -> std::option::Option {::partial_cmp}, val: Value(Scalar()) } + } + + bb3: { + return; // scope 0 at $DIR/partial.rs:9:31: 9:31 + } +} diff --git a/src/test/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff b/src/test/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff index 80024124dc523..c6c225d998912 100644 --- a/src/test/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff +++ b/src/test/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff @@ -50,7 +50,7 @@ - StorageLive(_3); // scope 1 at $DIR/remove_storage_markers.rs:8:14: 8:19 (_3.0: i32) = const 0_i32; // scope 1 at $DIR/remove_storage_markers.rs:8:14: 8:19 (_3.1: i32) = const 10_i32; // scope 1 at $DIR/remove_storage_markers.rs:8:14: 8:19 - _2 = move _3; // scope 6 at $DIR/remove_storage_markers.rs:8:14: 8:19 + _2 = _3; // scope 6 at $DIR/remove_storage_markers.rs:8:14: 8:19 - StorageDead(_3); // scope 1 at $DIR/remove_storage_markers.rs:8:18: 8:19 - StorageLive(_4); // scope 1 at $DIR/remove_storage_markers.rs:8:14: 8:19 _4 = move _2; // scope 1 at $DIR/remove_storage_markers.rs:8:14: 8:19 diff --git a/src/test/mir-opt/separate_const_switch.identity.ConstProp.diff b/src/test/mir-opt/separate_const_switch.identity.ConstProp.diff index 57299cee7b726..e85dc52cf0a37 100644 --- a/src/test/mir-opt/separate_const_switch.identity.ConstProp.diff +++ b/src/test/mir-opt/separate_const_switch.identity.ConstProp.diff @@ -17,13 +17,13 @@ scope 2 { scope 8 (inlined as FromResidual>>::from_residual) { // at $DIR/separate_const_switch.rs:29:8: 29:10 debug residual => _8; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 - let _16: i32; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 - let mut _17: i32; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 - let mut _18: i32; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 + let _14: i32; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 + let mut _15: i32; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 + let mut _16: i32; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 scope 9 { - debug e => _16; // in scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + debug e => _14; // in scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 scope 10 (inlined >::from) { // at $DIR/separate_const_switch.rs:29:8: 29:10 - debug t => _18; // in scope 10 at $DIR/separate_const_switch.rs:29:8: 29:10 + debug t => _16; // in scope 10 at $DIR/separate_const_switch.rs:29:8: 29:10 } } } @@ -38,15 +38,13 @@ debug self => _4; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 let mut _10: isize; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 let _11: i32; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - let mut _12: i32; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - let _13: i32; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - let mut _14: std::result::Result; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - let mut _15: i32; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + let _12: i32; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + let mut _13: std::result::Result; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 scope 6 { debug v => _11; // in scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 } scope 7 { - debug e => _13; // in scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + debug e => _12; // in scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 } } @@ -57,7 +55,7 @@ _4 = _1; // scope 0 at $DIR/separate_const_switch.rs:29:8: 29:9 StorageLive(_10); // scope 0 at $DIR/separate_const_switch.rs:29:8: 29:10 _10 = discriminant(_4); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - switchInt(move _10) -> [0_isize: bb5, 1_isize: bb3, otherwise: bb4]; // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + switchInt(_10) -> [0_isize: bb5, 1_isize: bb3, otherwise: bb4]; // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 } bb1: { @@ -77,17 +75,17 @@ _6 = ((_3 as Break).0: std::result::Result); // scope 0 at $DIR/separate_const_switch.rs:29:9: 29:10 StorageLive(_8); // scope 2 at $DIR/separate_const_switch.rs:29:9: 29:10 _8 = _6; // scope 2 at $DIR/separate_const_switch.rs:29:9: 29:10 - StorageLive(_16); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 - _16 = move ((_8 as Err).0: i32); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageLive(_17); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageLive(_18); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - _18 = move _16; // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - _17 = move _18; // scope 10 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_18); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - ((_0 as Err).0: i32) = move _17; // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageLive(_14); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 + _14 = ((_8 as Err).0: i32); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageLive(_15); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageLive(_16); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + _16 = _14; // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + _15 = _16; // scope 10 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageDead(_16); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + ((_0 as Err).0: i32) = _15; // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 discriminant(_0) = 1; // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_17); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_16); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageDead(_15); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageDead(_14); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 StorageDead(_8); // scope 2 at $DIR/separate_const_switch.rs:29:9: 29:10 StorageDead(_6); // scope 0 at $DIR/separate_const_switch.rs:29:9: 29:10 StorageDead(_2); // scope 0 at $DIR/separate_const_switch.rs:29:10: 29:11 @@ -96,18 +94,15 @@ } bb3: { - StorageLive(_13); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - _13 = move ((_4 as Err).0: i32); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageLive(_14); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageLive(_15); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - _15 = move _13; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - ((_14 as Err).0: i32) = move _15; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - discriminant(_14) = 1; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_15); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - ((_3 as Break).0: std::result::Result) = move _14; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageLive(_12); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + _12 = ((_4 as Err).0: i32); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageLive(_13); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + ((_13 as Err).0: i32) = _12; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + discriminant(_13) = 1; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + ((_3 as Break).0: std::result::Result) = _13; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 discriminant(_3) = 1; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_14); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_13); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageDead(_13); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageDead(_12); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 StorageDead(_10); // scope 0 at $DIR/separate_const_switch.rs:29:8: 29:10 StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:29:9: 29:10 - _5 = discriminant(_3); // scope 0 at $DIR/separate_const_switch.rs:29:9: 29:10 @@ -122,12 +117,9 @@ bb5: { StorageLive(_11); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - _11 = move ((_4 as Ok).0: i32); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageLive(_12); // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 - _12 = move _11; // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 - ((_3 as Continue).0: i32) = move _12; // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 + _11 = ((_4 as Ok).0: i32); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + ((_3 as Continue).0: i32) = _11; // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 discriminant(_3) = 0; // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_12); // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 StorageDead(_11); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 StorageDead(_10); // scope 0 at $DIR/separate_const_switch.rs:29:8: 29:10 StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:29:9: 29:10 diff --git a/src/test/mir-opt/separate_const_switch.identity.PreCodegen.after.mir b/src/test/mir-opt/separate_const_switch.identity.PreCodegen.after.mir index dee45c5840383..7615f3399a2ee 100644 --- a/src/test/mir-opt/separate_const_switch.identity.PreCodegen.after.mir +++ b/src/test/mir-opt/separate_const_switch.identity.PreCodegen.after.mir @@ -14,13 +14,12 @@ fn identity(_1: Result) -> Result { scope 2 { scope 8 (inlined as FromResidual>>::from_residual) { // at $DIR/separate_const_switch.rs:29:8: 29:10 debug residual => _6; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 - let _14: i32; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 - let mut _15: i32; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 - let mut _16: i32; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 + let _12: i32; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 + let mut _13: i32; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 scope 9 { - debug e => _14; // in scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + debug e => _12; // in scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 scope 10 (inlined >::from) { // at $DIR/separate_const_switch.rs:29:8: 29:10 - debug t => _16; // in scope 10 at $DIR/separate_const_switch.rs:29:8: 29:10 + debug t => _13; // in scope 10 at $DIR/separate_const_switch.rs:29:8: 29:10 } } } @@ -35,15 +34,13 @@ fn identity(_1: Result) -> Result { debug self => _4; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 let mut _8: isize; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 let _9: i32; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - let mut _10: i32; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - let _11: i32; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - let mut _12: std::result::Result; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - let mut _13: i32; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + let _10: i32; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + let mut _11: std::result::Result; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 scope 6 { debug v => _9; // in scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 } scope 7 { - debug e => _11; // in scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + debug e => _10; // in scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 } } @@ -53,40 +50,34 @@ fn identity(_1: Result) -> Result { StorageLive(_4); // scope 0 at $DIR/separate_const_switch.rs:29:8: 29:9 _4 = _1; // scope 0 at $DIR/separate_const_switch.rs:29:8: 29:9 StorageLive(_8); // scope 0 at $DIR/separate_const_switch.rs:29:8: 29:10 - _8 = discriminant(_4); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - switchInt(move _8) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + _8 = discriminant(_1); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + switchInt(_8) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 } bb1: { - StorageLive(_11); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - _11 = move ((_4 as Err).0: i32); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageLive(_12); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageLive(_13); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - _13 = move _11; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - ((_12 as Err).0: i32) = move _13; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - discriminant(_12) = 1; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_13); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - ((_3 as Break).0: std::result::Result) = move _12; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageLive(_10); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + _10 = ((_4 as Err).0: i32); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageLive(_11); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + ((_11 as Err).0: i32) = _10; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + discriminant(_11) = 1; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + ((_3 as Break).0: std::result::Result) = _11; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 discriminant(_3) = 1; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_12); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_11); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageDead(_11); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageDead(_10); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 StorageDead(_8); // scope 0 at $DIR/separate_const_switch.rs:29:8: 29:10 StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:29:9: 29:10 StorageLive(_5); // scope 0 at $DIR/separate_const_switch.rs:29:9: 29:10 _5 = ((_3 as Break).0: std::result::Result); // scope 0 at $DIR/separate_const_switch.rs:29:9: 29:10 StorageLive(_6); // scope 2 at $DIR/separate_const_switch.rs:29:9: 29:10 _6 = _5; // scope 2 at $DIR/separate_const_switch.rs:29:9: 29:10 - StorageLive(_14); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 - _14 = move ((_6 as Err).0: i32); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageLive(_15); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageLive(_16); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - _16 = move _14; // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - _15 = move _16; // scope 10 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_16); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - ((_0 as Err).0: i32) = move _15; // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageLive(_12); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 + _12 = ((_5 as Err).0: i32); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageLive(_13); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + _13 = _12; // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageDead(_13); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + ((_0 as Err).0: i32) = _12; // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 discriminant(_0) = 1; // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_15); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_14); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageDead(_12); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 StorageDead(_6); // scope 2 at $DIR/separate_const_switch.rs:29:9: 29:10 StorageDead(_5); // scope 0 at $DIR/separate_const_switch.rs:29:9: 29:10 StorageDead(_2); // scope 0 at $DIR/separate_const_switch.rs:29:10: 29:11 @@ -100,12 +91,9 @@ fn identity(_1: Result) -> Result { bb3: { StorageLive(_9); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - _9 = move ((_4 as Ok).0: i32); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageLive(_10); // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 - _10 = move _9; // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 - ((_3 as Continue).0: i32) = move _10; // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 + _9 = ((_4 as Ok).0: i32); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + ((_3 as Continue).0: i32) = _9; // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 discriminant(_3) = 0; // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_10); // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 StorageDead(_9); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 StorageDead(_8); // scope 0 at $DIR/separate_const_switch.rs:29:8: 29:10 StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:29:9: 29:10 @@ -113,7 +101,7 @@ fn identity(_1: Result) -> Result { _7 = ((_3 as Continue).0: i32); // scope 0 at $DIR/separate_const_switch.rs:29:8: 29:10 _2 = _7; // scope 4 at $DIR/separate_const_switch.rs:29:8: 29:10 StorageDead(_7); // scope 0 at $DIR/separate_const_switch.rs:29:9: 29:10 - ((_0 as Ok).0: i32) = move _2; // scope 0 at $DIR/separate_const_switch.rs:29:5: 29:11 + ((_0 as Ok).0: i32) = _2; // scope 0 at $DIR/separate_const_switch.rs:29:5: 29:11 discriminant(_0) = 0; // scope 0 at $DIR/separate_const_switch.rs:29:5: 29:11 StorageDead(_2); // scope 0 at $DIR/separate_const_switch.rs:29:10: 29:11 StorageDead(_3); // scope 0 at $DIR/separate_const_switch.rs:30:1: 30:2 diff --git a/src/test/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff b/src/test/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff index 4bfd0842db084..8ad27dcf9f4aa 100644 --- a/src/test/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff +++ b/src/test/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff @@ -17,13 +17,13 @@ scope 2 { scope 8 (inlined as FromResidual>>::from_residual) { // at $DIR/separate_const_switch.rs:29:8: 29:10 debug residual => _8; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 - let _16: i32; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 - let mut _17: i32; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 - let mut _18: i32; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 + let _14: i32; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 + let mut _15: i32; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 + let mut _16: i32; // in scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 scope 9 { - debug e => _16; // in scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + debug e => _14; // in scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 scope 10 (inlined >::from) { // at $DIR/separate_const_switch.rs:29:8: 29:10 - debug t => _18; // in scope 10 at $DIR/separate_const_switch.rs:29:8: 29:10 + debug t => _16; // in scope 10 at $DIR/separate_const_switch.rs:29:8: 29:10 } } } @@ -38,15 +38,13 @@ debug self => _4; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 let mut _10: isize; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 let _11: i32; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - let mut _12: i32; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - let _13: i32; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - let mut _14: std::result::Result; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - let mut _15: i32; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + let _12: i32; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + let mut _13: std::result::Result; // in scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 scope 6 { debug v => _11; // in scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 } scope 7 { - debug e => _13; // in scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + debug e => _12; // in scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 } } @@ -57,8 +55,8 @@ _4 = _1; // scope 0 at $DIR/separate_const_switch.rs:29:8: 29:9 StorageLive(_10); // scope 0 at $DIR/separate_const_switch.rs:29:8: 29:10 _10 = discriminant(_4); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 -- switchInt(move _10) -> [0_isize: bb6, 1_isize: bb4, otherwise: bb5]; // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 -+ switchInt(move _10) -> [0_isize: bb5, 1_isize: bb3, otherwise: bb4]; // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 +- switchInt(_10) -> [0_isize: bb6, 1_isize: bb4, otherwise: bb5]; // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 ++ switchInt(_10) -> [0_isize: bb5, 1_isize: bb3, otherwise: bb4]; // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 } bb1: { @@ -86,17 +84,17 @@ _6 = ((_3 as Break).0: std::result::Result); // scope 0 at $DIR/separate_const_switch.rs:29:9: 29:10 StorageLive(_8); // scope 2 at $DIR/separate_const_switch.rs:29:9: 29:10 _8 = _6; // scope 2 at $DIR/separate_const_switch.rs:29:9: 29:10 - StorageLive(_16); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 - _16 = move ((_8 as Err).0: i32); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageLive(_17); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageLive(_18); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - _18 = move _16; // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - _17 = move _18; // scope 10 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_18); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - ((_0 as Err).0: i32) = move _17; // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageLive(_14); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 + _14 = ((_8 as Err).0: i32); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageLive(_15); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageLive(_16); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + _16 = _14; // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + _15 = _16; // scope 10 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageDead(_16); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + ((_0 as Err).0: i32) = _15; // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 discriminant(_0) = 1; // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_17); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_16); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageDead(_15); // scope 9 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageDead(_14); // scope 8 at $DIR/separate_const_switch.rs:29:8: 29:10 StorageDead(_8); // scope 2 at $DIR/separate_const_switch.rs:29:9: 29:10 StorageDead(_6); // scope 0 at $DIR/separate_const_switch.rs:29:9: 29:10 StorageDead(_2); // scope 0 at $DIR/separate_const_switch.rs:29:10: 29:11 @@ -106,18 +104,15 @@ - bb4: { + bb3: { - StorageLive(_13); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - _13 = move ((_4 as Err).0: i32); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageLive(_14); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageLive(_15); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - _15 = move _13; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - ((_14 as Err).0: i32) = move _15; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - discriminant(_14) = 1; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_15); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - ((_3 as Break).0: std::result::Result) = move _14; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageLive(_12); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + _12 = ((_4 as Err).0: i32); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageLive(_13); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + ((_13 as Err).0: i32) = _12; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + discriminant(_13) = 1; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + ((_3 as Break).0: std::result::Result) = _13; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 discriminant(_3) = 1; // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_14); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_13); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageDead(_13); // scope 7 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageDead(_12); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - goto -> bb1; // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageDead(_10); // scope 0 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:29:9: 29:10 @@ -133,12 +128,9 @@ - bb6: { + bb5: { StorageLive(_11); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - _11 = move ((_4 as Ok).0: i32); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageLive(_12); // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 - _12 = move _11; // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 - ((_3 as Continue).0: i32) = move _12; // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 + _11 = ((_4 as Ok).0: i32); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + ((_3 as Continue).0: i32) = _11; // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 discriminant(_3) = 0; // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 - StorageDead(_12); // scope 6 at $DIR/separate_const_switch.rs:29:8: 29:10 StorageDead(_11); // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 - goto -> bb1; // scope 5 at $DIR/separate_const_switch.rs:29:8: 29:10 + StorageDead(_10); // scope 0 at $DIR/separate_const_switch.rs:29:8: 29:10 diff --git a/src/test/mir-opt/separate_const_switch.too_complex.PreCodegen.after.mir b/src/test/mir-opt/separate_const_switch.too_complex.PreCodegen.after.mir index cc941f251cea5..5af5b451298cb 100644 --- a/src/test/mir-opt/separate_const_switch.too_complex.PreCodegen.after.mir +++ b/src/test/mir-opt/separate_const_switch.too_complex.PreCodegen.after.mir @@ -6,64 +6,52 @@ fn too_complex(_1: Result) -> Option { let mut _2: std::ops::ControlFlow; // in scope 0 at $DIR/separate_const_switch.rs:14:11: 19:6 let mut _3: isize; // in scope 0 at $DIR/separate_const_switch.rs:16:13: 16:18 let _4: i32; // in scope 0 at $DIR/separate_const_switch.rs:16:16: 16:17 - let mut _5: i32; // in scope 0 at $DIR/separate_const_switch.rs:16:44: 16:45 - let _6: usize; // in scope 0 at $DIR/separate_const_switch.rs:17:17: 17:18 - let mut _7: usize; // in scope 0 at $DIR/separate_const_switch.rs:17:42: 17:43 - let _8: i32; // in scope 0 at $DIR/separate_const_switch.rs:20:31: 20:32 - let mut _9: i32; // in scope 0 at $DIR/separate_const_switch.rs:20:42: 20:43 - let _10: usize; // in scope 0 at $DIR/separate_const_switch.rs:21:28: 21:29 + let _5: usize; // in scope 0 at $DIR/separate_const_switch.rs:17:17: 17:18 + let _6: i32; // in scope 0 at $DIR/separate_const_switch.rs:20:31: 20:32 + let _7: usize; // in scope 0 at $DIR/separate_const_switch.rs:21:28: 21:29 scope 1 { debug v => _4; // in scope 1 at $DIR/separate_const_switch.rs:16:16: 16:17 } scope 2 { - debug r => _6; // in scope 2 at $DIR/separate_const_switch.rs:17:17: 17:18 + debug r => _5; // in scope 2 at $DIR/separate_const_switch.rs:17:17: 17:18 } scope 3 { - debug v => _8; // in scope 3 at $DIR/separate_const_switch.rs:20:31: 20:32 + debug v => _6; // in scope 3 at $DIR/separate_const_switch.rs:20:31: 20:32 } scope 4 { - debug r => _10; // in scope 4 at $DIR/separate_const_switch.rs:21:28: 21:29 + debug r => _7; // in scope 4 at $DIR/separate_const_switch.rs:21:28: 21:29 } bb0: { StorageLive(_2); // scope 0 at $DIR/separate_const_switch.rs:14:11: 19:6 _3 = discriminant(_1); // scope 0 at $DIR/separate_const_switch.rs:16:13: 16:18 - switchInt(move _3) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/separate_const_switch.rs:16:13: 16:18 + switchInt(_3) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/separate_const_switch.rs:16:13: 16:18 } bb1: { - StorageLive(_6); // scope 0 at $DIR/separate_const_switch.rs:17:17: 17:18 - _6 = ((_1 as Err).0: usize); // scope 0 at $DIR/separate_const_switch.rs:17:17: 17:18 - StorageLive(_7); // scope 2 at $DIR/separate_const_switch.rs:17:42: 17:43 - _7 = _6; // scope 2 at $DIR/separate_const_switch.rs:17:42: 17:43 - ((_2 as Break).0: usize) = move _7; // scope 2 at $DIR/separate_const_switch.rs:17:23: 17:44 + StorageLive(_5); // scope 0 at $DIR/separate_const_switch.rs:17:17: 17:18 + _5 = ((_1 as Err).0: usize); // scope 0 at $DIR/separate_const_switch.rs:17:17: 17:18 + ((_2 as Break).0: usize) = _5; // scope 2 at $DIR/separate_const_switch.rs:17:23: 17:44 discriminant(_2) = 1; // scope 2 at $DIR/separate_const_switch.rs:17:23: 17:44 - StorageDead(_7); // scope 2 at $DIR/separate_const_switch.rs:17:43: 17:44 - StorageDead(_6); // scope 0 at $DIR/separate_const_switch.rs:17:43: 17:44 - StorageLive(_10); // scope 0 at $DIR/separate_const_switch.rs:21:28: 21:29 - _10 = ((_2 as Break).0: usize); // scope 0 at $DIR/separate_const_switch.rs:21:28: 21:29 + StorageDead(_5); // scope 0 at $DIR/separate_const_switch.rs:17:43: 17:44 + StorageLive(_7); // scope 0 at $DIR/separate_const_switch.rs:21:28: 21:29 + _7 = ((_2 as Break).0: usize); // scope 0 at $DIR/separate_const_switch.rs:21:28: 21:29 discriminant(_0) = 0; // scope 4 at $DIR/separate_const_switch.rs:21:34: 21:38 - StorageDead(_10); // scope 0 at $DIR/separate_const_switch.rs:21:37: 21:38 + StorageDead(_7); // scope 0 at $DIR/separate_const_switch.rs:21:37: 21:38 goto -> bb3; // scope 0 at $DIR/separate_const_switch.rs:14:5: 22:6 } bb2: { StorageLive(_4); // scope 0 at $DIR/separate_const_switch.rs:16:16: 16:17 _4 = ((_1 as Ok).0: i32); // scope 0 at $DIR/separate_const_switch.rs:16:16: 16:17 - StorageLive(_5); // scope 1 at $DIR/separate_const_switch.rs:16:44: 16:45 - _5 = _4; // scope 1 at $DIR/separate_const_switch.rs:16:44: 16:45 - ((_2 as Continue).0: i32) = move _5; // scope 1 at $DIR/separate_const_switch.rs:16:22: 16:46 + ((_2 as Continue).0: i32) = _4; // scope 1 at $DIR/separate_const_switch.rs:16:22: 16:46 discriminant(_2) = 0; // scope 1 at $DIR/separate_const_switch.rs:16:22: 16:46 - StorageDead(_5); // scope 1 at $DIR/separate_const_switch.rs:16:45: 16:46 StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:16:45: 16:46 - StorageLive(_8); // scope 0 at $DIR/separate_const_switch.rs:20:31: 20:32 - _8 = ((_2 as Continue).0: i32); // scope 0 at $DIR/separate_const_switch.rs:20:31: 20:32 - StorageLive(_9); // scope 3 at $DIR/separate_const_switch.rs:20:42: 20:43 - _9 = _8; // scope 3 at $DIR/separate_const_switch.rs:20:42: 20:43 - ((_0 as Some).0: i32) = move _9; // scope 3 at $DIR/separate_const_switch.rs:20:37: 20:44 + StorageLive(_6); // scope 0 at $DIR/separate_const_switch.rs:20:31: 20:32 + _6 = ((_2 as Continue).0: i32); // scope 0 at $DIR/separate_const_switch.rs:20:31: 20:32 + ((_0 as Some).0: i32) = _6; // scope 3 at $DIR/separate_const_switch.rs:20:37: 20:44 discriminant(_0) = 1; // scope 3 at $DIR/separate_const_switch.rs:20:37: 20:44 - StorageDead(_9); // scope 3 at $DIR/separate_const_switch.rs:20:43: 20:44 - StorageDead(_8); // scope 0 at $DIR/separate_const_switch.rs:20:43: 20:44 + StorageDead(_6); // scope 0 at $DIR/separate_const_switch.rs:20:43: 20:44 goto -> bb3; // scope 0 at $DIR/separate_const_switch.rs:14:5: 22:6 } diff --git a/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff index a3bad4f0c623d..b6125a27f7778 100644 --- a/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff @@ -19,15 +19,12 @@ + debug x => ((_0 as Ok).0: u8); // in scope 1 at $DIR/simplify-arm.rs:36:9: 36:10 } scope 2 { -- debug e => _6; // in scope 2 at $DIR/simplify-arm.rs:37:13: 37:14 -+ debug e => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify-arm.rs:37:13: 37:14 + debug e => _6; // in scope 2 at $DIR/simplify-arm.rs:37:13: 37:14 scope 5 (inlined >::from) { // at $DIR/simplify-arm.rs:37:37: 37:50 -- debug t => _9; // in scope 5 at $DIR/simplify-arm.rs:37:37: 37:50 -+ debug t => ((_0 as Err).0: i32); // in scope 5 at $DIR/simplify-arm.rs:37:37: 37:50 + debug t => _9; // in scope 5 at $DIR/simplify-arm.rs:37:37: 37:50 } scope 6 (inlined from_error::) { // at $DIR/simplify-arm.rs:37:26: 37:51 -- debug e => _8; // in scope 6 at $DIR/simplify-arm.rs:37:26: 37:51 -+ debug e => ((_0 as Err).0: i32); // in scope 6 at $DIR/simplify-arm.rs:37:26: 37:51 + debug e => _8; // in scope 6 at $DIR/simplify-arm.rs:37:26: 37:51 } } scope 3 { @@ -43,7 +40,7 @@ StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:36:19: 36:33 StorageLive(_4); // scope 0 at $DIR/simplify-arm.rs:36:31: 36:32 _4 = _1; // scope 0 at $DIR/simplify-arm.rs:36:31: 36:32 - _3 = move _4; // scope 4 at $DIR/simplify-arm.rs:36:19: 36:33 + _3 = _4; // scope 4 at $DIR/simplify-arm.rs:36:19: 36:33 StorageDead(_4); // scope 0 at $DIR/simplify-arm.rs:36:32: 36:33 _5 = discriminant(_3); // scope 0 at $DIR/simplify-arm.rs:37:9: 37:15 switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:37:9: 37:15 @@ -70,18 +67,17 @@ } bb3: { -- StorageLive(_6); // scope 0 at $DIR/simplify-arm.rs:37:13: 37:14 -- _6 = ((_3 as Err).0: i32); // scope 0 at $DIR/simplify-arm.rs:37:13: 37:14 -- StorageLive(_8); // scope 2 at $DIR/simplify-arm.rs:37:37: 37:50 -- StorageLive(_9); // scope 2 at $DIR/simplify-arm.rs:37:48: 37:49 -- _9 = _6; // scope 2 at $DIR/simplify-arm.rs:37:48: 37:49 -- _8 = move _9; // scope 5 at $DIR/simplify-arm.rs:37:37: 37:50 -- StorageDead(_9); // scope 2 at $DIR/simplify-arm.rs:37:49: 37:50 -- ((_0 as Err).0: i32) = move _8; // scope 6 at $DIR/simplify-arm.rs:37:26: 37:51 -- discriminant(_0) = 1; // scope 6 at $DIR/simplify-arm.rs:37:26: 37:51 -- StorageDead(_8); // scope 2 at $DIR/simplify-arm.rs:37:50: 37:51 -- StorageDead(_6); // scope 0 at $DIR/simplify-arm.rs:37:50: 37:51 -+ _0 = move _3; // scope 6 at $DIR/simplify-arm.rs:37:26: 37:51 + StorageLive(_6); // scope 0 at $DIR/simplify-arm.rs:37:13: 37:14 + _6 = ((_3 as Err).0: i32); // scope 0 at $DIR/simplify-arm.rs:37:13: 37:14 + StorageLive(_8); // scope 2 at $DIR/simplify-arm.rs:37:37: 37:50 + StorageLive(_9); // scope 2 at $DIR/simplify-arm.rs:37:48: 37:49 + _9 = _6; // scope 2 at $DIR/simplify-arm.rs:37:48: 37:49 + _8 = _9; // scope 5 at $DIR/simplify-arm.rs:37:37: 37:50 + StorageDead(_9); // scope 2 at $DIR/simplify-arm.rs:37:49: 37:50 + ((_0 as Err).0: i32) = _8; // scope 6 at $DIR/simplify-arm.rs:37:26: 37:51 + discriminant(_0) = 1; // scope 6 at $DIR/simplify-arm.rs:37:26: 37:51 + StorageDead(_8); // scope 2 at $DIR/simplify-arm.rs:37:50: 37:51 + StorageDead(_6); // scope 0 at $DIR/simplify-arm.rs:37:50: 37:51 StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:39:6: 39:7 StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:41:1: 41:2 goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:41:2: 41:2 diff --git a/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff b/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff index b6b7511b3f597..94c8613ca982f 100644 --- a/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff +++ b/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff @@ -18,12 +18,12 @@ debug x => ((_0 as Ok).0: u8); // in scope 1 at $DIR/simplify-arm.rs:36:9: 36:10 } scope 2 { - debug e => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify-arm.rs:37:13: 37:14 + debug e => _6; // in scope 2 at $DIR/simplify-arm.rs:37:13: 37:14 scope 5 (inlined >::from) { // at $DIR/simplify-arm.rs:37:37: 37:50 - debug t => ((_0 as Err).0: i32); // in scope 5 at $DIR/simplify-arm.rs:37:37: 37:50 + debug t => _9; // in scope 5 at $DIR/simplify-arm.rs:37:37: 37:50 } scope 6 (inlined from_error::) { // at $DIR/simplify-arm.rs:37:26: 37:51 - debug e => ((_0 as Err).0: i32); // in scope 6 at $DIR/simplify-arm.rs:37:26: 37:51 + debug e => _8; // in scope 6 at $DIR/simplify-arm.rs:37:26: 37:51 } } scope 3 { @@ -38,33 +38,41 @@ StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:36:19: 36:33 StorageLive(_4); // scope 0 at $DIR/simplify-arm.rs:36:31: 36:32 _4 = _1; // scope 0 at $DIR/simplify-arm.rs:36:31: 36:32 - _3 = move _4; // scope 4 at $DIR/simplify-arm.rs:36:19: 36:33 + _3 = _4; // scope 4 at $DIR/simplify-arm.rs:36:19: 36:33 StorageDead(_4); // scope 0 at $DIR/simplify-arm.rs:36:32: 36:33 _5 = discriminant(_3); // scope 0 at $DIR/simplify-arm.rs:37:9: 37:15 -- switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:37:9: 37:15 -+ goto -> bb1; // scope 0 at $DIR/simplify-arm.rs:37:9: 37:15 + switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:37:9: 37:15 } bb1: { _0 = move _3; // scope 1 at $DIR/simplify-arm.rs:40:5: 40:10 StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:39:6: 39:7 StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:41:1: 41:2 -- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:41:2: 41:2 -+ goto -> bb2; // scope 0 at $DIR/simplify-arm.rs:41:2: 41:2 + goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:41:2: 41:2 } bb2: { -- unreachable; // scope 0 at $DIR/simplify-arm.rs:36:19: 36:33 -- } -- -- bb3: { -- _0 = move _3; // scope 6 at $DIR/simplify-arm.rs:37:26: 37:51 -- StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:39:6: 39:7 -- StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:41:1: 41:2 -- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:41:2: 41:2 -- } -- -- bb4: { + unreachable; // scope 0 at $DIR/simplify-arm.rs:36:19: 36:33 + } + + bb3: { + StorageLive(_6); // scope 0 at $DIR/simplify-arm.rs:37:13: 37:14 + _6 = ((_3 as Err).0: i32); // scope 0 at $DIR/simplify-arm.rs:37:13: 37:14 + StorageLive(_8); // scope 2 at $DIR/simplify-arm.rs:37:37: 37:50 + StorageLive(_9); // scope 2 at $DIR/simplify-arm.rs:37:48: 37:49 + _9 = _6; // scope 2 at $DIR/simplify-arm.rs:37:48: 37:49 + _8 = _9; // scope 5 at $DIR/simplify-arm.rs:37:37: 37:50 + StorageDead(_9); // scope 2 at $DIR/simplify-arm.rs:37:49: 37:50 + ((_0 as Err).0: i32) = _8; // scope 6 at $DIR/simplify-arm.rs:37:26: 37:51 + discriminant(_0) = 1; // scope 6 at $DIR/simplify-arm.rs:37:26: 37:51 + StorageDead(_8); // scope 2 at $DIR/simplify-arm.rs:37:50: 37:51 + StorageDead(_6); // scope 0 at $DIR/simplify-arm.rs:37:50: 37:51 + StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:39:6: 39:7 + StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:41:1: 41:2 + goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:41:2: 41:2 + } + + bb4: { return; // scope 0 at $DIR/simplify-arm.rs:41:2: 41:2 } } diff --git a/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff index 2995d1e86e3bf..4806e2de24b6b 100644 --- a/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff @@ -21,7 +21,7 @@ - StorageLive(_4); // scope 1 at $DIR/simplify-locals.rs:16:20: 16:26 - _4 = &_1; // scope 1 at $DIR/simplify-locals.rs:16:20: 16:26 - _3 = _4; // scope 1 at $DIR/simplify-locals.rs:16:20: 16:26 -- _2 = move _3 as &[u8] (Pointer(Unsize)); // scope 1 at $DIR/simplify-locals.rs:16:20: 16:26 +- _2 = _4 as &[u8] (Pointer(Unsize)); // scope 1 at $DIR/simplify-locals.rs:16:20: 16:26 - 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 diff --git a/src/test/mir-opt/simplify_locals.t4.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.t4.SimplifyLocals.diff index e0e9b3ef4062a..93c6cfc73e278 100644 --- a/src/test/mir-opt/simplify_locals.t4.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.t4.SimplifyLocals.diff @@ -13,7 +13,7 @@ StorageLive(_2); // scope 1 at $DIR/simplify-locals.rs:62:14: 62:15 _2 = &/*tls*/ mut X; // scope 1 at $DIR/simplify-locals.rs:62:14: 62:15 _1 = (*_2); // scope 1 at $DIR/simplify-locals.rs:62:14: 62:15 - _0 = Add(move _1, const 1_u32); // scope 1 at $DIR/simplify-locals.rs:62:14: 62:19 + _0 = Add(_1, const 1_u32); // scope 1 at $DIR/simplify-locals.rs:62:14: 62:19 StorageDead(_1); // scope 1 at $DIR/simplify-locals.rs:62:18: 62:19 StorageDead(_2); // scope 0 at $DIR/simplify-locals.rs:63:1: 63:2 return; // scope 0 at $DIR/simplify-locals.rs:63:2: 63: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 70725e5f14f7d..ee1e3c9346bf3 100644 --- a/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff @@ -10,7 +10,7 @@ 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 _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 } @@ -21,12 +21,12 @@ discriminant(_2) = 0; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:31: 4:49 StorageLive(_3); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:51: 4:68 discriminant(_3) = 0; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:51: 4:68 - (_1.0: std::option::Option) = move _2; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:30: 4:69 - (_1.1: std::option::Option) = move _3; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:30: 4:69 + (_1.0: std::option::Option) = _2; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:30: 4:69 + (_1.1: std::option::Option) = _3; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:30: 4:69 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(_5) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20 } bb1: { @@ -36,18 +36,18 @@ 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(_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 - switchInt(move _7) -> [false: bb5, otherwise: bb4]; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10 +- 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(_6, 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(_7) -> [false: bb5, otherwise: bb4]; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10 } bb4: { diff --git a/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.32bit.diff b/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.32bit.diff index 760fb747f7229..edb0b0c478bd7 100644 --- a/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.32bit.diff +++ b/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.32bit.diff @@ -18,7 +18,7 @@ - _5 = const false; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:5:9: 5:13 - _5 = const true; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:5:9: 5:13 - _2 = discriminant(_1); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:5:9: 5:13 - _0 = move _1; // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:6:20: 6:27 + _0 = _1; // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:6:20: 6:27 - _6 = discriminant(_1); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:8:1: 8:2 return; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:8:2: 8:2 } diff --git a/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.64bit.diff b/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.64bit.diff index 760fb747f7229..edb0b0c478bd7 100644 --- a/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.64bit.diff +++ b/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.64bit.diff @@ -18,7 +18,7 @@ - _5 = const false; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:5:9: 5:13 - _5 = const true; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:5:9: 5:13 - _2 = discriminant(_1); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:5:9: 5:13 - _0 = move _1; // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:6:20: 6:27 + _0 = _1; // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:6:20: 6:27 - _6 = discriminant(_1); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:8:1: 8:2 return; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:8:2: 8:2 } diff --git a/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff b/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff index e09b8cb39bd51..159ee0236be49 100644 --- a/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff +++ b/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff @@ -18,12 +18,15 @@ debug y => ((_0 as Ok).0: u32); // in scope 1 at $DIR/simplify_try.rs:21:9: 21:10 } scope 2 { - debug e => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_try.rs:22:13: 22:14 +- debug e => _6; // in scope 2 at $DIR/simplify_try.rs:22:13: 22:14 ++ debug e => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_try.rs:22:13: 22:14 scope 5 (inlined >::from) { // at $DIR/simplify_try.rs:22:37: 22:50 - debug t => ((_0 as Err).0: i32); // in scope 5 at $DIR/simplify_try.rs:22:37: 22:50 +- debug t => _9; // in scope 5 at $DIR/simplify_try.rs:22:37: 22:50 ++ debug t => ((_0 as Err).0: i32); // in scope 5 at $DIR/simplify_try.rs:22:37: 22:50 } scope 6 (inlined from_error::) { // at $DIR/simplify_try.rs:22:26: 22:51 - debug e => ((_0 as Err).0: i32); // in scope 6 at $DIR/simplify_try.rs:22:26: 22:51 +- debug e => _8; // in scope 6 at $DIR/simplify_try.rs:22:26: 22:51 ++ debug e => ((_0 as Err).0: i32); // in scope 6 at $DIR/simplify_try.rs:22:26: 22:51 } } scope 3 { @@ -39,7 +42,7 @@ - StorageLive(_3); // scope 0 at $DIR/simplify_try.rs:21:19: 21:33 - StorageLive(_4); // scope 0 at $DIR/simplify_try.rs:21:31: 21:32 - _4 = _1; // scope 0 at $DIR/simplify_try.rs:21:31: 21:32 -- _3 = move _4; // scope 4 at $DIR/simplify_try.rs:21:19: 21:33 +- _3 = _4; // scope 4 at $DIR/simplify_try.rs:21:19: 21:33 - StorageDead(_4); // scope 0 at $DIR/simplify_try.rs:21:32: 21:33 - _5 = discriminant(_3); // scope 0 at $DIR/simplify_try.rs:22:9: 22:15 + nop; // scope 0 at $DIR/simplify_try.rs:21:19: 21:33 @@ -48,13 +51,41 @@ + nop; // scope 4 at $DIR/simplify_try.rs:21:19: 21:33 + nop; // scope 0 at $DIR/simplify_try.rs:21:32: 21:33 + _5 = discriminant(_0); // scope 0 at $DIR/simplify_try.rs:22:9: 22:15 - goto -> bb1; // scope 0 at $DIR/simplify_try.rs:22:9: 22:15 + switchInt(move _5) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:22:9: 22:15 } bb1: { - _0 = move _3; // scope 1 at $DIR/simplify_try.rs:25:5: 25:10 - StorageDead(_3); // scope 0 at $DIR/simplify_try.rs:24:6: 24:7 + nop; // scope 1 at $DIR/simplify_try.rs:25:5: 25:10 ++ nop; // scope 0 at $DIR/simplify_try.rs:24:6: 24:7 + StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:26:1: 26:2 + return; // scope 0 at $DIR/simplify_try.rs:26:2: 26:2 + } + + bb2: { +- StorageLive(_6); // scope 0 at $DIR/simplify_try.rs:22:13: 22:14 +- _6 = ((_3 as Err).0: i32); // scope 0 at $DIR/simplify_try.rs:22:13: 22:14 +- StorageLive(_8); // scope 2 at $DIR/simplify_try.rs:22:37: 22:50 +- StorageLive(_9); // scope 2 at $DIR/simplify_try.rs:22:48: 22:49 +- _9 = _6; // scope 2 at $DIR/simplify_try.rs:22:48: 22:49 +- _8 = _9; // scope 5 at $DIR/simplify_try.rs:22:37: 22:50 +- StorageDead(_9); // scope 2 at $DIR/simplify_try.rs:22:49: 22:50 +- ((_0 as Err).0: i32) = _8; // scope 6 at $DIR/simplify_try.rs:22:26: 22:51 ++ nop; // scope 0 at $DIR/simplify_try.rs:22:13: 22:14 ++ nop; // scope 0 at $DIR/simplify_try.rs:22:13: 22:14 ++ nop; // scope 2 at $DIR/simplify_try.rs:22:37: 22:50 ++ nop; // scope 2 at $DIR/simplify_try.rs:22:48: 22:49 ++ nop; // scope 2 at $DIR/simplify_try.rs:22:48: 22:49 ++ nop; // scope 5 at $DIR/simplify_try.rs:22:37: 22:50 ++ nop; // scope 2 at $DIR/simplify_try.rs:22:49: 22:50 ++ nop; // scope 6 at $DIR/simplify_try.rs:22:26: 22:51 + discriminant(_0) = 1; // scope 6 at $DIR/simplify_try.rs:22:26: 22:51 +- StorageDead(_8); // scope 2 at $DIR/simplify_try.rs:22:50: 22:51 +- StorageDead(_6); // scope 0 at $DIR/simplify_try.rs:22:50: 22:51 +- StorageDead(_3); // scope 0 at $DIR/simplify_try.rs:24:6: 24:7 ++ nop; // scope 2 at $DIR/simplify_try.rs:22:50: 22:51 ++ nop; // scope 0 at $DIR/simplify_try.rs:22:50: 22:51 + nop; // scope 0 at $DIR/simplify_try.rs:24:6: 24:7 StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:26:1: 26:2 return; // scope 0 at $DIR/simplify_try.rs:26:2: 26:2 diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff index 488ad33f80a2d..ecf67ee736c92 100644 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff @@ -19,15 +19,12 @@ + debug y => ((_0 as Ok).0: u32); // in scope 1 at $DIR/simplify_try.rs:21:9: 21:10 } scope 2 { -- debug e => _6; // in scope 2 at $DIR/simplify_try.rs:22:13: 22:14 -+ debug e => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_try.rs:22:13: 22:14 + debug e => _6; // in scope 2 at $DIR/simplify_try.rs:22:13: 22:14 scope 5 (inlined >::from) { // at $DIR/simplify_try.rs:22:37: 22:50 -- debug t => _9; // in scope 5 at $DIR/simplify_try.rs:22:37: 22:50 -+ debug t => ((_0 as Err).0: i32); // in scope 5 at $DIR/simplify_try.rs:22:37: 22:50 + debug t => _9; // in scope 5 at $DIR/simplify_try.rs:22:37: 22:50 } scope 6 (inlined from_error::) { // at $DIR/simplify_try.rs:22:26: 22:51 -- debug e => _8; // in scope 6 at $DIR/simplify_try.rs:22:26: 22:51 -+ debug e => ((_0 as Err).0: i32); // in scope 6 at $DIR/simplify_try.rs:22:26: 22:51 + debug e => _8; // in scope 6 at $DIR/simplify_try.rs:22:26: 22:51 } } scope 3 { @@ -43,7 +40,7 @@ StorageLive(_3); // scope 0 at $DIR/simplify_try.rs:21:19: 21:33 StorageLive(_4); // scope 0 at $DIR/simplify_try.rs:21:31: 21:32 _4 = _1; // scope 0 at $DIR/simplify_try.rs:21:31: 21:32 - _3 = move _4; // scope 4 at $DIR/simplify_try.rs:21:19: 21:33 + _3 = _4; // scope 4 at $DIR/simplify_try.rs:21:19: 21:33 StorageDead(_4); // scope 0 at $DIR/simplify_try.rs:21:32: 21:33 _5 = discriminant(_3); // scope 0 at $DIR/simplify_try.rs:22:9: 22:15 switchInt(move _5) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:22:9: 22:15 @@ -66,18 +63,17 @@ } bb2: { -- StorageLive(_6); // scope 0 at $DIR/simplify_try.rs:22:13: 22:14 -- _6 = ((_3 as Err).0: i32); // scope 0 at $DIR/simplify_try.rs:22:13: 22:14 -- StorageLive(_8); // scope 2 at $DIR/simplify_try.rs:22:37: 22:50 -- StorageLive(_9); // scope 2 at $DIR/simplify_try.rs:22:48: 22:49 -- _9 = _6; // scope 2 at $DIR/simplify_try.rs:22:48: 22:49 -- _8 = move _9; // scope 5 at $DIR/simplify_try.rs:22:37: 22:50 -- StorageDead(_9); // scope 2 at $DIR/simplify_try.rs:22:49: 22:50 -- ((_0 as Err).0: i32) = move _8; // scope 6 at $DIR/simplify_try.rs:22:26: 22:51 -- discriminant(_0) = 1; // scope 6 at $DIR/simplify_try.rs:22:26: 22:51 -- StorageDead(_8); // scope 2 at $DIR/simplify_try.rs:22:50: 22:51 -- StorageDead(_6); // scope 0 at $DIR/simplify_try.rs:22:50: 22:51 -+ _0 = move _3; // scope 6 at $DIR/simplify_try.rs:22:26: 22:51 + StorageLive(_6); // scope 0 at $DIR/simplify_try.rs:22:13: 22:14 + _6 = ((_3 as Err).0: i32); // scope 0 at $DIR/simplify_try.rs:22:13: 22:14 + StorageLive(_8); // scope 2 at $DIR/simplify_try.rs:22:37: 22:50 + StorageLive(_9); // scope 2 at $DIR/simplify_try.rs:22:48: 22:49 + _9 = _6; // scope 2 at $DIR/simplify_try.rs:22:48: 22:49 + _8 = _9; // scope 5 at $DIR/simplify_try.rs:22:37: 22:50 + StorageDead(_9); // scope 2 at $DIR/simplify_try.rs:22:49: 22:50 + ((_0 as Err).0: i32) = _8; // scope 6 at $DIR/simplify_try.rs:22:26: 22:51 + discriminant(_0) = 1; // scope 6 at $DIR/simplify_try.rs:22:26: 22:51 + StorageDead(_8); // scope 2 at $DIR/simplify_try.rs:22:50: 22:51 + StorageDead(_6); // scope 0 at $DIR/simplify_try.rs:22:50: 22:51 StorageDead(_3); // scope 0 at $DIR/simplify_try.rs:24:6: 24:7 StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:26:1: 26:2 return; // scope 0 at $DIR/simplify_try.rs:26:2: 26:2 diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir b/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir index 5d829f859e9d9..5b9be1846ff30 100644 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir +++ b/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir @@ -17,12 +17,12 @@ fn try_identity(_1: Result) -> Result { debug y => ((_0 as Ok).0: u32); // in scope 1 at $DIR/simplify_try.rs:21:9: 21:10 } scope 2 { - debug e => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_try.rs:22:13: 22:14 + debug e => _6; // in scope 2 at $DIR/simplify_try.rs:22:13: 22:14 scope 5 (inlined >::from) { // at $DIR/simplify_try.rs:22:37: 22:50 - debug t => ((_0 as Err).0: i32); // in scope 5 at $DIR/simplify_try.rs:22:37: 22:50 + debug t => _9; // in scope 5 at $DIR/simplify_try.rs:22:37: 22:50 } scope 6 (inlined from_error::) { // at $DIR/simplify_try.rs:22:26: 22:51 - debug e => ((_0 as Err).0: i32); // in scope 6 at $DIR/simplify_try.rs:22:26: 22:51 + debug e => _8; // in scope 6 at $DIR/simplify_try.rs:22:26: 22:51 } } scope 3 { @@ -37,10 +37,10 @@ fn try_identity(_1: Result) -> Result { StorageLive(_3); // scope 0 at $DIR/simplify_try.rs:21:19: 21:33 StorageLive(_4); // scope 0 at $DIR/simplify_try.rs:21:31: 21:32 _4 = _1; // scope 0 at $DIR/simplify_try.rs:21:31: 21:32 - _3 = move _4; // scope 4 at $DIR/simplify_try.rs:21:19: 21:33 + _3 = _4; // scope 4 at $DIR/simplify_try.rs:21:19: 21:33 StorageDead(_4); // scope 0 at $DIR/simplify_try.rs:21:32: 21:33 _5 = discriminant(_3); // scope 0 at $DIR/simplify_try.rs:22:9: 22:15 - goto -> bb1; // scope 0 at $DIR/simplify_try.rs:22:9: 22:15 + switchInt(move _5) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:22:9: 22:15 } bb1: { @@ -49,4 +49,21 @@ fn try_identity(_1: Result) -> Result { StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:26:1: 26:2 return; // scope 0 at $DIR/simplify_try.rs:26:2: 26:2 } + + bb2: { + StorageLive(_6); // scope 0 at $DIR/simplify_try.rs:22:13: 22:14 + _6 = ((_3 as Err).0: i32); // scope 0 at $DIR/simplify_try.rs:22:13: 22:14 + StorageLive(_8); // scope 2 at $DIR/simplify_try.rs:22:37: 22:50 + StorageLive(_9); // scope 2 at $DIR/simplify_try.rs:22:48: 22:49 + _9 = _6; // scope 2 at $DIR/simplify_try.rs:22:48: 22:49 + _8 = _9; // scope 5 at $DIR/simplify_try.rs:22:37: 22:50 + StorageDead(_9); // scope 2 at $DIR/simplify_try.rs:22:49: 22:50 + ((_0 as Err).0: i32) = _8; // scope 6 at $DIR/simplify_try.rs:22:26: 22:51 + discriminant(_0) = 1; // scope 6 at $DIR/simplify_try.rs:22:26: 22:51 + StorageDead(_8); // scope 2 at $DIR/simplify_try.rs:22:50: 22:51 + StorageDead(_6); // scope 0 at $DIR/simplify_try.rs:22:50: 22:51 + StorageDead(_3); // scope 0 at $DIR/simplify_try.rs:24:6: 24:7 + StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:26:1: 26:2 + return; // scope 0 at $DIR/simplify_try.rs:26:2: 26:2 + } } diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir b/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir index 1b5232422b6c3..c185426c3e09a 100644 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir +++ b/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir @@ -3,6 +3,7 @@ fn try_identity(_1: Result) -> Result { debug x => _1; // in scope 0 at $DIR/simplify_try.rs:20:17: 20:18 let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_try.rs:20:41: 20:57 + let mut _2: isize; // in scope 0 at $DIR/simplify_try.rs:22:9: 22:15 scope 1 { debug y => ((_0 as Ok).0: u32); // in scope 1 at $DIR/simplify_try.rs:21:9: 21:10 } @@ -24,6 +25,16 @@ fn try_identity(_1: Result) -> Result { bb0: { _0 = _1; // scope 0 at $DIR/simplify_try.rs:21:31: 21:32 + _2 = discriminant(_1); // scope 0 at $DIR/simplify_try.rs:22:9: 22:15 + switchInt(_2) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:22:9: 22:15 + } + + bb1: { + return; // scope 0 at $DIR/simplify_try.rs:26:2: 26:2 + } + + bb2: { + discriminant(_0) = 1; // scope 6 at $DIR/simplify_try.rs:22:26: 22:51 return; // scope 0 at $DIR/simplify_try.rs:26:2: 26:2 } } 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 bf9c2d138a0f6..67b0f0a7e05a1 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 @@ -35,7 +35,7 @@ fn while_loop(_1: bool) -> () { bb3: { StorageDead(_5); // scope 0 at $DIR/while-storage.rs:11:22: 11:23 - switchInt(move _4) -> [false: bb5, otherwise: bb4]; // scope 0 at $DIR/while-storage.rs:11:9: 13:10 + switchInt(_4) -> [false: bb5, otherwise: bb4]; // scope 0 at $DIR/while-storage.rs:11:9: 13:10 } bb4: { diff --git a/src/test/ui/async-await/large_moves.attribute.stderr b/src/test/ui/async-await/large_moves.attribute.stderr index 39b7e7cb345bd..2ca816f3bc868 100644 --- a/src/test/ui/async-await/large_moves.attribute.stderr +++ b/src/test/ui/async-await/large_moves.attribute.stderr @@ -16,12 +16,6 @@ note: the lint level is defined here LL | #![deny(large_assignments)] | ^^^^^^^^^^^^^^^^^ -error: moving 10024 bytes - --> $DIR/large_moves.rs:18:14 - | -LL | let z = (x, 42); - | ^ value moved from here - error: moving 10024 bytes --> $DIR/large_moves.rs:18:13 | @@ -29,10 +23,10 @@ LL | let z = (x, 42); | ^^^^^^^ value moved from here error: moving 10024 bytes - --> $DIR/large_moves.rs:20:13 + --> $DIR/large_moves.rs:19:13 | LL | let a = z.0; | ^^^ value moved from here -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/src/test/ui/async-await/large_moves.option.stderr b/src/test/ui/async-await/large_moves.option.stderr index 39b7e7cb345bd..2ca816f3bc868 100644 --- a/src/test/ui/async-await/large_moves.option.stderr +++ b/src/test/ui/async-await/large_moves.option.stderr @@ -16,12 +16,6 @@ note: the lint level is defined here LL | #![deny(large_assignments)] | ^^^^^^^^^^^^^^^^^ -error: moving 10024 bytes - --> $DIR/large_moves.rs:18:14 - | -LL | let z = (x, 42); - | ^ value moved from here - error: moving 10024 bytes --> $DIR/large_moves.rs:18:13 | @@ -29,10 +23,10 @@ LL | let z = (x, 42); | ^^^^^^^ value moved from here error: moving 10024 bytes - --> $DIR/large_moves.rs:20:13 + --> $DIR/large_moves.rs:19:13 | LL | let a = z.0; | ^^^ value moved from here -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/src/test/ui/async-await/large_moves.rs b/src/test/ui/async-await/large_moves.rs index 18bb538a81eb1..5210a42d693aa 100644 --- a/src/test/ui/async-await/large_moves.rs +++ b/src/test/ui/async-await/large_moves.rs @@ -16,7 +16,6 @@ fn main() { dbg!(y); }; let z = (x, 42); //~ ERROR large_assignments - //~^ ERROR large_assignments let a = z.0; //~ ERROR large_assignments let b = z.1; }