diff --git a/compiler/rustc_mir_transform/src/simplify_try.rs b/compiler/rustc_mir_transform/src/simplify_try.rs index d5507fcc78cad..3293710a312df 100644 --- a/compiler/rustc_mir_transform/src/simplify_try.rs +++ b/compiler/rustc_mir_transform/src/simplify_try.rs @@ -11,529 +11,441 @@ use crate::{simplify, MirPass}; use itertools::Itertools as _; -use rustc_index::{bit_set::BitSet, vec::IndexVec}; -use rustc_middle::mir::visit::{NonUseContext, PlaceContext, Visitor}; +use rustc_data_structures::fx::FxHashMap; use rustc_middle::mir::*; -use rustc_middle::ty::{self, List, Ty, TyCtxt}; +use rustc_middle::ty::query::TyCtxtAt; +use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt}; +use rustc_span::{Symbol, DUMMY_SP}; use rustc_target::abi::VariantIdx; -use std::iter::{once, Enumerate, Peekable}; -use std::slice::Iter; +use smallvec::SmallVec; +use std::collections::hash_map::Entry; +use std::iter::once; /// Simplifies arms of form `Variant(x) => Variant(x)` to just a move. /// -/// This is done by transforming basic blocks where the statements match: +/// We do this by finding statement bundles of the following form: /// -/// ```rust -/// _LOCAL_TMP = ((_LOCAL_1 as Variant ).FIELD: TY ); -/// _TMP_2 = _LOCAL_TMP; -/// ((_LOCAL_0 as Variant).FIELD: TY) = move _TMP_2; -/// discriminant(_LOCAL_0) = VAR_IDX; +/// ```ignore (syntax-highlighting-only) +/// TMP_1 = move? ((SRC as Variant).FIELD); +/// TMP_2 = move? TMP_1; +/// ((DEST as Variant).FIELD) = move? TMP_2; /// ``` /// -/// into: +/// where `Variant`, `SRC`, and `DEST` must be consistent across all bundles, while `TMP_1`, +/// `TMP_2`, and `FIELD` must vary across all bundles. The actual number of `TMP_*`s that we require +/// is not fixed; we allow arbitrarily many, including possibly zero. /// -/// ```rust -/// _LOCAL_0 = move _LOCAL_1 +/// The bundles of the kind above may be interlaced with each other, however they must form a +/// contiguous set of statements. Finally, we expect that these bundles are terminated with +/// +/// ```ignore (syntax-highlighting-only) +/// discriminant(DEST) = VAR_IDX; /// ``` +/// +/// where `VAR_IDX` corresponds to `Variant`. +/// +/// After doing some checks, we then transform the statements we matched above as follows: +/// +/// 1. We remove the `discriminant(DEST) =` and `((DEST as Variant).FIELD: TY)` statements, +/// replacing the `discriminant(DEST)` with `DEST = move? SRC`. This is correct because our +/// bundles precisely track the flow of data from `SRC` into `DEST`. +/// 2. The assignments to temporaries may or may not be removed. How this works is detailed below. +/// +/// Additionally, we allow any amount of `StorageLive`/`StorageDead` statements among the statements +/// we match. If we make the transformation, all the `StorageLive` statements are moved to the +/// beginning of the contiguous section of statements that we operate on, while all the +/// `StorageDead` are moved to the end. This is correct because reordering `StorageLive` +/// backwards/`StorageDead` forwards is always correct. +/// +/// ## Dealing with `move`/`copy` +/// +/// Whether each of the assignments is `move`/`copy` (the "move mode") may be inconsistent, which +/// causes some complications. Using either move mode comes with requirements: `move` must be the +/// last use, while anything `copy`ed must have satisfy a `Copy` bound. Furthermore, we need to +/// assume that anything `copy`ed may be used again later. Making sure we don't miscompile something +/// here requires care. We impose the following rules: +/// +/// 1. All assignments out of the source must have the same move mode. This is the move mode that is +/// used for the single assignment that is found in the new output statement. If that move mode +/// then turns out to be `copy`, we additionally require the type of `src` to satisfy a `Copy` +/// bound. +/// 2. For each bundle, if any assignment to a temporary is via `copy`, then this is sufficient to +/// prove that the field is `Copy`. In this case, we keep all assignments to temporaries +/// associated with this bundle. The move mode of the assignment out of `src` is forced to be +/// `copy`. For all other assignments, the move mode is preserved. If none of the move modes are +/// `copy`, then all of the assignments are dropped. +/// pub struct SimplifyArmIdentity; #[derive(Debug)] struct ArmIdentityInfo<'tcx> { - /// Storage location for the variant's field - local_temp_0: Local, - /// Storage location holding the variant being read from - local_1: Local, - /// The variant field being read from - vf_s0: VarField<'tcx>, - /// Index of the statement which loads the variant being read - get_variant_field_stmt: usize, - - /// Tracks each assignment to a temporary of the variant's field - field_tmp_assignments: Vec<(Local, Local)>, - - /// Storage location holding the variant's field that was read from - local_tmp_s1: Local, - /// Storage location holding the enum that we are writing to - local_0: Local, - /// The variant field being written to - vf_s1: VarField<'tcx>, - - /// Storage location that the discriminant is being written to - set_discr_local: Local, - /// The variant being written - set_discr_var_idx: VariantIdx, - - /// Index of the statement that should be overwritten as a move - stmt_to_overwrite: usize, - /// SourceInfo for the new move - source_info: SourceInfo, - - /// Indices of matching Storage{Live,Dead} statements encountered. - /// (StorageLive index,, StorageDead index, Local) - storage_stmts: Vec<(usize, usize, Local)>, - - /// The statements that should be removed (turned into nops) - stmts_to_remove: Vec, - - /// Indices of debug variables that need to be adjusted to point to - // `{local_0}.{dbg_projection}`. - dbg_info_to_adjust: Vec, - - /// The projection used to rewrite debug info. - dbg_projection: &'tcx List>, + src: Place<'tcx>, + dest: Place<'tcx>, + variant: VariantIdx, + variant_sym: Option, + + // The move mode of the main assignment + move_mode: MoveMode, + + /// This maps locals to the bundle they are found in, by mapping them to the field associated + /// with the bundle, along with the type of the field. We use this to update debug info + temps: FxHashMap)>, + + /// Indicates the role that each statement passed into the info gathering plays. This *does not* + /// include the `discriminant(DEST) = Variant;` statement, which comes immediately after this, + /// and terminates the range of statements involved in the optimization. + stmts: Vec, +} + +#[derive(Debug, Eq, PartialEq, Clone, Copy)] +enum MoveMode { + Move, + Copy, +} + +#[derive(Debug)] +enum StatementType { + StorageLive, + StorageDead, + /// Drop this assignment from the output. + /// + /// This is used for all assignments if the bundle's move mode is `move` and for all assignments + /// into `dest` if the bundle's move mode is `copy`. + AssignDrop, + /// Retain the assignment and preserve its move mode. + /// + /// This is used for assignments that are both into and out of temporaries in bundles with + /// `copy` move mode. + AssignPreserve, + /// Retain the assignment and force the move mode to be `copy`. + /// + /// This is used for assignments out of `src` and into temporaries in bundles with `copy` move + /// mode. + AssignForceCopy, +} + +struct BundleData<'tcx> { + /// The sequence of temporaries that this bundle assigns to. The `usize` is the index of the + /// associated statement, stored so that we can go update the statement types later. + temps: SmallVec<[(Local, usize); 2]>, + // `true` once we have assigned to `dest` + complete: bool, + move_mode: MoveMode, + ty: Ty<'tcx>, } fn get_arm_identity_info<'a, 'tcx>( + tcx: TyCtxt<'tcx>, stmts: &'a [Statement<'tcx>], - locals_count: usize, - debug_info: &'a [VarDebugInfo<'tcx>], + local_decls: &'a LocalDecls<'tcx>, + param_env: ParamEnv<'tcx>, ) -> Option> { - // This can't possibly match unless there are at least 3 statements in the block + // This can't possibly match unless there are at least 2 statements in the block // so fail fast on tiny blocks. - if stmts.len() < 3 { + if stmts.len() < 2 { return None; } - let mut tmp_assigns = Vec::new(); - let mut nop_stmts = Vec::new(); - let mut storage_stmts = Vec::new(); - let mut storage_live_stmts = Vec::new(); - let mut storage_dead_stmts = Vec::new(); - - type StmtIter<'a, 'tcx> = Peekable>>>; - - fn is_storage_stmt(stmt: &Statement<'_>) -> bool { - matches!(stmt.kind, StatementKind::StorageLive(_) | StatementKind::StorageDead(_)) - } - - /// Eats consecutive Statements which match `test`, performing the specified `action` for each. - /// The iterator `stmt_iter` is not advanced if none were matched. - fn try_eat<'a, 'tcx>( - stmt_iter: &mut StmtIter<'a, 'tcx>, - test: impl Fn(&'a Statement<'tcx>) -> bool, - mut action: impl FnMut(usize, &'a Statement<'tcx>), - ) { - while stmt_iter.peek().map_or(false, |(_, stmt)| test(stmt)) { - let (idx, stmt) = stmt_iter.next().unwrap(); - - action(idx, stmt); - } - } - - /// Eats consecutive `StorageLive` and `StorageDead` Statements. - /// The iterator `stmt_iter` is not advanced if none were found. - fn try_eat_storage_stmts( - stmt_iter: &mut StmtIter<'_, '_>, - storage_live_stmts: &mut Vec<(usize, Local)>, - storage_dead_stmts: &mut Vec<(usize, Local)>, - ) { - try_eat(stmt_iter, is_storage_stmt, |idx, stmt| { - if let StatementKind::StorageLive(l) = stmt.kind { - storage_live_stmts.push((idx, l)); - } else if let StatementKind::StorageDead(l) = stmt.kind { - storage_dead_stmts.push((idx, l)); - } - }) - } - - fn is_tmp_storage_stmt(stmt: &Statement<'_>) -> bool { - use rustc_middle::mir::StatementKind::Assign; - if let Assign(box (place, Rvalue::Use(Operand::Copy(p) | Operand::Move(p)))) = &stmt.kind { - place.as_local().is_some() && p.as_local().is_some() - } else { - false - } - } - - /// Eats consecutive `Assign` Statements. - // The iterator `stmt_iter` is not advanced if none were found. - fn try_eat_assign_tmp_stmts( - stmt_iter: &mut StmtIter<'_, '_>, - tmp_assigns: &mut Vec<(Local, Local)>, - nop_stmts: &mut Vec, - ) { - try_eat(stmt_iter, is_tmp_storage_stmt, |idx, stmt| { - use rustc_middle::mir::StatementKind::Assign; - if let Assign(box (place, Rvalue::Use(Operand::Copy(p) | Operand::Move(p)))) = - &stmt.kind - { - tmp_assigns.push((place.as_local().unwrap(), p.as_local().unwrap())); - nop_stmts.push(idx); + let mut src = None; + let mut dest = None; + let mut variant = None; + let mut variant_sym = None; + let mut move_mode = None; + let mut stmt_types = Vec::new(); + + // This map is not returned; we create and update it as we process statements. + let mut bundles: FxHashMap> = FxHashMap::default(); + + for stmt in stmts { + match &stmt.kind { + StatementKind::StorageLive(_) => stmt_types.push(StatementType::StorageLive), + StatementKind::StorageDead(_) => stmt_types.push(StatementType::StorageDead), + StatementKind::Assign(assign) => { + update_with_assign( + tcx, + assign, + &mut src, + &mut dest, + &mut variant, + &mut variant_sym, + &mut move_mode, + &mut stmt_types, + &mut bundles, + )?; } - }) - } - - fn find_storage_live_dead_stmts_for_local( - local: Local, - stmts: &[Statement<'_>], - ) -> Option<(usize, usize)> { - trace!("looking for {:?}", local); - let mut storage_live_stmt = None; - let mut storage_dead_stmt = None; - for (idx, stmt) in stmts.iter().enumerate() { - if stmt.kind == StatementKind::StorageLive(local) { - storage_live_stmt = Some(idx); - } else if stmt.kind == StatementKind::StorageDead(local) { - storage_dead_stmt = Some(idx); - } - } - - Some((storage_live_stmt?, storage_dead_stmt.unwrap_or(usize::MAX))) - } - - // Try to match the expected MIR structure with the basic block we're processing. - // We want to see something that looks like: - // ``` - // (StorageLive(_) | StorageDead(_));* - // _LOCAL_INTO = ((_LOCAL_FROM as Variant).FIELD: TY); - // (StorageLive(_) | StorageDead(_));* - // (tmp_n+1 = tmp_n);* - // (StorageLive(_) | StorageDead(_));* - // (tmp_n+1 = tmp_n);* - // ((LOCAL_FROM as Variant).FIELD: TY) = move tmp; - // discriminant(LOCAL_FROM) = VariantIdx; - // (StorageLive(_) | StorageDead(_));* - // ``` - let mut stmt_iter = stmts.iter().enumerate().peekable(); - - try_eat_storage_stmts(&mut stmt_iter, &mut storage_live_stmts, &mut storage_dead_stmts); - - let (get_variant_field_stmt, stmt) = stmt_iter.next()?; - let (local_tmp_s0, local_1, vf_s0, dbg_projection) = match_get_variant_field(stmt)?; - - try_eat_storage_stmts(&mut stmt_iter, &mut storage_live_stmts, &mut storage_dead_stmts); - - try_eat_assign_tmp_stmts(&mut stmt_iter, &mut tmp_assigns, &mut nop_stmts); - - try_eat_storage_stmts(&mut stmt_iter, &mut storage_live_stmts, &mut storage_dead_stmts); - - try_eat_assign_tmp_stmts(&mut stmt_iter, &mut tmp_assigns, &mut nop_stmts); + StatementKind::SetDiscriminant { place, variant_index: var_idx } => { + // We've found the end of the potential optimization + let src = src?; + let dest = dest?; + let variant = variant?; + let move_mode = move_mode?; + + // First, make sure the `SetDiscriminant` has the expected form as well + if variant != *var_idx || dest != **place { + return None; + } - let (idx, stmt) = stmt_iter.next()?; - let (local_tmp_s1, local_0, vf_s1) = match_set_variant_field(stmt)?; - nop_stmts.push(idx); + // Finally, make sure that all the bundles are complete + if bundles.values().any(|b| !b.complete) { + return None; + } - let (idx, stmt) = stmt_iter.next()?; - let (set_discr_local, set_discr_var_idx) = match_set_discr(stmt)?; - let discr_stmt_source_info = stmt.source_info; - nop_stmts.push(idx); + // That the types match + let src_ty = src.ty(local_decls, tcx).ty; + if src_ty != dest.ty(local_decls, tcx).ty { + return None; + } - try_eat_storage_stmts(&mut stmt_iter, &mut storage_live_stmts, &mut storage_dead_stmts); + // That we assigned the correct number of fields + let num_fields_assigned = bundles.len(); + let num_var_fields = src_ty.ty_adt_def().unwrap().variants[variant].fields.len(); + if num_fields_assigned != num_var_fields { + return None; + } - for (live_idx, live_local) in storage_live_stmts { - if let Some(i) = storage_dead_stmts.iter().rposition(|(_, l)| *l == live_local) { - let (dead_idx, _) = storage_dead_stmts.swap_remove(i); - storage_stmts.push((live_idx, dead_idx, live_local)); + // And that if we're going to copy the source, it's really a `Copy` type + if move_mode == MoveMode::Copy + && !src_ty.is_copy_modulo_regions(TyCtxtAt { tcx, span: DUMMY_SP }, param_env) + { + return None; + } - if live_local == local_tmp_s0 { - nop_stmts.push(get_variant_field_stmt); + let temps = bundles + .into_iter() + .flat_map(|(f, b)| b.temps.into_iter().map(move |(l, _)| (l, (f, b.ty)))) + .collect(); + + return Some(ArmIdentityInfo { + src, + dest, + variant, + variant_sym, + move_mode, + temps, + stmts: stmt_types, + }); } - } - } - // We sort primitive usize here so we can use unstable sort - nop_stmts.sort_unstable(); - - // Use one of the statements we're going to discard between the point - // where the storage location for the variant field becomes live and - // is killed. - let (live_idx, dead_idx) = find_storage_live_dead_stmts_for_local(local_tmp_s0, stmts)?; - let stmt_to_overwrite = - nop_stmts.iter().find(|stmt_idx| live_idx < **stmt_idx && **stmt_idx < dead_idx); - - let mut tmp_assigned_vars = BitSet::new_empty(locals_count); - for (l, r) in &tmp_assigns { - tmp_assigned_vars.insert(*l); - tmp_assigned_vars.insert(*r); - } - - let dbg_info_to_adjust: Vec<_> = debug_info - .iter() - .enumerate() - .filter_map(|(i, var_info)| { - if let VarDebugInfoContents::Place(p) = var_info.value { - if tmp_assigned_vars.contains(p.local) { - return Some(i); - } + _ => { + return None; } + }; + } - None - }) - .collect(); - - Some(ArmIdentityInfo { - local_temp_0: local_tmp_s0, - local_1, - vf_s0, - get_variant_field_stmt, - field_tmp_assignments: tmp_assigns, - local_tmp_s1, - local_0, - vf_s1, - set_discr_local, - set_discr_var_idx, - stmt_to_overwrite: *stmt_to_overwrite?, - source_info: discr_stmt_source_info, - storage_stmts, - stmts_to_remove: nop_stmts, - dbg_info_to_adjust, - dbg_projection, - }) + // We ran out of statements before we found the `SetDiscriminant` + return None; } -fn optimization_applies<'tcx>( - opt_info: &ArmIdentityInfo<'tcx>, - local_decls: &IndexVec>, - local_uses: &IndexVec, - var_debug_info: &[VarDebugInfo<'tcx>], -) -> bool { - trace!("testing if optimization applies..."); - - // FIXME(wesleywiser): possibly relax this restriction? - if opt_info.local_0 == opt_info.local_1 { - trace!("NO: moving into ourselves"); - return false; - } else if opt_info.vf_s0 != opt_info.vf_s1 { - trace!("NO: the field-and-variant information do not match"); - return false; - } else if local_decls[opt_info.local_0].ty != local_decls[opt_info.local_1].ty { - // FIXME(Centril,oli-obk): possibly relax to same layout? - trace!("NO: source and target locals have different types"); - return false; - } else if (opt_info.local_0, opt_info.vf_s0.var_idx) - != (opt_info.set_discr_local, opt_info.set_discr_var_idx) - { - trace!("NO: the discriminants do not match"); - return false; - } +#[must_use] +fn update_with_assign<'tcx>( + tcx: TyCtxt<'tcx>, + assign: &Box<(Place<'tcx>, Rvalue<'tcx>)>, + src: &mut Option>, + dest: &mut Option>, + variant: &mut Option, + variant_sym: &mut Option, + move_mode: &mut Option, + stmt_types: &mut Vec, + bundles: &mut FxHashMap>, +) -> Option<()> { + let lhs = assign.0; + let Rvalue::Use(rhs_op) = &assign.1 else { return None }; + + let (mm, rhs) = match_operand(tcx, rhs_op)?; + let (src_field, bundle, mut stmt_type) = match rhs { + TempOrVarField::VarField(place, var_idx, _, field, field_ty) => { + // We are assigning *from* `field`. First, check that we are using the right + // `src`, `variant`, and move mode. + set_or_check(src, place)?; + set_or_check(variant, var_idx)?; + set_or_check(move_mode, mm)?; + + let new_bundle = + BundleData { temps: SmallVec::new(), complete: false, move_mode: mm, ty: field_ty }; + let Entry::Vacant(entry) = bundles.entry(field) else { + // We had assigned from `field` already + return None; + }; + let bundle = entry.insert(new_bundle); + let stmt_type = if mm == MoveMode::Move { + StatementType::AssignDrop + } else { + StatementType::AssignForceCopy + }; - // Verify the assignment chain consists of the form b = a; c = b; d = c; etc... - if opt_info.field_tmp_assignments.is_empty() { - trace!("NO: no assignments found"); - return false; - } - let mut last_assigned_to = opt_info.field_tmp_assignments[0].1; - let source_local = last_assigned_to; - for (l, r) in &opt_info.field_tmp_assignments { - if *r != last_assigned_to { - trace!("NO: found unexpected assignment {:?} = {:?}", l, r); - return false; + (field, bundle, stmt_type) } - - last_assigned_to = *l; - } - - // Check that the first and last used locals are only used twice - // since they are of the form: - // - // ``` - // _first = ((_x as Variant).n: ty); - // _n = _first; - // ... - // ((_y as Variant).n: ty) = _n; - // discriminant(_y) = z; - // ``` - for (l, r) in &opt_info.field_tmp_assignments { - if local_uses[*l] != 2 { - warn!("NO: FAILED assignment chain local {:?} was used more than twice", l); - return false; - } else if local_uses[*r] != 2 { - warn!("NO: FAILED assignment chain local {:?} was used more than twice", r); - return false; + TempOrVarField::Temp(local) => { + // We are assigning out of a `local`. It should be the most recently + // assigned local of some bundle. + let (field, bundle) = bundles + .iter_mut() + .filter(|(_, b)| !b.complete) + .find(|(_, b)| b.temps.last().map(|(l, _)| *l) == Some(local))?; + let statement_type = if bundle.move_mode == MoveMode::Move { + if mm == MoveMode::Copy { + // We need to update this bundle to use `copy` move mode + bundle.move_mode = MoveMode::Copy; + stmt_types[bundle.temps[0].1] = StatementType::AssignForceCopy; + for (_, i) in bundle.temps[1..].iter() { + stmt_types[*i] = StatementType::AssignPreserve; + } + StatementType::AssignPreserve + } else { + StatementType::AssignDrop + } + } else { + StatementType::AssignPreserve + }; + (*field, bundle, statement_type) } - } + }; - // Check that debug info only points to full Locals and not projections. - for dbg_idx in &opt_info.dbg_info_to_adjust { - let dbg_info = &var_debug_info[*dbg_idx]; - if let VarDebugInfoContents::Place(p) = dbg_info.value { - if !p.projection.is_empty() { - trace!("NO: debug info for {:?} had a projection {:?}", dbg_info.name, p); - return false; + let lhs = match_place(tcx, lhs)?; + match lhs { + TempOrVarField::VarField(place, var_idx, var_sym, dest_field, _) => { + if *variant_sym == None { + *variant_sym = var_sym; + } + set_or_check(dest, place)?; + set_or_check(variant, var_idx)?; + if dest_field != src_field { + return None; } + bundle.complete = true; + stmt_type = StatementType::AssignDrop; } - } - - if source_local != opt_info.local_temp_0 { - trace!( - "NO: start of assignment chain does not match enum variant temp: {:?} != {:?}", - source_local, - opt_info.local_temp_0 - ); - return false; - } else if last_assigned_to != opt_info.local_tmp_s1 { - trace!( - "NO: end of assignemnt chain does not match written enum temp: {:?} != {:?}", - last_assigned_to, - opt_info.local_tmp_s1 - ); - return false; - } - - trace!("SUCCESS: optimization applies!"); - true -} - -impl<'tcx> MirPass<'tcx> for SimplifyArmIdentity { - fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { - // FIXME(77359): This optimization can result in unsoundness. - if !tcx.sess.opts.debugging_opts.unsound_mir_opts { - return; + TempOrVarField::Temp(local) => { + bundle.temps.push((local, stmt_types.len())); } + }; + stmt_types.push(stmt_type); + Some(()) +} - let source = body.source; - trace!("running SimplifyArmIdentity on {:?}", source); - - let local_uses = LocalUseCounter::get_local_uses(body); - let (basic_blocks, local_decls, debug_info) = - body.basic_blocks_local_decls_mut_and_var_debug_info(); - for bb in basic_blocks { - if let Some(opt_info) = - get_arm_identity_info(&bb.statements, local_decls.len(), debug_info) - { - trace!("got opt_info = {:#?}", opt_info); - if !optimization_applies(&opt_info, local_decls, &local_uses, &debug_info) { - debug!("optimization skipped for {:?}", source); - continue; - } - - // Also remove unused Storage{Live,Dead} statements which correspond - // to temps used previously. - for (live_idx, dead_idx, local) in &opt_info.storage_stmts { - // The temporary that we've read the variant field into is scoped to this block, - // so we can remove the assignment. - if *local == opt_info.local_temp_0 { - bb.statements[opt_info.get_variant_field_stmt].make_nop(); - } - - for (left, right) in &opt_info.field_tmp_assignments { - if local == left || local == right { - bb.statements[*live_idx].make_nop(); - bb.statements[*dead_idx].make_nop(); - } - } - } - - // Right shape; transform - for stmt_idx in opt_info.stmts_to_remove { - bb.statements[stmt_idx].make_nop(); - } - - let stmt = &mut bb.statements[opt_info.stmt_to_overwrite]; - stmt.source_info = opt_info.source_info; - stmt.kind = StatementKind::Assign(Box::new(( - opt_info.local_0.into(), - Rvalue::Use(Operand::Move(opt_info.local_1.into())), - ))); - - bb.statements.retain(|stmt| stmt.kind != StatementKind::Nop); - - // Fix the debug info to point to the right local - for dbg_index in opt_info.dbg_info_to_adjust { - let dbg_info = &mut debug_info[dbg_index]; - assert!( - matches!(dbg_info.value, VarDebugInfoContents::Place(_)), - "value was not a Place" - ); - if let VarDebugInfoContents::Place(p) = &mut dbg_info.value { - assert!(p.projection.is_empty()); - p.local = opt_info.local_0; - p.projection = opt_info.dbg_projection; - } - } - - trace!("block is now {:?}", bb.statements); +/// If `opt` is `None`, sets it to `val`, then checks if the value in `opt` is the same as +/// `val`, returning `None` if not. +#[must_use] +fn set_or_check(opt: &mut Option, val: T) -> Option<()> { + match opt { + Some(o) => { + if o == &val { + Some(()) + } else { + None } } + None => { + *opt = Some(val); + Some(()) + } } } -struct LocalUseCounter { - local_uses: IndexVec, -} - -impl LocalUseCounter { - fn get_local_uses(body: &Body<'_>) -> IndexVec { - let mut counter = LocalUseCounter { local_uses: IndexVec::from_elem(0, &body.local_decls) }; - counter.visit_body(body); - counter.local_uses - } +enum TempOrVarField<'tcx> { + Temp(Local), + VarField(Place<'tcx>, VariantIdx, Option, Field, Ty<'tcx>), } -impl Visitor<'_> for LocalUseCounter { - fn visit_local(&mut self, local: &Local, context: PlaceContext, _location: Location) { - if context.is_storage_marker() - || context == PlaceContext::NonUse(NonUseContext::VarDebugInfo) - { - return; - } - - self.local_uses[*local] += 1; - } +fn match_operand<'tcx>( + tcx: TyCtxt<'tcx>, + op: &Operand<'tcx>, +) -> Option<(MoveMode, TempOrVarField<'tcx>)> { + let (mm, place) = match op { + Operand::Move(p) => (MoveMode::Move, p), + Operand::Copy(p) => (MoveMode::Copy, p), + Operand::Constant(_) => return None, + }; + match_place(tcx, *place).map(|x| (mm, x)) } -/// Match on: -/// ```rust -/// _LOCAL_INTO = ((_LOCAL_FROM as Variant).FIELD: TY); -/// ``` -fn match_get_variant_field<'tcx>( - stmt: &Statement<'tcx>, -) -> Option<(Local, Local, VarField<'tcx>, &'tcx List>)> { - match &stmt.kind { - StatementKind::Assign(box ( - place_into, - Rvalue::Use(Operand::Copy(pf) | Operand::Move(pf)), - )) => { - let local_into = place_into.as_local()?; - let (local_from, vf) = match_variant_field_place(*pf)?; - Some((local_into, local_from, vf, pf.projection)) - } - _ => None, +fn match_place<'tcx>(tcx: TyCtxt<'tcx>, place: Place<'tcx>) -> Option> { + let len = place.projection.len(); + if len == 0 { + return Some(TempOrVarField::Temp(place.local)); } -} - -/// Match on: -/// ```rust -/// ((_LOCAL_FROM as Variant).FIELD: TY) = move _LOCAL_INTO; -/// ``` -fn match_set_variant_field<'tcx>(stmt: &Statement<'tcx>) -> Option<(Local, Local, VarField<'tcx>)> { - match &stmt.kind { - StatementKind::Assign(box (place_from, Rvalue::Use(Operand::Move(place_into)))) => { - let local_into = place_into.as_local()?; - let (local_from, vf) = match_variant_field_place(*place_from)?; - Some((local_into, local_from, vf)) - } - _ => None, + if len == 1 { + return None; } + let ProjectionElem::Field(f, f_ty) = place.projection[len - 1] else { return None; }; + let ProjectionElem::Downcast(var_sym, var) = place.projection[len - 2] else { return None; }; + let p = Place { + local: place.local, + projection: tcx.intern_place_elems(&place.projection[..len - 2]), + }; + return Some(TempOrVarField::VarField(p, var, var_sym, f, f_ty)); } -/// Match on: -/// ```rust -/// discriminant(_LOCAL_TO_SET) = VAR_IDX; -/// ``` -fn match_set_discr(stmt: &Statement<'_>) -> Option<(Local, VariantIdx)> { - match &stmt.kind { - StatementKind::SetDiscriminant { place, variant_index } => { - Some((place.as_local()?, *variant_index)) - } - _ => None, +impl<'tcx> MirPass<'tcx> for SimplifyArmIdentity { + fn is_enabled(&self, sess: &rustc_session::Session) -> bool { + sess.mir_opt_level() >= 2 } -} -#[derive(PartialEq, Debug)] -struct VarField<'tcx> { - field: Field, - field_ty: Ty<'tcx>, - var_idx: VariantIdx, -} + fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { + let param_env = tcx.param_env(body.source.instance.def_id()); + let (bbs, local_decls, debug_info) = body.basic_blocks_local_decls_mut_and_var_debug_info(); + let mut cleanup = false; + for bb in bbs { + if let Some(info) = get_arm_identity_info(tcx, &bb.statements, local_decls, param_env) { + cleanup = true; + // Apply the optimization as described above. We will collect the statements in the + // bb into three groups. + let mut storage_live = Vec::new(); + let mut storage_dead = Vec::new(); + let mut assigns = Vec::new(); + + for (mut stmt, stmt_type) in + bb.statements.drain(0..info.stmts.len()).zip(info.stmts) + { + match stmt_type { + StatementType::StorageLive => storage_live.push(stmt), + StatementType::StorageDead => storage_dead.push(stmt), + StatementType::AssignPreserve => assigns.push(stmt), + StatementType::AssignForceCopy => { + let StatementKind::Assign(k) = &mut stmt.kind else { unreachable!() }; + let Rvalue::Use(op) = &mut k.1 else { unreachable!() }; + *op = op.to_copy(); + assigns.push(stmt); + } + StatementType::AssignDrop => (), + } + } -/// Match on `((_LOCAL as Variant).FIELD: TY)`. -fn match_variant_field_place<'tcx>(place: Place<'tcx>) -> Option<(Local, VarField<'tcx>)> { - match place.as_ref() { - PlaceRef { - local, - projection: &[ProjectionElem::Downcast(_, var_idx), ProjectionElem::Field(field, ty)], - } => Some((local, VarField { field, field_ty: ty, var_idx })), - _ => None, + // The zeroth statement in `bb.statements` is now the `SetDiscriminant` + let mut new_statements = storage_live; + new_statements.extend(assigns); + // Construct the optimized statement to add in + let optimized = StatementKind::Assign(Box::new(( + info.dest, + Rvalue::Use(match info.move_mode { + MoveMode::Move => Operand::Move(info.src), + MoveMode::Copy => Operand::Copy(info.src), + }), + ))); + new_statements + .push(Statement { source_info: bb.statements[0].source_info, kind: optimized }); + new_statements.extend(storage_dead); + new_statements.extend(bb.statements.drain(1..)); + + bb.statements = new_statements; + + // Finally, update debug info + let mut projs = info.dest.projection.to_vec(); + projs.push(ProjectionElem::Downcast(info.variant_sym, info.variant)); + let base_len = projs.len(); + for debug_info in debug_info.iter_mut() { + let VarDebugInfoContents::Place(place) = &mut debug_info.value else { continue; }; + let Some(&(field, field_ty)) = info.temps.get(&place.local) else { continue; }; + projs.push(ProjectionElem::Field(field, field_ty)); + projs.extend(place.projection); + place.local = info.dest.local; + place.projection = tcx.intern_place_elems(&projs); + projs.truncate(base_len); + } + } + } + if cleanup { + crate::simplify::simplify_locals(body, tcx); + } } } diff --git a/src/test/codegen/try_identity.rs b/src/test/codegen/try_identity.rs index 3ff77163b9f3d..454fac39954ef 100644 --- a/src/test/codegen/try_identity.rs +++ b/src/test/codegen/try_identity.rs @@ -1,4 +1,4 @@ -// compile-flags: -C no-prepopulate-passes -O -Z mir-opt-level=3 -Zunsound-mir-opts +// compile-flags: -C opt-level=3 -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`. 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 240da5577dee5..a0e57ba561a47 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff @@ -6,38 +6,37 @@ let _1: i32; // in scope 0 at $DIR/issue-73223.rs:2:9: 2:14 let mut _2: std::option::Option; // in scope 0 at $DIR/issue-73223.rs:2:23: 2:30 let _3: i32; // in scope 0 at $DIR/issue-73223.rs:3:14: 3:15 - 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 _5: (&i32, &i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _6: &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 _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 _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 _15: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _16: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _17: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _18: 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 + debug split => ((_4 as Some).0: i32); // 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 _19: &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 } } } } scope 2 { - debug v => _3; // in scope 2 at $DIR/issue-73223.rs:3:14: 3:15 + debug v => ((_4 as Some).0: i32); // in scope 2 at $DIR/issue-73223.rs:3:14: 3:15 } bb0: { @@ -46,58 +45,54 @@ ((_2 as Some).0: i32) = const 1_i32; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 discriminant(_2) = 1; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 StorageLive(_3); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 + StorageLive(_4); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 _3 = ((_2 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 _1 = _3; // scope 2 at $DIR/issue-73223.rs:3:20: 3:21 + _4 = _2; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 StorageDead(_3); // scope 0 at $DIR/issue-73223.rs:3:20: 3:21 StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 - 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 - 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(_5); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_6); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _6 = &_1; // 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 + _19 = const main::promoted[0]; // scope 3 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: &i32, val: Unevaluated(main, [], 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 + _7 = _19; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_5.0: &i32) = move _6; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_5.1: &i32) = move _7; // 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 + StorageDead(_6); // 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 = (_5.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 = (_5.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(move _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(move _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(move _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 StorageLive(_15); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _15 = _8; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _14 = _15; // 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 + _17 = _9; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _16 = _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(_18) = 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 _16, move _18); // 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, Option>) -> ! {core::panicking::assert_failed::}, val: Value(Scalar()) } @@ -107,10 +102,10 @@ } 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(_6); // 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(_5); // 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 return; // scope 0 at $DIR/issue-73223.rs:9:2: 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 240da5577dee5..a0e57ba561a47 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff @@ -6,38 +6,37 @@ let _1: i32; // in scope 0 at $DIR/issue-73223.rs:2:9: 2:14 let mut _2: std::option::Option; // in scope 0 at $DIR/issue-73223.rs:2:23: 2:30 let _3: i32; // in scope 0 at $DIR/issue-73223.rs:3:14: 3:15 - 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 _5: (&i32, &i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _6: &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 _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 _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 _15: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _16: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _17: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _18: 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 + debug split => ((_4 as Some).0: i32); // 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 _19: &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 } } } } scope 2 { - debug v => _3; // in scope 2 at $DIR/issue-73223.rs:3:14: 3:15 + debug v => ((_4 as Some).0: i32); // in scope 2 at $DIR/issue-73223.rs:3:14: 3:15 } bb0: { @@ -46,58 +45,54 @@ ((_2 as Some).0: i32) = const 1_i32; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 discriminant(_2) = 1; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 StorageLive(_3); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 + StorageLive(_4); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 _3 = ((_2 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 _1 = _3; // scope 2 at $DIR/issue-73223.rs:3:20: 3:21 + _4 = _2; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 StorageDead(_3); // scope 0 at $DIR/issue-73223.rs:3:20: 3:21 StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 - 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 - 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(_5); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_6); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _6 = &_1; // 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 + _19 = const main::promoted[0]; // scope 3 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: &i32, val: Unevaluated(main, [], 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 + _7 = _19; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_5.0: &i32) = move _6; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_5.1: &i32) = move _7; // 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 + StorageDead(_6); // 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 = (_5.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 = (_5.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(move _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(move _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(move _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 StorageLive(_15); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _15 = _8; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _14 = _15; // 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 + _17 = _9; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _16 = _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(_18) = 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 _16, move _18); // 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, Option>) -> ! {core::panicking::assert_failed::}, val: Value(Scalar()) } @@ -107,10 +102,10 @@ } 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(_6); // 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(_5); // 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 return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff index 1e8b681dfad46..156ac0e69f347 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff @@ -5,47 +5,70 @@ let mut _0: (); // return place in scope 0 at $DIR/issue-73223.rs:1:11: 1:11 let _1: i32; // in scope 0 at $DIR/issue-73223.rs:2:9: 2:14 let mut _2: std::option::Option; // in scope 0 at $DIR/issue-73223.rs:2:23: 2:30 - let mut _3: isize; // in scope 0 at $DIR/issue-73223.rs:3:9: 3:16 - let _4: i32; // in scope 0 at $DIR/issue-73223.rs:3:14: 3:15 - let mut _5: !; // in scope 0 at $DIR/issue-73223.rs:4:17: 4:23 - let mut _7: i32; // in scope 0 at $DIR/issue-73223.rs:7:22: 7:27 - let _8: (); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _9: (&i32, &i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _10: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _11: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _12: i32; // in scope 0 at $DIR/issue-73223.rs:8:23: 8:24 - let mut _15: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _16: bool; // 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 mut _18: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _19: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _21: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _22: core::panicking::AssertKind; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _23: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _24: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _25: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _26: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _27: std::option::Option; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _3: isize; // in scope 0 at $DIR/issue-73223.rs:3:9: 3:16 +- let _4: i32; // in scope 0 at $DIR/issue-73223.rs:3:14: 3:15 +- let mut _5: !; // in scope 0 at $DIR/issue-73223.rs:4:17: 4:23 +- let mut _7: i32; // in scope 0 at $DIR/issue-73223.rs:7:22: 7:27 +- let _8: (); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _9: (&i32, &i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _10: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _11: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let _12: i32; // in scope 0 at $DIR/issue-73223.rs:8:23: 8:24 +- let mut _15: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _16: bool; // 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 mut _18: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _19: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let _21: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _22: core::panicking::AssertKind; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _23: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let _24: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _25: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let _26: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _27: std::option::Option; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ let _3: i32; // in scope 0 at $DIR/issue-73223.rs:3:14: 3:15 ++ let mut _5: (&i32, &i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ let mut _6: &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 _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: 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 _15: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ let mut _16: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ let _17: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ let mut _18: 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 _6: std::option::Option; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 +- debug split => _1; // in scope 1 at $DIR/issue-73223.rs:2:9: 2:14 +- let _6: std::option::Option; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 ++ debug split => ((_4 as Some).0: i32); // 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 => _6; // in scope 3 at $DIR/issue-73223.rs:7:9: 7:14 - let _13: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _14: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _28: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- debug _prev => _6; // in scope 3 at $DIR/issue-73223.rs:7:9: 7:14 +- let _13: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let _14: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _28: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ 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 mut _19: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 4 { - debug left_val => _13; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - debug right_val => _14; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _20: core::panicking::AssertKind; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- debug left_val => _13; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- debug right_val => _14; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let _20: 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 => _20; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- debug kind => _20; // 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 } } } } scope 2 { - debug v => _4; // in scope 2 at $DIR/issue-73223.rs:3:14: 3:15 +- debug v => _4; // in scope 2 at $DIR/issue-73223.rs:3:14: 3:15 ++ debug v => ((_4 as Some).0: i32); // in scope 2 at $DIR/issue-73223.rs:3:14: 3:15 } bb0: { @@ -53,7 +76,7 @@ StorageLive(_2); // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 ((_2 as Some).0: i32) = const 1_i32; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 discriminant(_2) = 1; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 - _3 = const 1_isize; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 +- _3 = const 1_isize; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 goto -> bb2; // scope 0 at $DIR/issue-73223.rs:2:17: 2:30 } @@ -65,71 +88,113 @@ } bb2: { - StorageLive(_4); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 - _4 = ((_2 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 - _1 = _4; // scope 2 at $DIR/issue-73223.rs:3:20: 3:21 - StorageDead(_4); // scope 0 at $DIR/issue-73223.rs:3:20: 3:21 +- StorageLive(_4); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 +- _4 = ((_2 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 +- _1 = _4; // scope 2 at $DIR/issue-73223.rs:3:20: 3:21 +- StorageDead(_4); // scope 0 at $DIR/issue-73223.rs:3:20: 3:21 ++ StorageLive(_3); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 ++ StorageLive(_4); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 ++ _3 = ((_2 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 ++ _1 = _3; // scope 2 at $DIR/issue-73223.rs:3:20: 3:21 ++ _4 = _2; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 ++ StorageDead(_3); // scope 0 at $DIR/issue-73223.rs:3:20: 3:21 StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 - StorageLive(_6); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 - StorageLive(_7); // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 - _7 = _1; // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 - ((_6 as Some).0: i32) = move _7; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 - discriminant(_6) = 1; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 - StorageDead(_7); // scope 1 at $DIR/issue-73223.rs:7:27: 7:28 - StorageLive(_8); // 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 - StorageLive(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _10 = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _28 = const main::promoted[0]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_6); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 +- StorageLive(_7); // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 +- _7 = _1; // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 +- ((_6 as Some).0: i32) = move _7; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 +- discriminant(_6) = 1; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 +- StorageDead(_7); // scope 1 at $DIR/issue-73223.rs:7:27: 7:28 +- StorageLive(_8); // 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 +- StorageLive(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _10 = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _28 = const main::promoted[0]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ StorageLive(_5); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ StorageLive(_6); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ _6 = &_1; // 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 ++ _19 = const main::promoted[0]; // scope 3 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: &i32, val: Unevaluated(main, [], Some(promoted[0])) } - _11 = _28; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_9.0: &i32) = move _10; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _13 = (_9.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _14 = (_9.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _17 = (*_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _18 = const 1_i32; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _16 = Eq(move _17, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _15 = Not(move _16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - switchInt(move _15) -> [false: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _11 = _28; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- (_9.0: &i32) = move _10; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- (_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageDead(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageDead(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _13 = (_9.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _14 = (_9.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _17 = (*_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _18 = const 1_i32; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _16 = Eq(move _17, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageDead(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageDead(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _15 = Not(move _16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageDead(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- switchInt(move _15) -> [false: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ _7 = _19; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ (_5.0: &i32) = move _6; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ (_5.1: &i32) = move _7; // 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 ++ StorageDead(_6); // 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 = (_5.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 = (_5.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 ++ _12 = (*_8); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ _11 = Eq(move _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 ++ _10 = Not(move _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(move _10) -> [false: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } bb3: { - StorageLive(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_20) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_21); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_22); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _22 = const core::panicking::AssertKind::Eq; // 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: core::panicking::AssertKind, val: Value(Scalar(0x00)) } - StorageLive(_23); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_24); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _24 = _13; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _23 = _24; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_25); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_26); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _26 = _14; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _25 = _26; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_27); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_27) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - core::panicking::assert_failed::(const core::panicking::AssertKind::Eq, move _23, move _25, move _27); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- discriminant(_20) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_21); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_22); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _22 = const core::panicking::AssertKind::Eq; // scope 5 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 ++ StorageLive(_15); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ _15 = _8; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ _14 = _15; // 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 ++ StorageLive(_17); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ _17 = _9; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ _16 = _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 ++ discriminant(_18) = 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 _16, move _18); // 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: core::panicking::AssertKind, val: Value(Scalar(0x00)) } +- StorageLive(_23); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_24); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _24 = _13; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _23 = _24; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_25); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_26); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _26 = _14; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _25 = _26; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_27); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- discriminant(_27) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- core::panicking::assert_failed::(const core::panicking::AssertKind::Eq, move _23, move _25, move _27); // 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, Option>) -> ! {core::panicking::assert_failed::}, val: Value(Scalar()) } // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -138,13 +203,16 @@ bb4: { nop; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageDead(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ StorageDead(_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(_5); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL nop; // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 - StorageDead(_6); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 +- StorageDead(_6); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 ++ 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 return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 } diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff index 1e8b681dfad46..156ac0e69f347 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff @@ -5,47 +5,70 @@ let mut _0: (); // return place in scope 0 at $DIR/issue-73223.rs:1:11: 1:11 let _1: i32; // in scope 0 at $DIR/issue-73223.rs:2:9: 2:14 let mut _2: std::option::Option; // in scope 0 at $DIR/issue-73223.rs:2:23: 2:30 - let mut _3: isize; // in scope 0 at $DIR/issue-73223.rs:3:9: 3:16 - let _4: i32; // in scope 0 at $DIR/issue-73223.rs:3:14: 3:15 - let mut _5: !; // in scope 0 at $DIR/issue-73223.rs:4:17: 4:23 - let mut _7: i32; // in scope 0 at $DIR/issue-73223.rs:7:22: 7:27 - let _8: (); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _9: (&i32, &i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _10: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _11: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _12: i32; // in scope 0 at $DIR/issue-73223.rs:8:23: 8:24 - let mut _15: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _16: bool; // 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 mut _18: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _19: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _21: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _22: core::panicking::AssertKind; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _23: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _24: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _25: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _26: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _27: std::option::Option; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _3: isize; // in scope 0 at $DIR/issue-73223.rs:3:9: 3:16 +- let _4: i32; // in scope 0 at $DIR/issue-73223.rs:3:14: 3:15 +- let mut _5: !; // in scope 0 at $DIR/issue-73223.rs:4:17: 4:23 +- let mut _7: i32; // in scope 0 at $DIR/issue-73223.rs:7:22: 7:27 +- let _8: (); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _9: (&i32, &i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _10: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _11: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let _12: i32; // in scope 0 at $DIR/issue-73223.rs:8:23: 8:24 +- let mut _15: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _16: bool; // 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 mut _18: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _19: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let _21: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _22: core::panicking::AssertKind; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _23: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let _24: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _25: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let _26: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _27: std::option::Option; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ let _3: i32; // in scope 0 at $DIR/issue-73223.rs:3:14: 3:15 ++ let mut _5: (&i32, &i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ let mut _6: &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 _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: 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 _15: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ let mut _16: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ let _17: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ let mut _18: 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 _6: std::option::Option; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 +- debug split => _1; // in scope 1 at $DIR/issue-73223.rs:2:9: 2:14 +- let _6: std::option::Option; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 ++ debug split => ((_4 as Some).0: i32); // 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 => _6; // in scope 3 at $DIR/issue-73223.rs:7:9: 7:14 - let _13: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _14: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _28: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- debug _prev => _6; // in scope 3 at $DIR/issue-73223.rs:7:9: 7:14 +- let _13: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let _14: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let mut _28: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ 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 mut _19: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 4 { - debug left_val => _13; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - debug right_val => _14; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _20: core::panicking::AssertKind; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- debug left_val => _13; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- debug right_val => _14; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- let _20: 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 => _20; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- debug kind => _20; // 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 } } } } scope 2 { - debug v => _4; // in scope 2 at $DIR/issue-73223.rs:3:14: 3:15 +- debug v => _4; // in scope 2 at $DIR/issue-73223.rs:3:14: 3:15 ++ debug v => ((_4 as Some).0: i32); // in scope 2 at $DIR/issue-73223.rs:3:14: 3:15 } bb0: { @@ -53,7 +76,7 @@ StorageLive(_2); // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 ((_2 as Some).0: i32) = const 1_i32; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 discriminant(_2) = 1; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 - _3 = const 1_isize; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 +- _3 = const 1_isize; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 goto -> bb2; // scope 0 at $DIR/issue-73223.rs:2:17: 2:30 } @@ -65,71 +88,113 @@ } bb2: { - StorageLive(_4); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 - _4 = ((_2 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 - _1 = _4; // scope 2 at $DIR/issue-73223.rs:3:20: 3:21 - StorageDead(_4); // scope 0 at $DIR/issue-73223.rs:3:20: 3:21 +- StorageLive(_4); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 +- _4 = ((_2 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 +- _1 = _4; // scope 2 at $DIR/issue-73223.rs:3:20: 3:21 +- StorageDead(_4); // scope 0 at $DIR/issue-73223.rs:3:20: 3:21 ++ StorageLive(_3); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 ++ StorageLive(_4); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 ++ _3 = ((_2 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 ++ _1 = _3; // scope 2 at $DIR/issue-73223.rs:3:20: 3:21 ++ _4 = _2; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 ++ StorageDead(_3); // scope 0 at $DIR/issue-73223.rs:3:20: 3:21 StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 - StorageLive(_6); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 - StorageLive(_7); // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 - _7 = _1; // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 - ((_6 as Some).0: i32) = move _7; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 - discriminant(_6) = 1; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 - StorageDead(_7); // scope 1 at $DIR/issue-73223.rs:7:27: 7:28 - StorageLive(_8); // 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 - StorageLive(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _10 = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _28 = const main::promoted[0]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_6); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 +- StorageLive(_7); // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 +- _7 = _1; // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 +- ((_6 as Some).0: i32) = move _7; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 +- discriminant(_6) = 1; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 +- StorageDead(_7); // scope 1 at $DIR/issue-73223.rs:7:27: 7:28 +- StorageLive(_8); // 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 +- StorageLive(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _10 = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _28 = const main::promoted[0]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ StorageLive(_5); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ StorageLive(_6); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ _6 = &_1; // 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 ++ _19 = const main::promoted[0]; // scope 3 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: &i32, val: Unevaluated(main, [], Some(promoted[0])) } - _11 = _28; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_9.0: &i32) = move _10; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _13 = (_9.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _14 = (_9.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _17 = (*_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _18 = const 1_i32; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _16 = Eq(move _17, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _15 = Not(move _16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - switchInt(move _15) -> [false: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _11 = _28; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- (_9.0: &i32) = move _10; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- (_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageDead(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageDead(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _13 = (_9.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _14 = (_9.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _17 = (*_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _18 = const 1_i32; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _16 = Eq(move _17, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageDead(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageDead(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _15 = Not(move _16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageDead(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- switchInt(move _15) -> [false: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ _7 = _19; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ (_5.0: &i32) = move _6; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ (_5.1: &i32) = move _7; // 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 ++ StorageDead(_6); // 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 = (_5.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 = (_5.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 ++ _12 = (*_8); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ _11 = Eq(move _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 ++ _10 = Not(move _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(move _10) -> [false: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } bb3: { - StorageLive(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_20) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_21); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_22); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _22 = const core::panicking::AssertKind::Eq; // 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: core::panicking::AssertKind, val: Value(Scalar(0x00)) } - StorageLive(_23); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_24); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _24 = _13; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _23 = _24; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_25); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_26); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _26 = _14; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _25 = _26; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_27); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_27) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - core::panicking::assert_failed::(const core::panicking::AssertKind::Eq, move _23, move _25, move _27); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- discriminant(_20) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_21); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_22); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _22 = const core::panicking::AssertKind::Eq; // scope 5 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 ++ StorageLive(_15); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ _15 = _8; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ _14 = _15; // 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 ++ StorageLive(_17); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ _17 = _9; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ _16 = _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 ++ discriminant(_18) = 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 _16, move _18); // 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: core::panicking::AssertKind, val: Value(Scalar(0x00)) } +- StorageLive(_23); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_24); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _24 = _13; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _23 = _24; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_25); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_26); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _26 = _14; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- _25 = _26; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageLive(_27); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- discriminant(_27) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- core::panicking::assert_failed::(const core::panicking::AssertKind::Eq, move _23, move _25, move _27); // 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, Option>) -> ! {core::panicking::assert_failed::}, val: Value(Scalar()) } // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -138,13 +203,16 @@ bb4: { nop; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL +- StorageDead(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL ++ StorageDead(_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(_5); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL nop; // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 - StorageDead(_6); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 +- StorageDead(_6); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 ++ 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 return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 } diff --git a/src/test/mir-opt/simplify-locals-removes-unused-discriminant-reads.rs b/src/test/mir-opt/simplify-locals-removes-unused-discriminant-reads.rs deleted file mode 100644 index 84f57deccf7e0..0000000000000 --- a/src/test/mir-opt/simplify-locals-removes-unused-discriminant-reads.rs +++ /dev/null @@ -1,15 +0,0 @@ -// compile-flags: -Zunsound-mir-opts - -fn map(x: Option>) -> Option> { - match x { - None => None, - Some(x) => Some(x), - } -} - -fn main() { - map(None); -} - -// EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.diff diff --git a/src/test/mir-opt/simplify_arm.id.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_arm.id.SimplifyArmIdentity.diff index ad47891294a08..56c9a012a1d75 100644 --- a/src/test/mir-opt/simplify_arm.id.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify_arm.id.SimplifyArmIdentity.diff @@ -2,45 +2,37 @@ + // MIR for `id` after SimplifyArmIdentity fn id(_1: Option) -> Option { - debug o => _1; // in scope 0 at $DIR/simplify-arm.rs:9:7: 9:8 - let mut _0: std::option::Option; // return place in scope 0 at $DIR/simplify-arm.rs:9:25: 9:35 - let mut _2: isize; // in scope 0 at $DIR/simplify-arm.rs:11:9: 11:16 - let _3: u8; // in scope 0 at $DIR/simplify-arm.rs:11:14: 11:15 - let mut _4: u8; // in scope 0 at $DIR/simplify-arm.rs:11:25: 11:26 + debug o => _1; // in scope 0 at $DIR/simplify_arm.rs:5:7: 5:8 + let mut _0: std::option::Option; // return place in scope 0 at $DIR/simplify_arm.rs:5:25: 5:35 + let mut _2: isize; // in scope 0 at $DIR/simplify_arm.rs:7:9: 7:16 +- let _3: u8; // in scope 0 at $DIR/simplify_arm.rs:7:14: 7:15 +- let mut _4: u8; // in scope 0 at $DIR/simplify_arm.rs:7:25: 7:26 scope 1 { -- debug v => _3; // in scope 1 at $DIR/simplify-arm.rs:11:14: 11:15 -+ debug v => ((_0 as Some).0: u8); // in scope 1 at $DIR/simplify-arm.rs:11:14: 11:15 +- debug v => _3; // in scope 1 at $DIR/simplify_arm.rs:7:14: 7:15 ++ debug v => ((_0 as Some).0: u8); // in scope 1 at $DIR/simplify_arm.rs:7:14: 7:15 } bb0: { - _2 = discriminant(_1); // scope 0 at $DIR/simplify-arm.rs:10:11: 10:12 - switchInt(move _2) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:10:5: 10:12 + _2 = discriminant(_1); // scope 0 at $DIR/simplify_arm.rs:6:11: 6:12 + switchInt(move _2) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_arm.rs:6:5: 6:12 } bb1: { - discriminant(_0) = 0; // scope 0 at $DIR/simplify-arm.rs:12:17: 12:21 - goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:12:17: 12:21 + discriminant(_0) = 0; // scope 0 at $DIR/simplify_arm.rs:8:17: 8:21 + return; // scope 0 at $DIR/simplify_arm.rs:8:17: 8:21 } bb2: { - unreachable; // scope 0 at $DIR/simplify-arm.rs:10:11: 10:12 - } - - bb3: { -- StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:11:14: 11:15 -- _3 = ((_1 as Some).0: u8); // scope 0 at $DIR/simplify-arm.rs:11:14: 11:15 -- StorageLive(_4); // scope 1 at $DIR/simplify-arm.rs:11:25: 11:26 -- _4 = _3; // scope 1 at $DIR/simplify-arm.rs:11:25: 11:26 -- ((_0 as Some).0: u8) = move _4; // scope 1 at $DIR/simplify-arm.rs:11:20: 11:27 -- discriminant(_0) = 1; // scope 1 at $DIR/simplify-arm.rs:11:20: 11:27 -- StorageDead(_4); // scope 1 at $DIR/simplify-arm.rs:11:26: 11:27 -- StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:11:26: 11:27 -+ _0 = move _1; // scope 1 at $DIR/simplify-arm.rs:11:20: 11:27 - goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:11:26: 11:27 - } - - bb4: { - return; // scope 0 at $DIR/simplify-arm.rs:14:2: 14:2 +- StorageLive(_3); // scope 0 at $DIR/simplify_arm.rs:7:14: 7:15 +- _3 = ((_1 as Some).0: u8); // scope 0 at $DIR/simplify_arm.rs:7:14: 7:15 +- StorageLive(_4); // scope 1 at $DIR/simplify_arm.rs:7:25: 7:26 +- _4 = _3; // scope 1 at $DIR/simplify_arm.rs:7:25: 7:26 +- ((_0 as Some).0: u8) = move _4; // scope 1 at $DIR/simplify_arm.rs:7:20: 7:27 +- discriminant(_0) = 1; // scope 1 at $DIR/simplify_arm.rs:7:20: 7:27 +- StorageDead(_4); // scope 1 at $DIR/simplify_arm.rs:7:26: 7:27 +- StorageDead(_3); // scope 0 at $DIR/simplify_arm.rs:7:26: 7:27 ++ _0 = _1; // scope 1 at $DIR/simplify_arm.rs:7:20: 7:27 + return; // scope 0 at $DIR/simplify_arm.rs:7:26: 7:27 } } diff --git a/src/test/mir-opt/simplify_arm.id.SimplifyBranchSame.diff b/src/test/mir-opt/simplify_arm.id.SimplifyBranchSame.diff index 52c036a77007c..d1789e3818ebf 100644 --- a/src/test/mir-opt/simplify_arm.id.SimplifyBranchSame.diff +++ b/src/test/mir-opt/simplify_arm.id.SimplifyBranchSame.diff @@ -2,39 +2,27 @@ + // MIR for `id` after SimplifyBranchSame fn id(_1: Option) -> Option { - debug o => _1; // in scope 0 at $DIR/simplify-arm.rs:9:7: 9:8 - let mut _0: std::option::Option; // return place in scope 0 at $DIR/simplify-arm.rs:9:25: 9:35 - let mut _2: isize; // in scope 0 at $DIR/simplify-arm.rs:11:9: 11:16 - let _3: u8; // in scope 0 at $DIR/simplify-arm.rs:11:14: 11:15 - let mut _4: u8; // in scope 0 at $DIR/simplify-arm.rs:11:25: 11:26 + debug o => _1; // in scope 0 at $DIR/simplify_arm.rs:5:7: 5:8 + let mut _0: std::option::Option; // return place in scope 0 at $DIR/simplify_arm.rs:5:25: 5:35 + let mut _2: isize; // in scope 0 at $DIR/simplify_arm.rs:7:9: 7:16 scope 1 { - debug v => ((_0 as Some).0: u8); // in scope 1 at $DIR/simplify-arm.rs:11:14: 11:15 + debug v => ((_0 as Some).0: u8); // in scope 1 at $DIR/simplify_arm.rs:7:14: 7:15 } bb0: { - _2 = discriminant(_1); // scope 0 at $DIR/simplify-arm.rs:10:11: 10:12 -- switchInt(move _2) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:10:5: 10:12 -+ goto -> bb1; // scope 0 at $DIR/simplify-arm.rs:10:5: 10:12 + _2 = discriminant(_1); // scope 0 at $DIR/simplify_arm.rs:6:11: 6:12 +- switchInt(move _2) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_arm.rs:6:5: 6:12 ++ goto -> bb1; // scope 0 at $DIR/simplify_arm.rs:6:5: 6:12 } bb1: { -- discriminant(_0) = 0; // scope 0 at $DIR/simplify-arm.rs:12:17: 12:21 -- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:12:17: 12:21 +- discriminant(_0) = 0; // scope 0 at $DIR/simplify_arm.rs:8:17: 8:21 +- return; // scope 0 at $DIR/simplify_arm.rs:8:17: 8:21 - } - - bb2: { -- unreachable; // scope 0 at $DIR/simplify-arm.rs:10:11: 10:12 -- } -- -- bb3: { - _0 = move _1; // scope 1 at $DIR/simplify-arm.rs:11:20: 11:27 -- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:11:26: 11:27 -+ goto -> bb2; // scope 0 at $DIR/simplify-arm.rs:11:26: 11:27 - } - -- bb4: { -+ bb2: { - return; // scope 0 at $DIR/simplify-arm.rs:14:2: 14:2 + _0 = _1; // scope 1 at $DIR/simplify_arm.rs:7:20: 7:27 + return; // scope 0 at $DIR/simplify_arm.rs:7:26: 7:27 } } diff --git a/src/test/mir-opt/simplify_arm.id_result.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_arm.id_result.SimplifyArmIdentity.diff index b24bdea9b715d..ccd19bbe0f877 100644 --- a/src/test/mir-opt/simplify_arm.id_result.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify_arm.id_result.SimplifyArmIdentity.diff @@ -2,59 +2,51 @@ + // MIR for `id_result` after SimplifyArmIdentity fn id_result(_1: Result) -> Result { - debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:16:14: 16:15 - let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify-arm.rs:16:37: 16:52 - let mut _2: isize; // in scope 0 at $DIR/simplify-arm.rs:18:9: 18:14 - let _3: u8; // in scope 0 at $DIR/simplify-arm.rs:18:12: 18:13 - let mut _4: u8; // in scope 0 at $DIR/simplify-arm.rs:18:21: 18:22 - let _5: i32; // in scope 0 at $DIR/simplify-arm.rs:19:13: 19:14 - let mut _6: i32; // in scope 0 at $DIR/simplify-arm.rs:19:23: 19:24 + debug r => _1; // in scope 0 at $DIR/simplify_arm.rs:14:14: 14:15 + let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_arm.rs:14:37: 14:52 + let mut _2: isize; // in scope 0 at $DIR/simplify_arm.rs:16:9: 16:14 +- let _3: u8; // in scope 0 at $DIR/simplify_arm.rs:16:12: 16:13 +- let mut _4: u8; // in scope 0 at $DIR/simplify_arm.rs:16:21: 16:22 +- let _5: i32; // in scope 0 at $DIR/simplify_arm.rs:17:13: 17:14 +- let mut _6: i32; // in scope 0 at $DIR/simplify_arm.rs:17:23: 17:24 scope 1 { -- debug x => _3; // in scope 1 at $DIR/simplify-arm.rs:18:12: 18:13 -+ debug x => ((_0 as Ok).0: u8); // in scope 1 at $DIR/simplify-arm.rs:18:12: 18:13 +- debug x => _3; // in scope 1 at $DIR/simplify_arm.rs:16:12: 16:13 ++ debug x => ((_0 as Ok).0: u8); // in scope 1 at $DIR/simplify_arm.rs:16:12: 16:13 } scope 2 { -- debug y => _5; // in scope 2 at $DIR/simplify-arm.rs:19:13: 19:14 -+ debug y => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify-arm.rs:19:13: 19:14 +- debug y => _5; // in scope 2 at $DIR/simplify_arm.rs:17:13: 17:14 ++ debug y => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_arm.rs:17:13: 17:14 } bb0: { - _2 = discriminant(_1); // scope 0 at $DIR/simplify-arm.rs:17:11: 17:12 - switchInt(move _2) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:17:5: 17:12 + _2 = discriminant(_1); // scope 0 at $DIR/simplify_arm.rs:15:11: 15:12 + switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/simplify_arm.rs:15:5: 15:12 } bb1: { -- StorageLive(_5); // scope 0 at $DIR/simplify-arm.rs:19:13: 19:14 -- _5 = ((_1 as Err).0: i32); // scope 0 at $DIR/simplify-arm.rs:19:13: 19:14 -- StorageLive(_6); // scope 2 at $DIR/simplify-arm.rs:19:23: 19:24 -- _6 = _5; // scope 2 at $DIR/simplify-arm.rs:19:23: 19:24 -- ((_0 as Err).0: i32) = move _6; // scope 2 at $DIR/simplify-arm.rs:19:19: 19:25 -- discriminant(_0) = 1; // scope 2 at $DIR/simplify-arm.rs:19:19: 19:25 -- StorageDead(_6); // scope 2 at $DIR/simplify-arm.rs:19:24: 19:25 -- StorageDead(_5); // scope 0 at $DIR/simplify-arm.rs:19:24: 19:25 -+ _0 = move _1; // scope 2 at $DIR/simplify-arm.rs:19:19: 19:25 - goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:19:24: 19:25 +- StorageLive(_5); // scope 0 at $DIR/simplify_arm.rs:17:13: 17:14 +- _5 = ((_1 as Err).0: i32); // scope 0 at $DIR/simplify_arm.rs:17:13: 17:14 +- StorageLive(_6); // scope 2 at $DIR/simplify_arm.rs:17:23: 17:24 +- _6 = _5; // scope 2 at $DIR/simplify_arm.rs:17:23: 17:24 +- ((_0 as Err).0: i32) = move _6; // scope 2 at $DIR/simplify_arm.rs:17:19: 17:25 +- discriminant(_0) = 1; // scope 2 at $DIR/simplify_arm.rs:17:19: 17:25 +- StorageDead(_6); // scope 2 at $DIR/simplify_arm.rs:17:24: 17:25 +- StorageDead(_5); // scope 0 at $DIR/simplify_arm.rs:17:24: 17:25 ++ _0 = _1; // scope 2 at $DIR/simplify_arm.rs:17:19: 17:25 + return; // scope 0 at $DIR/simplify_arm.rs:17:24: 17:25 } bb2: { - unreachable; // scope 0 at $DIR/simplify-arm.rs:17:11: 17:12 - } - - bb3: { -- StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:18:12: 18:13 -- _3 = ((_1 as Ok).0: u8); // scope 0 at $DIR/simplify-arm.rs:18:12: 18:13 -- StorageLive(_4); // scope 1 at $DIR/simplify-arm.rs:18:21: 18:22 -- _4 = _3; // scope 1 at $DIR/simplify-arm.rs:18:21: 18:22 -- ((_0 as Ok).0: u8) = move _4; // scope 1 at $DIR/simplify-arm.rs:18:18: 18:23 -- discriminant(_0) = 0; // scope 1 at $DIR/simplify-arm.rs:18:18: 18:23 -- StorageDead(_4); // scope 1 at $DIR/simplify-arm.rs:18:22: 18:23 -- StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:18:22: 18:23 -+ _0 = move _1; // scope 1 at $DIR/simplify-arm.rs:18:18: 18:23 - goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:18:22: 18:23 - } - - bb4: { - return; // scope 0 at $DIR/simplify-arm.rs:21:2: 21:2 +- StorageLive(_3); // scope 0 at $DIR/simplify_arm.rs:16:12: 16:13 +- _3 = ((_1 as Ok).0: u8); // scope 0 at $DIR/simplify_arm.rs:16:12: 16:13 +- StorageLive(_4); // scope 1 at $DIR/simplify_arm.rs:16:21: 16:22 +- _4 = _3; // scope 1 at $DIR/simplify_arm.rs:16:21: 16:22 +- ((_0 as Ok).0: u8) = move _4; // scope 1 at $DIR/simplify_arm.rs:16:18: 16:23 +- discriminant(_0) = 0; // scope 1 at $DIR/simplify_arm.rs:16:18: 16:23 +- StorageDead(_4); // scope 1 at $DIR/simplify_arm.rs:16:22: 16:23 +- StorageDead(_3); // scope 0 at $DIR/simplify_arm.rs:16:22: 16:23 ++ _0 = _1; // scope 1 at $DIR/simplify_arm.rs:16:18: 16:23 + return; // scope 0 at $DIR/simplify_arm.rs:16:22: 16:23 } } diff --git a/src/test/mir-opt/simplify_arm.id_result.SimplifyBranchSame.diff b/src/test/mir-opt/simplify_arm.id_result.SimplifyBranchSame.diff index 4d6a4edb08ae5..4cfdbdb5b3c54 100644 --- a/src/test/mir-opt/simplify_arm.id_result.SimplifyBranchSame.diff +++ b/src/test/mir-opt/simplify_arm.id_result.SimplifyBranchSame.diff @@ -2,44 +2,30 @@ + // MIR for `id_result` after SimplifyBranchSame fn id_result(_1: Result) -> Result { - debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:16:14: 16:15 - let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify-arm.rs:16:37: 16:52 - let mut _2: isize; // in scope 0 at $DIR/simplify-arm.rs:18:9: 18:14 - let _3: u8; // in scope 0 at $DIR/simplify-arm.rs:18:12: 18:13 - let mut _4: u8; // in scope 0 at $DIR/simplify-arm.rs:18:21: 18:22 - let _5: i32; // in scope 0 at $DIR/simplify-arm.rs:19:13: 19:14 - let mut _6: i32; // in scope 0 at $DIR/simplify-arm.rs:19:23: 19:24 + debug r => _1; // in scope 0 at $DIR/simplify_arm.rs:14:14: 14:15 + let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_arm.rs:14:37: 14:52 + let mut _2: isize; // in scope 0 at $DIR/simplify_arm.rs:16:9: 16:14 scope 1 { - debug x => ((_0 as Ok).0: u8); // in scope 1 at $DIR/simplify-arm.rs:18:12: 18:13 + debug x => ((_0 as Ok).0: u8); // in scope 1 at $DIR/simplify_arm.rs:16:12: 16:13 } scope 2 { - debug y => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify-arm.rs:19:13: 19:14 + debug y => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_arm.rs:17:13: 17:14 } bb0: { - _2 = discriminant(_1); // scope 0 at $DIR/simplify-arm.rs:17:11: 17:12 -- switchInt(move _2) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:17:5: 17:12 -+ goto -> bb1; // scope 0 at $DIR/simplify-arm.rs:17:5: 17:12 + _2 = discriminant(_1); // scope 0 at $DIR/simplify_arm.rs:15:11: 15:12 +- switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/simplify_arm.rs:15:5: 15:12 ++ goto -> bb1; // scope 0 at $DIR/simplify_arm.rs:15:5: 15:12 } bb1: { -- _0 = move _1; // scope 2 at $DIR/simplify-arm.rs:19:19: 19:25 -- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:19:24: 19:25 +- _0 = _1; // scope 2 at $DIR/simplify_arm.rs:17:19: 17:25 +- return; // scope 0 at $DIR/simplify_arm.rs:17:24: 17:25 - } - - bb2: { -- unreachable; // scope 0 at $DIR/simplify-arm.rs:17:11: 17:12 -- } -- -- bb3: { - _0 = move _1; // scope 1 at $DIR/simplify-arm.rs:18:18: 18:23 -- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:18:22: 18:23 -+ goto -> bb2; // scope 0 at $DIR/simplify-arm.rs:18:22: 18:23 - } - -- bb4: { -+ bb2: { - return; // scope 0 at $DIR/simplify-arm.rs:21:2: 21:2 + _0 = _1; // scope 1 at $DIR/simplify_arm.rs:16:18: 16:23 + return; // scope 0 at $DIR/simplify_arm.rs:16:22: 16:23 } } 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 272a6756f39f2..755a912d01ef0 100644 --- a/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff @@ -2,93 +2,98 @@ + // MIR for `id_try` after SimplifyArmIdentity fn id_try(_1: Result) -> Result { - debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:35:11: 35:12 - let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify-arm.rs:35:34: 35:49 - let _2: u8; // in scope 0 at $DIR/simplify-arm.rs:36:9: 36:10 - let mut _3: std::result::Result; // in scope 0 at $DIR/simplify-arm.rs:36:19: 36:33 - let mut _4: std::result::Result; // in scope 0 at $DIR/simplify-arm.rs:36:31: 36:32 - let mut _5: isize; // in scope 0 at $DIR/simplify-arm.rs:37:9: 37:15 - let _6: i32; // in scope 0 at $DIR/simplify-arm.rs:37:13: 37:14 - let mut _7: !; // in scope 0 at $DIR/simplify-arm.rs:37:19: 37:51 - let mut _8: i32; // in scope 0 at $DIR/simplify-arm.rs:37:37: 37:50 - let mut _9: i32; // in scope 0 at $DIR/simplify-arm.rs:37:48: 37:49 - let _10: u8; // in scope 0 at $DIR/simplify-arm.rs:38:12: 38:13 - let mut _11: u8; // in scope 0 at $DIR/simplify-arm.rs:40:8: 40:9 + debug r => _1; // in scope 0 at $DIR/simplify_arm.rs:35:11: 35:12 + let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_arm.rs:35:34: 35:49 +- let _2: u8; // in scope 0 at $DIR/simplify_arm.rs:36:9: 36:10 +- let mut _3: std::result::Result; // in scope 0 at $DIR/simplify_arm.rs:36:19: 36:33 +- let mut _4: std::result::Result; // in scope 0 at $DIR/simplify_arm.rs:36:31: 36:32 +- let mut _5: isize; // in scope 0 at $DIR/simplify_arm.rs:37:9: 37:15 +- let _6: i32; // in scope 0 at $DIR/simplify_arm.rs:37:13: 37:14 +- let mut _7: !; // in scope 0 at $DIR/simplify_arm.rs:37:19: 37:51 +- let mut _8: i32; // in scope 0 at $DIR/simplify_arm.rs:37:37: 37:50 +- let mut _9: i32; // in scope 0 at $DIR/simplify_arm.rs:37:48: 37:49 +- let _10: u8; // in scope 0 at $DIR/simplify_arm.rs:38:12: 38:13 +- let mut _11: u8; // in scope 0 at $DIR/simplify_arm.rs:40:8: 40:9 ++ let mut _2: std::result::Result; // in scope 0 at $DIR/simplify_arm.rs:36:19: 36:33 ++ let mut _3: std::result::Result; // in scope 0 at $DIR/simplify_arm.rs:36:31: 36:32 ++ let mut _4: isize; // in scope 0 at $DIR/simplify_arm.rs:37:9: 37:15 scope 1 { -- debug x => _2; // in scope 1 at $DIR/simplify-arm.rs:36:9: 36:10 -+ debug x => ((_0 as Ok).0: u8); // in scope 1 at $DIR/simplify-arm.rs:36:9: 36:10 +- debug x => _2; // in scope 1 at $DIR/simplify_arm.rs:36:9: 36:10 ++ 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 - 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 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 + 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 } - 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 + 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 } } scope 3 { -- debug v => _10; // in scope 3 at $DIR/simplify-arm.rs:38:12: 38:13 -+ debug v => ((_0 as Ok).0: u8); // in scope 3 at $DIR/simplify-arm.rs:38:12: 38:13 +- debug v => _10; // in scope 3 at $DIR/simplify_arm.rs:38:12: 38:13 ++ debug v => ((_0 as Ok).0: u8); // in scope 3 at $DIR/simplify_arm.rs:38:12: 38:13 } - scope 4 (inlined into_result::) { // at $DIR/simplify-arm.rs:36:19: 36:33 - debug r => _4; // in scope 4 at $DIR/simplify-arm.rs:36:19: 36:33 + scope 4 (inlined into_result::) { // at $DIR/simplify_arm.rs:36:19: 36:33 +- debug r => _4; // in scope 4 at $DIR/simplify_arm.rs:36:19: 36:33 ++ debug r => _3; // in scope 4 at $DIR/simplify_arm.rs:36:19: 36:33 } bb0: { - StorageLive(_2); // scope 0 at $DIR/simplify-arm.rs:36:9: 36:10 - 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 - StorageDead(_4); // scope 0 at $DIR/simplify-arm.rs:36:32: 36:33 - _5 = discriminant(_3); // scope 0 at $DIR/simplify-arm.rs:36:19: 36:33 - switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:36:13: 36:33 +- StorageLive(_2); // scope 0 at $DIR/simplify_arm.rs:36:9: 36:10 +- 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 +- StorageDead(_4); // scope 0 at $DIR/simplify_arm.rs:36:32: 36:33 +- _5 = discriminant(_3); // scope 0 at $DIR/simplify_arm.rs:36:19: 36:33 +- switchInt(move _5) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_arm.rs:36:13: 36:33 ++ StorageLive(_2); // scope 0 at $DIR/simplify_arm.rs:36:19: 36:33 ++ StorageLive(_3); // scope 0 at $DIR/simplify_arm.rs:36:31: 36:32 ++ _3 = _1; // scope 0 at $DIR/simplify_arm.rs:36:31: 36:32 ++ _2 = move _3; // scope 4 at $DIR/simplify_arm.rs:36:19: 36:33 ++ StorageDead(_3); // scope 0 at $DIR/simplify_arm.rs:36:32: 36:33 ++ _4 = discriminant(_2); // scope 0 at $DIR/simplify_arm.rs:36:19: 36:33 ++ switchInt(move _4) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_arm.rs:36:13: 36:33 } bb1: { -- StorageLive(_10); // scope 0 at $DIR/simplify-arm.rs:38:12: 38:13 -- _10 = ((_3 as Ok).0: u8); // scope 0 at $DIR/simplify-arm.rs:38:12: 38:13 -- _2 = _10; // scope 3 at $DIR/simplify-arm.rs:38:18: 38:19 -- StorageDead(_10); // scope 0 at $DIR/simplify-arm.rs:38:18: 38:19 -+ _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 -- StorageLive(_11); // scope 1 at $DIR/simplify-arm.rs:40:8: 40:9 -- _11 = _2; // scope 1 at $DIR/simplify-arm.rs:40:8: 40:9 -- ((_0 as Ok).0: u8) = move _11; // scope 1 at $DIR/simplify-arm.rs:40:5: 40:10 -- discriminant(_0) = 0; // scope 1 at $DIR/simplify-arm.rs:40:5: 40:10 -- StorageDead(_11); // scope 1 at $DIR/simplify-arm.rs:40:9: 40:10 - 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 +- StorageLive(_10); // scope 0 at $DIR/simplify_arm.rs:38:12: 38:13 +- _10 = ((_3 as Ok).0: u8); // scope 0 at $DIR/simplify_arm.rs:38:12: 38:13 +- _2 = _10; // scope 3 at $DIR/simplify_arm.rs:38:18: 38:19 +- StorageDead(_10); // scope 0 at $DIR/simplify_arm.rs:38:18: 38:19 +- StorageDead(_3); // scope 0 at $DIR/simplify_arm.rs:39:6: 39:7 +- StorageLive(_11); // scope 1 at $DIR/simplify_arm.rs:40:8: 40:9 +- _11 = _2; // scope 1 at $DIR/simplify_arm.rs:40:8: 40:9 +- ((_0 as Ok).0: u8) = move _11; // scope 1 at $DIR/simplify_arm.rs:40:5: 40:10 +- discriminant(_0) = 0; // scope 1 at $DIR/simplify_arm.rs:40:5: 40:10 +- StorageDead(_11); // scope 1 at $DIR/simplify_arm.rs:40:9: 40:10 +- StorageDead(_2); // scope 0 at $DIR/simplify_arm.rs:41:1: 41:2 ++ _0 = _2; // scope 1 at $DIR/simplify_arm.rs:40:5: 40:10 ++ StorageDead(_2); // scope 0 at $DIR/simplify_arm.rs:39:6: 39:7 + return; // 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: { -- 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 - 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 +- 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 +- 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 ++ _0 = _2; // scope 6 at $DIR/simplify_arm.rs:37:26: 37:51 ++ StorageDead(_2); // scope 0 at $DIR/simplify_arm.rs:39:6: 39:7 + return; // 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 651a37f5a9722..49979a7175712 100644 --- a/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff +++ b/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff @@ -2,70 +2,51 @@ + // MIR for `id_try` after SimplifyBranchSame fn id_try(_1: Result) -> Result { - debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:35:11: 35:12 - let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify-arm.rs:35:34: 35:49 - let _2: u8; // in scope 0 at $DIR/simplify-arm.rs:36:9: 36:10 - let mut _3: std::result::Result; // in scope 0 at $DIR/simplify-arm.rs:36:19: 36:33 - let mut _4: std::result::Result; // in scope 0 at $DIR/simplify-arm.rs:36:31: 36:32 - let mut _5: isize; // in scope 0 at $DIR/simplify-arm.rs:37:9: 37:15 - let _6: i32; // in scope 0 at $DIR/simplify-arm.rs:37:13: 37:14 - let mut _7: !; // in scope 0 at $DIR/simplify-arm.rs:37:19: 37:51 - let mut _8: i32; // in scope 0 at $DIR/simplify-arm.rs:37:37: 37:50 - let mut _9: i32; // in scope 0 at $DIR/simplify-arm.rs:37:48: 37:49 - let _10: u8; // in scope 0 at $DIR/simplify-arm.rs:38:12: 38:13 - let mut _11: u8; // in scope 0 at $DIR/simplify-arm.rs:40:8: 40:9 + debug r => _1; // in scope 0 at $DIR/simplify_arm.rs:35:11: 35:12 + let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_arm.rs:35:34: 35:49 + let mut _2: std::result::Result; // in scope 0 at $DIR/simplify_arm.rs:36:19: 36:33 + let mut _3: std::result::Result; // in scope 0 at $DIR/simplify_arm.rs:36:31: 36:32 + let mut _4: isize; // in scope 0 at $DIR/simplify_arm.rs:37:9: 37:15 scope 1 { - debug x => ((_0 as Ok).0: u8); // in scope 1 at $DIR/simplify-arm.rs:36:9: 36:10 + 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 - 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 e => ((_0 as Err).0: i32); // 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 } - 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 + 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 } } scope 3 { - debug v => ((_0 as Ok).0: u8); // in scope 3 at $DIR/simplify-arm.rs:38:12: 38:13 + debug v => ((_0 as Ok).0: u8); // in scope 3 at $DIR/simplify_arm.rs:38:12: 38:13 } - scope 4 (inlined into_result::) { // at $DIR/simplify-arm.rs:36:19: 36:33 - debug r => _4; // in scope 4 at $DIR/simplify-arm.rs:36:19: 36:33 + scope 4 (inlined into_result::) { // at $DIR/simplify_arm.rs:36:19: 36:33 + debug r => _3; // in scope 4 at $DIR/simplify_arm.rs:36:19: 36:33 } bb0: { - StorageLive(_2); // scope 0 at $DIR/simplify-arm.rs:36:9: 36:10 - 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 - StorageDead(_4); // scope 0 at $DIR/simplify-arm.rs:36:32: 36:33 - _5 = discriminant(_3); // scope 0 at $DIR/simplify-arm.rs:36:19: 36:33 -- switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:36:13: 36:33 -+ goto -> bb1; // scope 0 at $DIR/simplify-arm.rs:36:13: 36:33 + StorageLive(_2); // scope 0 at $DIR/simplify_arm.rs:36:19: 36:33 + StorageLive(_3); // scope 0 at $DIR/simplify_arm.rs:36:31: 36:32 + _3 = _1; // scope 0 at $DIR/simplify_arm.rs:36:31: 36:32 + _2 = move _3; // scope 4 at $DIR/simplify_arm.rs:36:19: 36:33 + StorageDead(_3); // scope 0 at $DIR/simplify_arm.rs:36:32: 36:33 + _4 = discriminant(_2); // scope 0 at $DIR/simplify_arm.rs:36:19: 36:33 +- switchInt(move _4) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_arm.rs:36:13: 36:33 ++ goto -> bb1; // scope 0 at $DIR/simplify_arm.rs:36:13: 36:33 } 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 - } - - 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 + _0 = _2; // scope 1 at $DIR/simplify_arm.rs:40:5: 40:10 +- StorageDead(_2); // scope 0 at $DIR/simplify_arm.rs:39:6: 39:7 +- return; // scope 0 at $DIR/simplify_arm.rs:41:2: 41:2 - } - -- bb4: { - return; // scope 0 at $DIR/simplify-arm.rs:41:2: 41:2 +- bb2: { +- _0 = _2; // scope 6 at $DIR/simplify_arm.rs:37:26: 37:51 + StorageDead(_2); // scope 0 at $DIR/simplify_arm.rs:39:6: 39:7 + return; // scope 0 at $DIR/simplify_arm.rs:41:2: 41:2 } } diff --git a/src/test/mir-opt/simplify_arm.multi_field_id.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_arm.multi_field_id.SimplifyArmIdentity.diff new file mode 100644 index 0000000000000..0bef018e00893 --- /dev/null +++ b/src/test/mir-opt/simplify_arm.multi_field_id.SimplifyArmIdentity.diff @@ -0,0 +1,85 @@ +- // MIR for `multi_field_id` before SimplifyArmIdentity ++ // MIR for `multi_field_id` after SimplifyArmIdentity + + fn multi_field_id(_1: MultiField) -> MultiField { + debug x => _1; // in scope 0 at $DIR/simplify_arm.rs:50:19: 50:20 + let mut _0: MultiField; // return place in scope 0 at $DIR/simplify_arm.rs:50:37: 50:47 + let mut _2: isize; // in scope 0 at $DIR/simplify_arm.rs:52:9: 52:28 +- let _3: u32; // in scope 0 at $DIR/simplify_arm.rs:52:23: 52:24 +- let _4: u32; // in scope 0 at $DIR/simplify_arm.rs:52:26: 52:27 +- let mut _5: u32; // in scope 0 at $DIR/simplify_arm.rs:52:46: 52:47 +- let mut _6: u32; // in scope 0 at $DIR/simplify_arm.rs:52:49: 52:50 +- let _7: u32; // in scope 0 at $DIR/simplify_arm.rs:53:23: 53:24 +- let _8: u32; // in scope 0 at $DIR/simplify_arm.rs:53:26: 53:27 +- let _9: u32; // in scope 0 at $DIR/simplify_arm.rs:53:29: 53:30 +- let mut _10: u32; // in scope 0 at $DIR/simplify_arm.rs:53:49: 53:50 +- let mut _11: u32; // in scope 0 at $DIR/simplify_arm.rs:53:52: 53:53 +- let mut _12: u32; // in scope 0 at $DIR/simplify_arm.rs:53:55: 53:56 + scope 1 { +- debug a => _3; // in scope 1 at $DIR/simplify_arm.rs:52:23: 52:24 +- debug b => _4; // in scope 1 at $DIR/simplify_arm.rs:52:26: 52:27 ++ debug a => ((_0 as A).0: u32); // in scope 1 at $DIR/simplify_arm.rs:52:23: 52:24 ++ debug b => ((_0 as A).1: u32); // in scope 1 at $DIR/simplify_arm.rs:52:26: 52:27 + } + scope 2 { +- debug a => _7; // in scope 2 at $DIR/simplify_arm.rs:53:23: 53:24 +- debug b => _8; // in scope 2 at $DIR/simplify_arm.rs:53:26: 53:27 +- debug c => _9; // in scope 2 at $DIR/simplify_arm.rs:53:29: 53:30 ++ debug a => ((_0 as B).0: u32); // in scope 2 at $DIR/simplify_arm.rs:53:23: 53:24 ++ debug b => ((_0 as B).1: u32); // in scope 2 at $DIR/simplify_arm.rs:53:26: 53:27 ++ debug c => ((_0 as B).2: u32); // in scope 2 at $DIR/simplify_arm.rs:53:29: 53:30 + } + + bb0: { + _2 = discriminant(_1); // scope 0 at $DIR/simplify_arm.rs:51:11: 51:12 + switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/simplify_arm.rs:51:5: 51:12 + } + + bb1: { +- StorageLive(_7); // scope 0 at $DIR/simplify_arm.rs:53:23: 53:24 +- _7 = ((_1 as B).0: u32); // scope 0 at $DIR/simplify_arm.rs:53:23: 53:24 +- StorageLive(_8); // scope 0 at $DIR/simplify_arm.rs:53:26: 53:27 +- _8 = ((_1 as B).1: u32); // scope 0 at $DIR/simplify_arm.rs:53:26: 53:27 +- StorageLive(_9); // scope 0 at $DIR/simplify_arm.rs:53:29: 53:30 +- _9 = ((_1 as B).2: u32); // scope 0 at $DIR/simplify_arm.rs:53:29: 53:30 +- StorageLive(_10); // scope 2 at $DIR/simplify_arm.rs:53:49: 53:50 +- _10 = _7; // scope 2 at $DIR/simplify_arm.rs:53:49: 53:50 +- StorageLive(_11); // scope 2 at $DIR/simplify_arm.rs:53:52: 53:53 +- _11 = _8; // scope 2 at $DIR/simplify_arm.rs:53:52: 53:53 +- StorageLive(_12); // scope 2 at $DIR/simplify_arm.rs:53:55: 53:56 +- _12 = _9; // scope 2 at $DIR/simplify_arm.rs:53:55: 53:56 +- ((_0 as B).0: u32) = move _10; // scope 2 at $DIR/simplify_arm.rs:53:35: 53:57 +- ((_0 as B).1: u32) = move _11; // scope 2 at $DIR/simplify_arm.rs:53:35: 53:57 +- ((_0 as B).2: u32) = move _12; // scope 2 at $DIR/simplify_arm.rs:53:35: 53:57 +- discriminant(_0) = 1; // scope 2 at $DIR/simplify_arm.rs:53:35: 53:57 +- StorageDead(_12); // scope 2 at $DIR/simplify_arm.rs:53:56: 53:57 +- StorageDead(_11); // scope 2 at $DIR/simplify_arm.rs:53:56: 53:57 +- StorageDead(_10); // scope 2 at $DIR/simplify_arm.rs:53:56: 53:57 +- StorageDead(_9); // scope 0 at $DIR/simplify_arm.rs:53:56: 53:57 +- StorageDead(_8); // scope 0 at $DIR/simplify_arm.rs:53:56: 53:57 +- StorageDead(_7); // scope 0 at $DIR/simplify_arm.rs:53:56: 53:57 ++ _0 = _1; // scope 2 at $DIR/simplify_arm.rs:53:35: 53:57 + return; // scope 0 at $DIR/simplify_arm.rs:53:56: 53:57 + } + + bb2: { +- StorageLive(_3); // scope 0 at $DIR/simplify_arm.rs:52:23: 52:24 +- _3 = ((_1 as A).0: u32); // scope 0 at $DIR/simplify_arm.rs:52:23: 52:24 +- StorageLive(_4); // scope 0 at $DIR/simplify_arm.rs:52:26: 52:27 +- _4 = ((_1 as A).1: u32); // scope 0 at $DIR/simplify_arm.rs:52:26: 52:27 +- StorageLive(_5); // scope 1 at $DIR/simplify_arm.rs:52:46: 52:47 +- _5 = _3; // scope 1 at $DIR/simplify_arm.rs:52:46: 52:47 +- StorageLive(_6); // scope 1 at $DIR/simplify_arm.rs:52:49: 52:50 +- _6 = _4; // scope 1 at $DIR/simplify_arm.rs:52:49: 52:50 +- ((_0 as A).0: u32) = move _5; // scope 1 at $DIR/simplify_arm.rs:52:32: 52:51 +- ((_0 as A).1: u32) = move _6; // scope 1 at $DIR/simplify_arm.rs:52:32: 52:51 +- discriminant(_0) = 0; // scope 1 at $DIR/simplify_arm.rs:52:32: 52:51 +- StorageDead(_6); // scope 1 at $DIR/simplify_arm.rs:52:50: 52:51 +- StorageDead(_5); // scope 1 at $DIR/simplify_arm.rs:52:50: 52:51 +- StorageDead(_4); // scope 0 at $DIR/simplify_arm.rs:52:50: 52:51 +- StorageDead(_3); // scope 0 at $DIR/simplify_arm.rs:52:50: 52:51 ++ _0 = _1; // scope 1 at $DIR/simplify_arm.rs:52:32: 52:51 + return; // scope 0 at $DIR/simplify_arm.rs:52:50: 52:51 + } + } + diff --git a/src/test/mir-opt/simplify_arm.non_copy_id.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_arm.non_copy_id.SimplifyArmIdentity.diff new file mode 100644 index 0000000000000..6ffb85cc6ba4e --- /dev/null +++ b/src/test/mir-opt/simplify_arm.non_copy_id.SimplifyArmIdentity.diff @@ -0,0 +1,65 @@ +- // MIR for `non_copy_id` before SimplifyArmIdentity ++ // MIR for `non_copy_id` after SimplifyArmIdentity + + fn non_copy_id(_1: NonCopy) -> NonCopy { + debug x => _1; // in scope 0 at $DIR/simplify_arm.rs:63:16: 63:17 + let mut _0: NonCopy; // return place in scope 0 at $DIR/simplify_arm.rs:63:31: 63:38 + let mut _2: isize; // in scope 0 at $DIR/simplify_arm.rs:65:9: 65:22 +- let _3: std::string::String; // in scope 0 at $DIR/simplify_arm.rs:65:20: 65:21 +- let mut _4: std::string::String; // in scope 0 at $DIR/simplify_arm.rs:65:37: 65:38 +- let _5: std::vec::Vec; // in scope 0 at $DIR/simplify_arm.rs:66:20: 66:21 +- let mut _6: std::vec::Vec; // in scope 0 at $DIR/simplify_arm.rs:66:37: 66:38 +- let mut _7: bool; // in scope 0 at $DIR/simplify_arm.rs:68:1: 68:2 +- let mut _8: bool; // in scope 0 at $DIR/simplify_arm.rs:68:1: 68:2 +- let mut _9: isize; // in scope 0 at $DIR/simplify_arm.rs:68:1: 68:2 +- let mut _10: isize; // in scope 0 at $DIR/simplify_arm.rs:68:1: 68:2 + scope 1 { +- debug a => _3; // in scope 1 at $DIR/simplify_arm.rs:65:20: 65:21 ++ debug a => ((_0 as A).0: std::string::String); // in scope 1 at $DIR/simplify_arm.rs:65:20: 65:21 + } + scope 2 { +- debug b => _5; // in scope 2 at $DIR/simplify_arm.rs:66:20: 66:21 ++ debug b => ((_0 as B).0: std::vec::Vec); // in scope 2 at $DIR/simplify_arm.rs:66:20: 66:21 + } + + bb0: { +- _7 = const false; // scope 0 at $DIR/simplify_arm.rs:64:11: 64:12 +- _8 = const false; // scope 0 at $DIR/simplify_arm.rs:64:11: 64:12 +- _7 = const true; // scope 0 at $DIR/simplify_arm.rs:64:11: 64:12 +- _8 = const true; // scope 0 at $DIR/simplify_arm.rs:64:11: 64:12 + _2 = discriminant(_1); // scope 0 at $DIR/simplify_arm.rs:64:11: 64:12 + switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/simplify_arm.rs:64:5: 64:12 + } + + bb1: { +- StorageLive(_5); // scope 0 at $DIR/simplify_arm.rs:66:20: 66:21 +- _5 = move ((_1 as B).0: std::vec::Vec); // scope 0 at $DIR/simplify_arm.rs:66:20: 66:21 +- StorageLive(_6); // scope 2 at $DIR/simplify_arm.rs:66:37: 66:38 +- _6 = move _5; // scope 2 at $DIR/simplify_arm.rs:66:37: 66:38 +- ((_0 as B).0: std::vec::Vec) = move _6; // scope 2 at $DIR/simplify_arm.rs:66:26: 66:39 +- discriminant(_0) = 1; // scope 2 at $DIR/simplify_arm.rs:66:26: 66:39 +- StorageDead(_6); // scope 2 at $DIR/simplify_arm.rs:66:38: 66:39 +- StorageDead(_5); // scope 0 at $DIR/simplify_arm.rs:66:38: 66:39 ++ _0 = move _1; // scope 2 at $DIR/simplify_arm.rs:66:26: 66:39 + goto -> bb3; // scope 0 at $DIR/simplify_arm.rs:66:38: 66:39 + } + + bb2: { +- StorageLive(_3); // scope 0 at $DIR/simplify_arm.rs:65:20: 65:21 +- _3 = move ((_1 as A).0: std::string::String); // scope 0 at $DIR/simplify_arm.rs:65:20: 65:21 +- StorageLive(_4); // scope 1 at $DIR/simplify_arm.rs:65:37: 65:38 +- _4 = move _3; // scope 1 at $DIR/simplify_arm.rs:65:37: 65:38 +- ((_0 as A).0: std::string::String) = move _4; // scope 1 at $DIR/simplify_arm.rs:65:26: 65:39 +- discriminant(_0) = 0; // scope 1 at $DIR/simplify_arm.rs:65:26: 65:39 +- StorageDead(_4); // scope 1 at $DIR/simplify_arm.rs:65:38: 65:39 +- StorageDead(_3); // scope 0 at $DIR/simplify_arm.rs:65:38: 65:39 ++ _0 = move _1; // scope 1 at $DIR/simplify_arm.rs:65:26: 65:39 + goto -> bb3; // scope 0 at $DIR/simplify_arm.rs:65:38: 65:39 + } + + bb3: { +- _9 = discriminant(_1); // scope 0 at $DIR/simplify_arm.rs:68:1: 68:2 + return; // scope 0 at $DIR/simplify_arm.rs:68:2: 68:2 + } + } + diff --git a/src/test/mir-opt/simplify-arm.rs b/src/test/mir-opt/simplify_arm.rs similarity index 64% rename from src/test/mir-opt/simplify-arm.rs rename to src/test/mir-opt/simplify_arm.rs index f7dcaa13449ea..b10aac5cf1880 100644 --- a/src/test/mir-opt/simplify-arm.rs +++ b/src/test/mir-opt/simplify_arm.rs @@ -1,11 +1,7 @@ -// compile-flags: -Z mir-opt-level=3 -Zunsound-mir-opts +// compile-flags: -Zunsound-mir-opts + // EMIT_MIR simplify_arm.id.SimplifyArmIdentity.diff // EMIT_MIR simplify_arm.id.SimplifyBranchSame.diff -// EMIT_MIR simplify_arm.id_result.SimplifyArmIdentity.diff -// EMIT_MIR simplify_arm.id_result.SimplifyBranchSame.diff -// EMIT_MIR simplify_arm.id_try.SimplifyArmIdentity.diff -// EMIT_MIR simplify_arm.id_try.SimplifyBranchSame.diff - fn id(o: Option) -> Option { match o { Some(v) => Some(v), @@ -13,6 +9,8 @@ fn id(o: Option) -> Option { } } +// EMIT_MIR simplify_arm.id_result.SimplifyArmIdentity.diff +// EMIT_MIR simplify_arm.id_result.SimplifyBranchSame.diff fn id_result(r: Result) -> Result { match r { Ok(x) => Ok(x), @@ -32,6 +30,8 @@ fn from_error(e: E) -> Result { // 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. +// EMIT_MIR simplify_arm.id_try.SimplifyArmIdentity.diff +// EMIT_MIR simplify_arm.id_try.SimplifyBranchSame.diff fn id_try(r: Result) -> Result { let x = match into_result(r) { Err(e) => return from_error(From::from(e)), @@ -40,8 +40,37 @@ fn id_try(r: Result) -> Result { Ok(x) } +#[derive(Copy, Clone)] +enum MultiField { + A(u32, u32), + B(u32, u32, u32), +} + +// EMIT_MIR simplify_arm.multi_field_id.SimplifyArmIdentity.diff +fn multi_field_id(x: MultiField) -> MultiField { + match x { + MultiField::A(a, b) => MultiField::A(a, b), + MultiField::B(a, b, c) => MultiField::B(a, b, c), + } +} + +enum NonCopy { + A(String), + B(Vec), +} + +// EMIT_MIR simplify_arm.non_copy_id.SimplifyArmIdentity.diff +fn non_copy_id(x: NonCopy) -> NonCopy { + match x { + NonCopy::A(a) => NonCopy::A(a), + NonCopy::B(b) => NonCopy::B(b), + } +} + fn main() { id(None); id_result(Ok(4)); id_try(Ok(4)); + multi_field_id(MultiField::A(0, 0)); + non_copy_id(NonCopy::A(String::new())); } diff --git a/src/test/mir-opt/simplify_arm_correctness.mismatched_variant.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_arm_correctness.mismatched_variant.SimplifyArmIdentity.diff new file mode 100644 index 0000000000000..7ced603386a7a --- /dev/null +++ b/src/test/mir-opt/simplify_arm_correctness.mismatched_variant.SimplifyArmIdentity.diff @@ -0,0 +1,48 @@ +- // MIR for `mismatched_variant` before SimplifyArmIdentity ++ // MIR for `mismatched_variant` after SimplifyArmIdentity + + fn mismatched_variant(_1: Result) -> Result { + debug x => _1; // in scope 0 at $DIR/simplify_arm_correctness.rs:33:23: 33:24 + let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_arm_correctness.rs:33:47: 33:63 + let mut _2: isize; // in scope 0 at $DIR/simplify_arm_correctness.rs:35:9: 35:14 + let _3: u32; // in scope 0 at $DIR/simplify_arm_correctness.rs:35:12: 35:13 + let mut _4: u32; // in scope 0 at $DIR/simplify_arm_correctness.rs:35:22: 35:23 + let _5: u32; // in scope 0 at $DIR/simplify_arm_correctness.rs:36:13: 36:14 + let mut _6: u32; // in scope 0 at $DIR/simplify_arm_correctness.rs:36:22: 36:23 + scope 1 { + debug a => _3; // in scope 1 at $DIR/simplify_arm_correctness.rs:35:12: 35:13 + } + scope 2 { + debug a => _5; // in scope 2 at $DIR/simplify_arm_correctness.rs:36:13: 36:14 + } + + bb0: { + _2 = discriminant(_1); // scope 0 at $DIR/simplify_arm_correctness.rs:34:11: 34:12 + switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/simplify_arm_correctness.rs:34:5: 34:12 + } + + bb1: { + StorageLive(_5); // scope 0 at $DIR/simplify_arm_correctness.rs:36:13: 36:14 + _5 = ((_1 as Err).0: u32); // scope 0 at $DIR/simplify_arm_correctness.rs:36:13: 36:14 + StorageLive(_6); // scope 2 at $DIR/simplify_arm_correctness.rs:36:22: 36:23 + _6 = _5; // scope 2 at $DIR/simplify_arm_correctness.rs:36:22: 36:23 + ((_0 as Ok).0: u32) = move _6; // scope 2 at $DIR/simplify_arm_correctness.rs:36:19: 36:24 + discriminant(_0) = 0; // scope 2 at $DIR/simplify_arm_correctness.rs:36:19: 36:24 + StorageDead(_6); // scope 2 at $DIR/simplify_arm_correctness.rs:36:23: 36:24 + StorageDead(_5); // scope 0 at $DIR/simplify_arm_correctness.rs:36:23: 36:24 + return; // scope 0 at $DIR/simplify_arm_correctness.rs:36:23: 36:24 + } + + bb2: { + StorageLive(_3); // scope 0 at $DIR/simplify_arm_correctness.rs:35:12: 35:13 + _3 = ((_1 as Ok).0: u32); // scope 0 at $DIR/simplify_arm_correctness.rs:35:12: 35:13 + StorageLive(_4); // scope 1 at $DIR/simplify_arm_correctness.rs:35:22: 35:23 + _4 = _3; // scope 1 at $DIR/simplify_arm_correctness.rs:35:22: 35:23 + ((_0 as Err).0: u32) = move _4; // scope 1 at $DIR/simplify_arm_correctness.rs:35:18: 35:24 + discriminant(_0) = 1; // scope 1 at $DIR/simplify_arm_correctness.rs:35:18: 35:24 + StorageDead(_4); // scope 1 at $DIR/simplify_arm_correctness.rs:35:23: 35:24 + StorageDead(_3); // scope 0 at $DIR/simplify_arm_correctness.rs:35:23: 35:24 + return; // scope 0 at $DIR/simplify_arm_correctness.rs:35:23: 35:24 + } + } + diff --git a/src/test/mir-opt/simplify_arm_correctness.mixed_copy_a_id.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_arm_correctness.mixed_copy_a_id.SimplifyArmIdentity.diff new file mode 100644 index 0000000000000..a91b9120027eb --- /dev/null +++ b/src/test/mir-opt/simplify_arm_correctness.mixed_copy_a_id.SimplifyArmIdentity.diff @@ -0,0 +1,36 @@ +- // MIR for `mixed_copy_a_id` before SimplifyArmIdentity ++ // MIR for `mixed_copy_a_id` after SimplifyArmIdentity + + fn mixed_copy_a_id(_1: MixedCopyA) -> MixedCopyA { + debug x => _1; // in scope 0 at $DIR/simplify_arm_correctness.rs:12:20: 12:21 + let mut _0: MixedCopyA; // return place in scope 0 at $DIR/simplify_arm_correctness.rs:12:38: 12:48 + let mut _2: isize; // in scope 0 at $DIR/simplify_arm_correctness.rs:14:9: 14:25 + let _3: u32; // in scope 0 at $DIR/simplify_arm_correctness.rs:14:23: 14:24 + let mut _4: u32; // in scope 0 at $DIR/simplify_arm_correctness.rs:14:43: 14:44 + scope 1 { + debug a => _3; // in scope 1 at $DIR/simplify_arm_correctness.rs:14:23: 14:24 + } + + bb0: { + _2 = discriminant(_1); // scope 0 at $DIR/simplify_arm_correctness.rs:13:11: 13:12 + switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/simplify_arm_correctness.rs:13:5: 13:12 + } + + bb1: { + discriminant(_0) = 1; // scope 0 at $DIR/simplify_arm_correctness.rs:15:26: 15:39 + return; // scope 0 at $DIR/simplify_arm_correctness.rs:15:26: 15:39 + } + + bb2: { + StorageLive(_3); // scope 0 at $DIR/simplify_arm_correctness.rs:14:23: 14:24 + _3 = ((_1 as A).0: u32); // scope 0 at $DIR/simplify_arm_correctness.rs:14:23: 14:24 + StorageLive(_4); // scope 1 at $DIR/simplify_arm_correctness.rs:14:43: 14:44 + _4 = _3; // scope 1 at $DIR/simplify_arm_correctness.rs:14:43: 14:44 + ((_0 as A).0: u32) = move _4; // scope 1 at $DIR/simplify_arm_correctness.rs:14:29: 14:45 + discriminant(_0) = 0; // scope 1 at $DIR/simplify_arm_correctness.rs:14:29: 14:45 + StorageDead(_4); // scope 1 at $DIR/simplify_arm_correctness.rs:14:44: 14:45 + StorageDead(_3); // scope 0 at $DIR/simplify_arm_correctness.rs:14:44: 14:45 + return; // scope 0 at $DIR/simplify_arm_correctness.rs:14:44: 14:45 + } + } + diff --git a/src/test/mir-opt/simplify_arm_correctness.mixed_copy_b_id.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_arm_correctness.mixed_copy_b_id.SimplifyArmIdentity.diff new file mode 100644 index 0000000000000..6c4cf142215a7 --- /dev/null +++ b/src/test/mir-opt/simplify_arm_correctness.mixed_copy_b_id.SimplifyArmIdentity.diff @@ -0,0 +1,56 @@ +- // MIR for `mixed_copy_b_id` before SimplifyArmIdentity ++ // MIR for `mixed_copy_b_id` after SimplifyArmIdentity + + fn mixed_copy_b_id(_1: MixedCopyB) -> MixedCopyB { + debug x => _1; // in scope 0 at $DIR/simplify_arm_correctness.rs:25:20: 25:21 + let mut _0: MixedCopyB; // return place in scope 0 at $DIR/simplify_arm_correctness.rs:25:38: 25:48 + let mut _2: isize; // in scope 0 at $DIR/simplify_arm_correctness.rs:27:9: 27:28 + let _3: u32; // in scope 0 at $DIR/simplify_arm_correctness.rs:27:23: 27:24 + let _4: std::string::String; // in scope 0 at $DIR/simplify_arm_correctness.rs:27:26: 27:27 + let mut _5: u32; // in scope 0 at $DIR/simplify_arm_correctness.rs:27:46: 27:47 + let mut _6: std::string::String; // in scope 0 at $DIR/simplify_arm_correctness.rs:27:49: 27:50 + let mut _7: bool; // in scope 0 at $DIR/simplify_arm_correctness.rs:30:1: 30:2 + let mut _8: isize; // in scope 0 at $DIR/simplify_arm_correctness.rs:30:1: 30:2 + let mut _9: isize; // in scope 0 at $DIR/simplify_arm_correctness.rs:30:1: 30:2 + scope 1 { + debug a => _3; // in scope 1 at $DIR/simplify_arm_correctness.rs:27:23: 27:24 + debug b => _4; // in scope 1 at $DIR/simplify_arm_correctness.rs:27:26: 27:27 + } + + bb0: { + _7 = const false; // scope 0 at $DIR/simplify_arm_correctness.rs:26:11: 26:12 + _7 = const true; // scope 0 at $DIR/simplify_arm_correctness.rs:26:11: 26:12 + _2 = discriminant(_1); // scope 0 at $DIR/simplify_arm_correctness.rs:26:11: 26:12 + switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/simplify_arm_correctness.rs:26:5: 26:12 + } + + bb1: { + discriminant(_0) = 1; // scope 0 at $DIR/simplify_arm_correctness.rs:28:26: 28:39 + goto -> bb3; // scope 0 at $DIR/simplify_arm_correctness.rs:28:26: 28:39 + } + + bb2: { + StorageLive(_3); // scope 0 at $DIR/simplify_arm_correctness.rs:27:23: 27:24 + _3 = ((_1 as A).0: u32); // scope 0 at $DIR/simplify_arm_correctness.rs:27:23: 27:24 + StorageLive(_4); // scope 0 at $DIR/simplify_arm_correctness.rs:27:26: 27:27 + _4 = move ((_1 as A).1: std::string::String); // scope 0 at $DIR/simplify_arm_correctness.rs:27:26: 27:27 + StorageLive(_5); // scope 1 at $DIR/simplify_arm_correctness.rs:27:46: 27:47 + _5 = _3; // scope 1 at $DIR/simplify_arm_correctness.rs:27:46: 27:47 + StorageLive(_6); // scope 1 at $DIR/simplify_arm_correctness.rs:27:49: 27:50 + _6 = move _4; // scope 1 at $DIR/simplify_arm_correctness.rs:27:49: 27:50 + ((_0 as A).0: u32) = move _5; // scope 1 at $DIR/simplify_arm_correctness.rs:27:32: 27:51 + ((_0 as A).1: std::string::String) = move _6; // scope 1 at $DIR/simplify_arm_correctness.rs:27:32: 27:51 + discriminant(_0) = 0; // scope 1 at $DIR/simplify_arm_correctness.rs:27:32: 27:51 + StorageDead(_6); // scope 1 at $DIR/simplify_arm_correctness.rs:27:50: 27:51 + StorageDead(_5); // scope 1 at $DIR/simplify_arm_correctness.rs:27:50: 27:51 + StorageDead(_4); // scope 0 at $DIR/simplify_arm_correctness.rs:27:50: 27:51 + StorageDead(_3); // scope 0 at $DIR/simplify_arm_correctness.rs:27:50: 27:51 + goto -> bb3; // scope 0 at $DIR/simplify_arm_correctness.rs:30:1: 30:2 + } + + bb3: { + _8 = discriminant(_1); // scope 0 at $DIR/simplify_arm_correctness.rs:30:1: 30:2 + return; // scope 0 at $DIR/simplify_arm_correctness.rs:30:2: 30:2 + } + } + diff --git a/src/test/mir-opt/simplify_arm_correctness.partial_copy.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_arm_correctness.partial_copy.SimplifyArmIdentity.diff new file mode 100644 index 0000000000000..70e9b4cd090e2 --- /dev/null +++ b/src/test/mir-opt/simplify_arm_correctness.partial_copy.SimplifyArmIdentity.diff @@ -0,0 +1,42 @@ +- // MIR for `partial_copy` before SimplifyArmIdentity ++ // MIR for `partial_copy` after SimplifyArmIdentity + + fn partial_copy(_1: MultiField) -> MultiField { + debug x => _1; // in scope 0 at $DIR/simplify_arm_correctness.rs:46:17: 46:18 + let mut _0: MultiField; // return place in scope 0 at $DIR/simplify_arm_correctness.rs:46:35: 46:45 + let mut _2: isize; // in scope 0 at $DIR/simplify_arm_correctness.rs:48:9: 48:29 + let _3: u32; // in scope 0 at $DIR/simplify_arm_correctness.rs:48:23: 48:24 + let _4: u32; // in scope 0 at $DIR/simplify_arm_correctness.rs:48:26: 48:28 + let mut _5: u32; // in scope 0 at $DIR/simplify_arm_correctness.rs:48:47: 48:48 + scope 1 { + debug a => _3; // in scope 1 at $DIR/simplify_arm_correctness.rs:48:23: 48:24 + debug _b => _4; // in scope 1 at $DIR/simplify_arm_correctness.rs:48:26: 48:28 + } + + bb0: { + _2 = discriminant(_1); // scope 0 at $DIR/simplify_arm_correctness.rs:47:11: 47:12 + switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/simplify_arm_correctness.rs:47:5: 47:12 + } + + bb1: { + discriminant(_0) = 1; // scope 0 at $DIR/simplify_arm_correctness.rs:49:26: 49:39 + return; // scope 0 at $DIR/simplify_arm_correctness.rs:49:26: 49:39 + } + + bb2: { + StorageLive(_3); // scope 0 at $DIR/simplify_arm_correctness.rs:48:23: 48:24 + _3 = ((_1 as A).0: u32); // scope 0 at $DIR/simplify_arm_correctness.rs:48:23: 48:24 + StorageLive(_4); // scope 0 at $DIR/simplify_arm_correctness.rs:48:26: 48:28 + _4 = ((_1 as A).1: u32); // scope 0 at $DIR/simplify_arm_correctness.rs:48:26: 48:28 + StorageLive(_5); // scope 1 at $DIR/simplify_arm_correctness.rs:48:47: 48:48 + _5 = _3; // scope 1 at $DIR/simplify_arm_correctness.rs:48:47: 48:48 + ((_0 as A).0: u32) = move _5; // scope 1 at $DIR/simplify_arm_correctness.rs:48:33: 48:52 + ((_0 as A).1: u32) = const 5_u32; // scope 1 at $DIR/simplify_arm_correctness.rs:48:33: 48:52 + discriminant(_0) = 0; // scope 1 at $DIR/simplify_arm_correctness.rs:48:33: 48:52 + StorageDead(_5); // scope 1 at $DIR/simplify_arm_correctness.rs:48:51: 48:52 + StorageDead(_4); // scope 0 at $DIR/simplify_arm_correctness.rs:48:51: 48:52 + StorageDead(_3); // scope 0 at $DIR/simplify_arm_correctness.rs:48:51: 48:52 + return; // scope 0 at $DIR/simplify_arm_correctness.rs:48:51: 48:52 + } + } + diff --git a/src/test/mir-opt/simplify_arm_correctness.rs b/src/test/mir-opt/simplify_arm_correctness.rs new file mode 100644 index 0000000000000..b0c6bf5bb6809 --- /dev/null +++ b/src/test/mir-opt/simplify_arm_correctness.rs @@ -0,0 +1,58 @@ +// Cases that should not be optimized by `SimplifyArmIdentity` + +// It may be possible to optimize these first two cases in the future, with improvements to other +// optimizations or changes in MIR semantics. However, at the moment, it would not be correct given +// the input to the pass and the extent of the analysis +enum MixedCopyA { + A(u32), + B, +} + +// EMIT_MIR simplify_arm_correctness.mixed_copy_a_id.SimplifyArmIdentity.diff +fn mixed_copy_a_id(x: MixedCopyA) -> MixedCopyA { + match x { + MixedCopyA::A(a) => MixedCopyA::A(a), + MixedCopyA::B => MixedCopyA::B, + } +} + +enum MixedCopyB { + A(u32, String), + B, +} + +// EMIT_MIR simplify_arm_correctness.mixed_copy_b_id.SimplifyArmIdentity.diff +fn mixed_copy_b_id(x: MixedCopyB) -> MixedCopyB { + match x { + MixedCopyB::A(a, b) => MixedCopyB::A(a, b), + MixedCopyB::B => MixedCopyB::B, + } +} + +// EMIT_MIR simplify_arm_correctness.mismatched_variant.SimplifyArmIdentity.diff +fn mismatched_variant(x: Result) -> Result { + match x { + Ok(a) => Err(a), + Err(a) => Ok(a), + } +} + +enum MultiField { + A(u32, u32), + B, +} + +// EMIT_MIR simplify_arm_correctness.partial_copy.SimplifyArmIdentity.diff +fn partial_copy(x: MultiField) -> MultiField { + match x { + MultiField::A(a, _b) => MultiField::A(a, 5), + MultiField::B => MultiField::B, + } +} + +fn main() { + mixed_copy_a_id(MixedCopyA::A(0)); + mixed_copy_b_id(MixedCopyB::A(0, String::new())); + mismatched_variant(Ok(0)); + partial_copy(MultiField::B); +} 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 deleted file mode 100644 index e139eedf3a0d6..0000000000000 --- a/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.32bit.diff +++ /dev/null @@ -1,26 +0,0 @@ -- // MIR for `map` before SimplifyLocals -+ // MIR for `map` after SimplifyLocals - - fn map(_1: Option>) -> Option> { - debug x => _1; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:8: 3:9 - let mut _0: std::option::Option>; // return place in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:31: 3:46 -- let mut _2: isize; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:5:9: 5:13 -- let _3: std::boxed::Box<()>; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:6:14: 6:15 -- let mut _4: std::boxed::Box<()>; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:6:25: 6:26 -- let mut _5: bool; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:8:1: 8:2 -- let mut _6: isize; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:8:1: 8:2 -- let mut _7: isize; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:8:1: 8:2 - scope 1 { - debug x => ((_0 as Some).0: std::boxed::Box<()>); // in scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:6:14: 6:15 - } - - bb0: { -- _5 = const false; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:11: 4:12 -- _5 = const true; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:11: 4:12 -- _2 = discriminant(_1); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:11: 4:12 - _0 = move _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 deleted file mode 100644 index e139eedf3a0d6..0000000000000 --- a/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.64bit.diff +++ /dev/null @@ -1,26 +0,0 @@ -- // MIR for `map` before SimplifyLocals -+ // MIR for `map` after SimplifyLocals - - fn map(_1: Option>) -> Option> { - debug x => _1; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:8: 3:9 - let mut _0: std::option::Option>; // return place in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:31: 3:46 -- let mut _2: isize; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:5:9: 5:13 -- let _3: std::boxed::Box<()>; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:6:14: 6:15 -- let mut _4: std::boxed::Box<()>; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:6:25: 6:26 -- let mut _5: bool; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:8:1: 8:2 -- let mut _6: isize; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:8:1: 8:2 -- let mut _7: isize; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:8:1: 8:2 - scope 1 { - debug x => ((_0 as Some).0: std::boxed::Box<()>); // in scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:6:14: 6:15 - } - - bb0: { -- _5 = const false; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:11: 4:12 -- _5 = const true; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:11: 4:12 -- _2 = discriminant(_1); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:11: 4:12 - _0 = move _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.rs b/src/test/mir-opt/simplify_try.rs deleted file mode 100644 index 15e351e7d5016..0000000000000 --- a/src/test/mir-opt/simplify_try.rs +++ /dev/null @@ -1,30 +0,0 @@ -// compile-flags: -Zunsound-mir-opts -// EMIT_MIR simplify_try.try_identity.SimplifyArmIdentity.diff -// EMIT_MIR simplify_try.try_identity.SimplifyBranchSame.after.mir -// EMIT_MIR simplify_try.try_identity.SimplifyLocals.after.mir -// EMIT_MIR simplify_try.try_identity.DestinationPropagation.diff - - -fn into_result(r: Result) -> Result { - r -} - -fn from_error(e: E) -> Result { - Err(e) -} - -// 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. -fn try_identity(x: Result) -> Result { - let y = match into_result(x) { - Err(e) => return from_error(From::from(e)), - Ok(v) => v, - }; - Ok(y) -} - -fn main() { - let _ = try_identity(Ok(0)); -} diff --git a/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff b/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff deleted file mode 100644 index a6ea8cacfd2c5..0000000000000 --- a/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff +++ /dev/null @@ -1,63 +0,0 @@ -- // MIR for `try_identity` before DestinationPropagation -+ // MIR for `try_identity` after DestinationPropagation - - 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 _2: u32; // in scope 0 at $DIR/simplify_try.rs:21:9: 21:10 - let mut _3: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:21:19: 21:33 - let mut _4: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:21:31: 21:32 - let mut _5: isize; // in scope 0 at $DIR/simplify_try.rs:22:9: 22:15 - let _6: i32; // in scope 0 at $DIR/simplify_try.rs:22:13: 22:14 - let mut _7: !; // in scope 0 at $DIR/simplify_try.rs:22:19: 22:51 - let mut _8: i32; // in scope 0 at $DIR/simplify_try.rs:22:37: 22:50 - let mut _9: i32; // in scope 0 at $DIR/simplify_try.rs:22:48: 22:49 - let _10: u32; // in scope 0 at $DIR/simplify_try.rs:23:12: 23:13 - let mut _11: u32; // in scope 0 at $DIR/simplify_try.rs:25:8: 25:9 - scope 1 { - 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 - 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 - } - 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 - } - } - scope 3 { - debug v => ((_0 as Ok).0: u32); // in scope 3 at $DIR/simplify_try.rs:23:12: 23:13 - } - scope 4 (inlined into_result::) { // at $DIR/simplify_try.rs:21:19: 21:33 -- debug r => _4; // in scope 4 at $DIR/simplify_try.rs:21:19: 21:33 -+ debug r => _0; // in scope 4 at $DIR/simplify_try.rs:21:19: 21:33 - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/simplify_try.rs:21:9: 21:10 -- 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 -- StorageDead(_4); // scope 0 at $DIR/simplify_try.rs:21:32: 21:33 -- _5 = discriminant(_3); // scope 0 at $DIR/simplify_try.rs:21:19: 21:33 -+ nop; // scope 0 at $DIR/simplify_try.rs:21:19: 21:33 -+ nop; // scope 0 at $DIR/simplify_try.rs:21:31: 21:32 -+ _0 = _1; // scope 0 at $DIR/simplify_try.rs:21:31: 21:32 -+ 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:21:19: 21:33 - goto -> bb1; // scope 0 at $DIR/simplify_try.rs:21:13: 21:33 - } - - 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 - } - } - diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff deleted file mode 100644 index bef57548005ce..0000000000000 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff +++ /dev/null @@ -1,86 +0,0 @@ -- // MIR for `try_identity` before SimplifyArmIdentity -+ // MIR for `try_identity` after SimplifyArmIdentity - - 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 _2: u32; // in scope 0 at $DIR/simplify_try.rs:21:9: 21:10 - let mut _3: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:21:19: 21:33 - let mut _4: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:21:31: 21:32 - let mut _5: isize; // in scope 0 at $DIR/simplify_try.rs:22:9: 22:15 - let _6: i32; // in scope 0 at $DIR/simplify_try.rs:22:13: 22:14 - let mut _7: !; // in scope 0 at $DIR/simplify_try.rs:22:19: 22:51 - let mut _8: i32; // in scope 0 at $DIR/simplify_try.rs:22:37: 22:50 - let mut _9: i32; // in scope 0 at $DIR/simplify_try.rs:22:48: 22:49 - let _10: u32; // in scope 0 at $DIR/simplify_try.rs:23:12: 23:13 - let mut _11: u32; // in scope 0 at $DIR/simplify_try.rs:25:8: 25:9 - scope 1 { -- debug y => _2; // in scope 1 at $DIR/simplify_try.rs:21:9: 21:10 -+ 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 - 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 - } - 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 - } - } - scope 3 { -- debug v => _10; // in scope 3 at $DIR/simplify_try.rs:23:12: 23:13 -+ debug v => ((_0 as Ok).0: u32); // in scope 3 at $DIR/simplify_try.rs:23:12: 23:13 - } - scope 4 (inlined into_result::) { // at $DIR/simplify_try.rs:21:19: 21:33 - debug r => _4; // in scope 4 at $DIR/simplify_try.rs:21:19: 21:33 - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/simplify_try.rs:21:9: 21:10 - 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 - StorageDead(_4); // scope 0 at $DIR/simplify_try.rs:21:32: 21:33 - _5 = discriminant(_3); // scope 0 at $DIR/simplify_try.rs:21:19: 21:33 - switchInt(move _5) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:21:13: 21:33 - } - - bb1: { -- StorageLive(_10); // scope 0 at $DIR/simplify_try.rs:23:12: 23:13 -- _10 = ((_3 as Ok).0: u32); // scope 0 at $DIR/simplify_try.rs:23:12: 23:13 -- _2 = _10; // scope 3 at $DIR/simplify_try.rs:23:18: 23:19 -- StorageDead(_10); // scope 0 at $DIR/simplify_try.rs:23:18: 23:19 -+ _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 -- StorageLive(_11); // scope 1 at $DIR/simplify_try.rs:25:8: 25:9 -- _11 = _2; // scope 1 at $DIR/simplify_try.rs:25:8: 25:9 -- ((_0 as Ok).0: u32) = move _11; // scope 1 at $DIR/simplify_try.rs:25:5: 25:10 -- discriminant(_0) = 0; // scope 1 at $DIR/simplify_try.rs:25:5: 25:10 -- StorageDead(_11); // scope 1 at $DIR/simplify_try.rs:25:9: 25:10 - 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 = 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 - 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 deleted file mode 100644 index aa19c479881aa..0000000000000 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir +++ /dev/null @@ -1,52 +0,0 @@ -// MIR for `try_identity` after SimplifyBranchSame - -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 _2: u32; // in scope 0 at $DIR/simplify_try.rs:21:9: 21:10 - let mut _3: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:21:19: 21:33 - let mut _4: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:21:31: 21:32 - let mut _5: isize; // in scope 0 at $DIR/simplify_try.rs:22:9: 22:15 - let _6: i32; // in scope 0 at $DIR/simplify_try.rs:22:13: 22:14 - let mut _7: !; // in scope 0 at $DIR/simplify_try.rs:22:19: 22:51 - let mut _8: i32; // in scope 0 at $DIR/simplify_try.rs:22:37: 22:50 - let mut _9: i32; // in scope 0 at $DIR/simplify_try.rs:22:48: 22:49 - let _10: u32; // in scope 0 at $DIR/simplify_try.rs:23:12: 23:13 - let mut _11: u32; // in scope 0 at $DIR/simplify_try.rs:25:8: 25:9 - scope 1 { - 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 - 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 - } - 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 - } - } - scope 3 { - debug v => ((_0 as Ok).0: u32); // in scope 3 at $DIR/simplify_try.rs:23:12: 23:13 - } - scope 4 (inlined into_result::) { // at $DIR/simplify_try.rs:21:19: 21:33 - debug r => _4; // in scope 4 at $DIR/simplify_try.rs:21:19: 21:33 - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/simplify_try.rs:21:9: 21:10 - 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 - StorageDead(_4); // scope 0 at $DIR/simplify_try.rs:21:32: 21:33 - _5 = discriminant(_3); // scope 0 at $DIR/simplify_try.rs:21:19: 21:33 - goto -> bb1; // scope 0 at $DIR/simplify_try.rs:21:13: 21:33 - } - - 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 - 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 deleted file mode 100644 index 1b5232422b6c3..0000000000000 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir +++ /dev/null @@ -1,29 +0,0 @@ -// MIR for `try_identity` after SimplifyLocals - -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 - scope 1 { - 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 - 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 - } - 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 - } - } - scope 3 { - debug v => ((_0 as Ok).0: u32); // in scope 3 at $DIR/simplify_try.rs:23:12: 23:13 - } - scope 4 (inlined into_result::) { // at $DIR/simplify_try.rs:21:19: 21:33 - debug r => _0; // in scope 4 at $DIR/simplify_try.rs:21:19: 21:33 - } - - bb0: { - _0 = _1; // scope 0 at $DIR/simplify_try.rs:21:31: 21:32 - return; // scope 0 at $DIR/simplify_try.rs:26:2: 26:2 - } -}