diff --git a/compiler/rustc_mir_transform/src/large_enums.rs b/compiler/rustc_mir_transform/src/large_enums.rs index 3f8662ad6971f..89f8de235835a 100644 --- a/compiler/rustc_mir_transform/src/large_enums.rs +++ b/compiler/rustc_mir_transform/src/large_enums.rs @@ -4,6 +4,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_middle::mir::interpret::AllocId; use rustc_middle::mir::*; use rustc_middle::ty::{self, AdtDef, Const, ParamEnv, Ty, TyCtxt}; +use rustc_session::Session; use rustc_target::abi::{HasDataLayout, Size, TagEncoding, Variants}; /// A pass that seeks to optimize unnecessary moves of large enum types, if there is a large @@ -28,14 +29,12 @@ pub struct EnumSizeOpt { } impl<'tcx> MirPass<'tcx> for EnumSizeOpt { + fn is_enabled(&self, sess: &Session) -> bool { + sess.opts.unstable_opts.unsound_mir_opts || sess.mir_opt_level() >= 3 + } fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { - let sess = tcx.sess; - // FIXME(julianknodt): one thing noticed while testing this mir-opt is that there is a - // different layout of large enums on wasm. It's not clear what is causing this layout - // difference, as it should be identical to i686 (32 bit). - if (!sess.opts.unstable_opts.unsound_mir_opts) || sess.mir_opt_level() < 3 { - return; - } + // NOTE: This pass may produce different MIR based on the alignment of the target + // platform, but it will still be valid. self.optim(tcx, body); } } @@ -254,6 +253,9 @@ impl EnumSizeOpt { )), }; + let deinit_old = + Statement { source_info, kind: StatementKind::Deinit(box dst) }; + let copy_bytes = Statement { source_info, kind: StatementKind::Intrinsic( @@ -279,6 +281,7 @@ impl EnumSizeOpt { dst_cast, src_ptr, src_cast, + deinit_old, copy_bytes, store_dead, ] diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index be3652dd3e7bd..45cd4024c9f57 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -547,7 +547,6 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { tcx, body, &[ - &large_enums::EnumSizeOpt { discrepancy: 128 }, &reveal_all::RevealAll, // has to be done before inlining, since inlined code is in RevealAll mode. &lower_slice_len::LowerSliceLenCalls, // has to be done before inlining, otherwise actual call will be almost always inlined. Also simple, so can just do first &unreachable_prop::UnreachablePropagation, @@ -586,6 +585,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { &simplify::SimplifyLocals::new("final"), &multiple_return_terminators::MultipleReturnTerminators, &deduplicate_blocks::DeduplicateBlocks, + &large_enums::EnumSizeOpt { discrepancy: 128 }, // Some cleanup necessary at least for LLVM and potentially other codegen backends. &add_call_guards::CriticalCallEdges, // Dump the end result for testing and debugging purposes. diff --git a/tests/mir-opt/enum_opt.cand.EnumSizeOpt.32bit.diff b/tests/mir-opt/enum_opt.cand.EnumSizeOpt.32bit.diff index e0ba46c15f4a9..b139deeee1fc9 100644 --- a/tests/mir-opt/enum_opt.cand.EnumSizeOpt.32bit.diff +++ b/tests/mir-opt/enum_opt.cand.EnumSizeOpt.32bit.diff @@ -1,11 +1,11 @@ - // MIR for `cand` before EnumSizeOpt + // MIR for `cand` after EnumSizeOpt - fn cand() -> () { - let mut _0: (); // return place in scope 0 at $DIR/enum_opt.rs:+0:15: +0:15 + fn cand() -> Candidate { + let mut _0: Candidate; // return place in scope 0 at $DIR/enum_opt.rs:+0:18: +0:27 let mut _1: Candidate; // in scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 let mut _2: Candidate; // in scope 0 at $DIR/enum_opt.rs:+2:7: +2:34 - let mut _3: [u64; 1024]; // in scope 0 at $DIR/enum_opt.rs:+2:24: +2:33 + let mut _3: [u8; 8196]; // in scope 0 at $DIR/enum_opt.rs:+2:24: +2:33 + let mut _4: [usize; 2]; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 + let mut _5: isize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 + let mut _6: usize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 @@ -14,25 +14,29 @@ + let mut _9: *mut u8; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 + let mut _10: *const Candidate; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 + let mut _11: *const u8; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _12: [usize; 2]; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _13: isize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _14: usize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _15: usize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _16: *mut Candidate; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _17: *mut u8; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _18: *const Candidate; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _19: *const u8; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 scope 1 { debug a => _1; // in scope 1 at $DIR/enum_opt.rs:+1:7: +1:12 } bb0: { StorageLive(_1); // scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 - Deinit(_1); // scope 0 at $DIR/enum_opt.rs:+1:15: +1:34 - ((_1 as Small).0: u8) = const 1_u8; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:34 - discriminant(_1) = 0; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:34 + _1 = Candidate::Small(const 1_u8); // scope 0 at $DIR/enum_opt.rs:+1:15: +1:34 StorageLive(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 StorageLive(_3); // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 - _3 = [const 1_u64; 1024]; // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 - Deinit(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 - ((_2 as Large).0: [u64; 1024]) = move _3; // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 - discriminant(_2) = 1; // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 + _3 = [const 1_u8; 8196]; // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 + _2 = Candidate::Large(move _3); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 StorageDead(_3); // scope 1 at $DIR/enum_opt.rs:+2:33: +2:34 - _1 = move _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + StorageLive(_4); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 -+ _4 = const [2_usize, 8196_usize]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _4 = const [2_usize, 8197_usize]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + _5 = discriminant(_2); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + _6 = _5 as usize (IntToInt); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + _7 = _4[_6]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 @@ -40,12 +44,25 @@ + _9 = _8 as *mut u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + _10 = &raw const _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + _11 = _10 as *const u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ Deinit(_8); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + copy_nonoverlapping(dst = _9, src = _11, count = _7); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + StorageDead(_4); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 StorageDead(_2); // scope 1 at $DIR/enum_opt.rs:+2:33: +2:34 - _0 = const (); // scope 0 at $DIR/enum_opt.rs:+0:15: +3:2 - StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+3:1: +3:2 - return; // scope 0 at $DIR/enum_opt.rs:+3:2: +3:2 +- _0 = move _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ StorageLive(_12); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _12 = const [2_usize, 8197_usize]; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _13 = discriminant(_1); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _14 = _13 as usize (IntToInt); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _15 = _12[_14]; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _16 = &raw mut _0; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _17 = _16 as *mut u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _18 = &raw const _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _19 = _18 as *const u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ Deinit(_16); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ copy_nonoverlapping(dst = _17, src = _19, count = _15); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ StorageDead(_12); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 + StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+4:1: +4:2 + return; // scope 0 at $DIR/enum_opt.rs:+4:2: +4:2 } } diff --git a/tests/mir-opt/enum_opt.cand.EnumSizeOpt.64bit.diff b/tests/mir-opt/enum_opt.cand.EnumSizeOpt.64bit.diff index 67439dba9c947..b139deeee1fc9 100644 --- a/tests/mir-opt/enum_opt.cand.EnumSizeOpt.64bit.diff +++ b/tests/mir-opt/enum_opt.cand.EnumSizeOpt.64bit.diff @@ -1,11 +1,11 @@ - // MIR for `cand` before EnumSizeOpt + // MIR for `cand` after EnumSizeOpt - fn cand() -> () { - let mut _0: (); // return place in scope 0 at $DIR/enum_opt.rs:+0:15: +0:15 + fn cand() -> Candidate { + let mut _0: Candidate; // return place in scope 0 at $DIR/enum_opt.rs:+0:18: +0:27 let mut _1: Candidate; // in scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 let mut _2: Candidate; // in scope 0 at $DIR/enum_opt.rs:+2:7: +2:34 - let mut _3: [u64; 1024]; // in scope 0 at $DIR/enum_opt.rs:+2:24: +2:33 + let mut _3: [u8; 8196]; // in scope 0 at $DIR/enum_opt.rs:+2:24: +2:33 + let mut _4: [usize; 2]; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 + let mut _5: isize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 + let mut _6: usize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 @@ -14,25 +14,29 @@ + let mut _9: *mut u8; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 + let mut _10: *const Candidate; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 + let mut _11: *const u8; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _12: [usize; 2]; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _13: isize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _14: usize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _15: usize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _16: *mut Candidate; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _17: *mut u8; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _18: *const Candidate; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _19: *const u8; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 scope 1 { debug a => _1; // in scope 1 at $DIR/enum_opt.rs:+1:7: +1:12 } bb0: { StorageLive(_1); // scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 - Deinit(_1); // scope 0 at $DIR/enum_opt.rs:+1:15: +1:34 - ((_1 as Small).0: u8) = const 1_u8; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:34 - discriminant(_1) = 0; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:34 + _1 = Candidate::Small(const 1_u8); // scope 0 at $DIR/enum_opt.rs:+1:15: +1:34 StorageLive(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 StorageLive(_3); // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 - _3 = [const 1_u64; 1024]; // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 - Deinit(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 - ((_2 as Large).0: [u64; 1024]) = move _3; // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 - discriminant(_2) = 1; // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 + _3 = [const 1_u8; 8196]; // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 + _2 = Candidate::Large(move _3); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 StorageDead(_3); // scope 1 at $DIR/enum_opt.rs:+2:33: +2:34 - _1 = move _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + StorageLive(_4); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 -+ _4 = const [2_usize, 8200_usize]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _4 = const [2_usize, 8197_usize]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + _5 = discriminant(_2); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + _6 = _5 as usize (IntToInt); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + _7 = _4[_6]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 @@ -40,12 +44,25 @@ + _9 = _8 as *mut u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + _10 = &raw const _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + _11 = _10 as *const u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ Deinit(_8); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + copy_nonoverlapping(dst = _9, src = _11, count = _7); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + StorageDead(_4); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 StorageDead(_2); // scope 1 at $DIR/enum_opt.rs:+2:33: +2:34 - _0 = const (); // scope 0 at $DIR/enum_opt.rs:+0:15: +3:2 - StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+3:1: +3:2 - return; // scope 0 at $DIR/enum_opt.rs:+3:2: +3:2 +- _0 = move _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ StorageLive(_12); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _12 = const [2_usize, 8197_usize]; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _13 = discriminant(_1); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _14 = _13 as usize (IntToInt); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _15 = _12[_14]; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _16 = &raw mut _0; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _17 = _16 as *mut u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _18 = &raw const _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _19 = _18 as *const u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ Deinit(_16); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ copy_nonoverlapping(dst = _17, src = _19, count = _15); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ StorageDead(_12); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 + StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+4:1: +4:2 + return; // scope 0 at $DIR/enum_opt.rs:+4:2: +4:2 } } diff --git a/tests/mir-opt/enum_opt.invalid.EnumSizeOpt.32bit.diff b/tests/mir-opt/enum_opt.invalid.EnumSizeOpt.32bit.diff index db2efa195a369..a80001149ebb7 100644 --- a/tests/mir-opt/enum_opt.invalid.EnumSizeOpt.32bit.diff +++ b/tests/mir-opt/enum_opt.invalid.EnumSizeOpt.32bit.diff @@ -1,8 +1,8 @@ - // MIR for `invalid` before EnumSizeOpt + // MIR for `invalid` after EnumSizeOpt - fn invalid() -> () { - let mut _0: (); // return place in scope 0 at $DIR/enum_opt.rs:+0:18: +0:18 + fn invalid() -> InvalidIdxs { + let mut _0: InvalidIdxs; // return place in scope 0 at $DIR/enum_opt.rs:+0:21: +0:32 let mut _1: InvalidIdxs; // in scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 let mut _2: InvalidIdxs; // in scope 0 at $DIR/enum_opt.rs:+2:7: +2:36 let mut _3: [u64; 1024]; // in scope 0 at $DIR/enum_opt.rs:+2:26: +2:35 @@ -12,20 +12,17 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 - Deinit(_1); // scope 0 at $DIR/enum_opt.rs:+1:15: +1:29 - discriminant(_1) = 0; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:29 + _1 = InvalidIdxs::A; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:29 StorageLive(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:36 StorageLive(_3); // scope 1 at $DIR/enum_opt.rs:+2:26: +2:35 _3 = [const 0_u64; 1024]; // scope 1 at $DIR/enum_opt.rs:+2:26: +2:35 - Deinit(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:36 - ((_2 as Large).0: [u64; 1024]) = move _3; // scope 1 at $DIR/enum_opt.rs:+2:7: +2:36 - discriminant(_2) = 1; // scope 1 at $DIR/enum_opt.rs:+2:7: +2:36 + _2 = InvalidIdxs::Large(move _3); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:36 StorageDead(_3); // scope 1 at $DIR/enum_opt.rs:+2:35: +2:36 _1 = move _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:36 StorageDead(_2); // scope 1 at $DIR/enum_opt.rs:+2:35: +2:36 - _0 = const (); // scope 0 at $DIR/enum_opt.rs:+0:18: +3:2 - StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+3:1: +3:2 - return; // scope 0 at $DIR/enum_opt.rs:+3:2: +3:2 + _0 = move _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 + StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+4:1: +4:2 + return; // scope 0 at $DIR/enum_opt.rs:+4:2: +4:2 } } diff --git a/tests/mir-opt/enum_opt.invalid.EnumSizeOpt.64bit.diff b/tests/mir-opt/enum_opt.invalid.EnumSizeOpt.64bit.diff index db2efa195a369..a80001149ebb7 100644 --- a/tests/mir-opt/enum_opt.invalid.EnumSizeOpt.64bit.diff +++ b/tests/mir-opt/enum_opt.invalid.EnumSizeOpt.64bit.diff @@ -1,8 +1,8 @@ - // MIR for `invalid` before EnumSizeOpt + // MIR for `invalid` after EnumSizeOpt - fn invalid() -> () { - let mut _0: (); // return place in scope 0 at $DIR/enum_opt.rs:+0:18: +0:18 + fn invalid() -> InvalidIdxs { + let mut _0: InvalidIdxs; // return place in scope 0 at $DIR/enum_opt.rs:+0:21: +0:32 let mut _1: InvalidIdxs; // in scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 let mut _2: InvalidIdxs; // in scope 0 at $DIR/enum_opt.rs:+2:7: +2:36 let mut _3: [u64; 1024]; // in scope 0 at $DIR/enum_opt.rs:+2:26: +2:35 @@ -12,20 +12,17 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 - Deinit(_1); // scope 0 at $DIR/enum_opt.rs:+1:15: +1:29 - discriminant(_1) = 0; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:29 + _1 = InvalidIdxs::A; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:29 StorageLive(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:36 StorageLive(_3); // scope 1 at $DIR/enum_opt.rs:+2:26: +2:35 _3 = [const 0_u64; 1024]; // scope 1 at $DIR/enum_opt.rs:+2:26: +2:35 - Deinit(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:36 - ((_2 as Large).0: [u64; 1024]) = move _3; // scope 1 at $DIR/enum_opt.rs:+2:7: +2:36 - discriminant(_2) = 1; // scope 1 at $DIR/enum_opt.rs:+2:7: +2:36 + _2 = InvalidIdxs::Large(move _3); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:36 StorageDead(_3); // scope 1 at $DIR/enum_opt.rs:+2:35: +2:36 _1 = move _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:36 StorageDead(_2); // scope 1 at $DIR/enum_opt.rs:+2:35: +2:36 - _0 = const (); // scope 0 at $DIR/enum_opt.rs:+0:18: +3:2 - StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+3:1: +3:2 - return; // scope 0 at $DIR/enum_opt.rs:+3:2: +3:2 + _0 = move _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 + StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+4:1: +4:2 + return; // scope 0 at $DIR/enum_opt.rs:+4:2: +4:2 } } diff --git a/tests/mir-opt/enum_opt.rs b/tests/mir-opt/enum_opt.rs index 6876c56cfa4ed..2768d70804926 100644 --- a/tests/mir-opt/enum_opt.rs +++ b/tests/mir-opt/enum_opt.rs @@ -1,20 +1,19 @@ +// unit-test: EnumSizeOpt // EMIT_MIR_FOR_EACH_BIT_WIDTH -// compile-flags: -Zunsound-mir-opts -Zmir-opt-level=3 -// ignore-wasm32 +// compile-flags: -Zunsound-mir-opts #![feature(arbitrary_enum_discriminant, repr128)] // Tests that an enum with a variant with no data gets correctly transformed. -#[repr(C)] pub enum NoData { - Large([u8; 8192]), + Large([u8; 8196]), None, } // Tests that an enum with a variant with data that is a valid candidate gets transformed. pub enum Candidate { Small(u8), - Large([u64; 1024]), + Large([u8; 8196]), } // Tests that an enum which has a discriminant much higher than the variant does not get @@ -43,34 +42,39 @@ pub enum RandOrderDiscr { } // EMIT_MIR enum_opt.unin.EnumSizeOpt.diff -pub fn unin() { +pub fn unin() -> NoData { let mut a = NoData::None; - a = NoData::Large([1; 8192]); + a = NoData::Large([1; 8196]); + a } // EMIT_MIR enum_opt.cand.EnumSizeOpt.diff -pub fn cand() { +pub fn cand() -> Candidate { let mut a = Candidate::Small(1); - a = Candidate::Large([1; 1024]); + a = Candidate::Large([1; 8196]); + a } // EMIT_MIR enum_opt.invalid.EnumSizeOpt.diff -pub fn invalid() { +pub fn invalid() -> InvalidIdxs { let mut a = InvalidIdxs::A; a = InvalidIdxs::Large([0; 1024]); + a } // EMIT_MIR enum_opt.trunc.EnumSizeOpt.diff -pub fn trunc() { +pub fn trunc() -> NotTrunctable { let mut a = NotTrunctable::A; a = NotTrunctable::B([0; 1024]); a = NotTrunctable::C([0; 4096]); + a } -pub fn rand_order() { +pub fn rand_order() -> RandOrderDiscr { let mut a = RandOrderDiscr::A; a = RandOrderDiscr::B([0; 1024]); a = RandOrderDiscr::C; + a } pub fn main() { diff --git a/tests/mir-opt/enum_opt.trunc.EnumSizeOpt.32bit.diff b/tests/mir-opt/enum_opt.trunc.EnumSizeOpt.32bit.diff index b9d6765d8c1ca..1ef79044d4fc6 100644 --- a/tests/mir-opt/enum_opt.trunc.EnumSizeOpt.32bit.diff +++ b/tests/mir-opt/enum_opt.trunc.EnumSizeOpt.32bit.diff @@ -1,8 +1,8 @@ - // MIR for `trunc` before EnumSizeOpt + // MIR for `trunc` after EnumSizeOpt - fn trunc() -> () { - let mut _0: (); // return place in scope 0 at $DIR/enum_opt.rs:+0:16: +0:16 + fn trunc() -> NotTrunctable { + let mut _0: NotTrunctable; // return place in scope 0 at $DIR/enum_opt.rs:+0:19: +0:32 let mut _1: NotTrunctable; // in scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 let mut _2: NotTrunctable; // in scope 0 at $DIR/enum_opt.rs:+2:7: +2:34 let mut _3: [u8; 1024]; // in scope 0 at $DIR/enum_opt.rs:+2:24: +2:33 @@ -14,29 +14,24 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 - Deinit(_1); // scope 0 at $DIR/enum_opt.rs:+1:15: +1:31 - discriminant(_1) = 0; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:31 + _1 = NotTrunctable::A; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:31 StorageLive(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 StorageLive(_3); // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 _3 = [const 0_u8; 1024]; // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 - Deinit(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 - ((_2 as B).0: [u8; 1024]) = move _3; // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 - discriminant(_2) = 1; // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 + _2 = NotTrunctable::B(move _3); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 StorageDead(_3); // scope 1 at $DIR/enum_opt.rs:+2:33: +2:34 _1 = move _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 StorageDead(_2); // scope 1 at $DIR/enum_opt.rs:+2:33: +2:34 StorageLive(_4); // scope 1 at $DIR/enum_opt.rs:+3:7: +3:34 StorageLive(_5); // scope 1 at $DIR/enum_opt.rs:+3:24: +3:33 _5 = [const 0_u8; 4096]; // scope 1 at $DIR/enum_opt.rs:+3:24: +3:33 - Deinit(_4); // scope 1 at $DIR/enum_opt.rs:+3:7: +3:34 - ((_4 as C).0: [u8; 4096]) = move _5; // scope 1 at $DIR/enum_opt.rs:+3:7: +3:34 - discriminant(_4) = 2; // scope 1 at $DIR/enum_opt.rs:+3:7: +3:34 + _4 = NotTrunctable::C(move _5); // scope 1 at $DIR/enum_opt.rs:+3:7: +3:34 StorageDead(_5); // scope 1 at $DIR/enum_opt.rs:+3:33: +3:34 _1 = move _4; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:34 StorageDead(_4); // scope 1 at $DIR/enum_opt.rs:+3:33: +3:34 - _0 = const (); // scope 0 at $DIR/enum_opt.rs:+0:16: +4:2 - StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+4:1: +4:2 - return; // scope 0 at $DIR/enum_opt.rs:+4:2: +4:2 + _0 = move _1; // scope 1 at $DIR/enum_opt.rs:+4:3: +4:4 + StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+5:1: +5:2 + return; // scope 0 at $DIR/enum_opt.rs:+5:2: +5:2 } } diff --git a/tests/mir-opt/enum_opt.trunc.EnumSizeOpt.64bit.diff b/tests/mir-opt/enum_opt.trunc.EnumSizeOpt.64bit.diff index b9d6765d8c1ca..1ef79044d4fc6 100644 --- a/tests/mir-opt/enum_opt.trunc.EnumSizeOpt.64bit.diff +++ b/tests/mir-opt/enum_opt.trunc.EnumSizeOpt.64bit.diff @@ -1,8 +1,8 @@ - // MIR for `trunc` before EnumSizeOpt + // MIR for `trunc` after EnumSizeOpt - fn trunc() -> () { - let mut _0: (); // return place in scope 0 at $DIR/enum_opt.rs:+0:16: +0:16 + fn trunc() -> NotTrunctable { + let mut _0: NotTrunctable; // return place in scope 0 at $DIR/enum_opt.rs:+0:19: +0:32 let mut _1: NotTrunctable; // in scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 let mut _2: NotTrunctable; // in scope 0 at $DIR/enum_opt.rs:+2:7: +2:34 let mut _3: [u8; 1024]; // in scope 0 at $DIR/enum_opt.rs:+2:24: +2:33 @@ -14,29 +14,24 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 - Deinit(_1); // scope 0 at $DIR/enum_opt.rs:+1:15: +1:31 - discriminant(_1) = 0; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:31 + _1 = NotTrunctable::A; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:31 StorageLive(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 StorageLive(_3); // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 _3 = [const 0_u8; 1024]; // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 - Deinit(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 - ((_2 as B).0: [u8; 1024]) = move _3; // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 - discriminant(_2) = 1; // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 + _2 = NotTrunctable::B(move _3); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 StorageDead(_3); // scope 1 at $DIR/enum_opt.rs:+2:33: +2:34 _1 = move _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 StorageDead(_2); // scope 1 at $DIR/enum_opt.rs:+2:33: +2:34 StorageLive(_4); // scope 1 at $DIR/enum_opt.rs:+3:7: +3:34 StorageLive(_5); // scope 1 at $DIR/enum_opt.rs:+3:24: +3:33 _5 = [const 0_u8; 4096]; // scope 1 at $DIR/enum_opt.rs:+3:24: +3:33 - Deinit(_4); // scope 1 at $DIR/enum_opt.rs:+3:7: +3:34 - ((_4 as C).0: [u8; 4096]) = move _5; // scope 1 at $DIR/enum_opt.rs:+3:7: +3:34 - discriminant(_4) = 2; // scope 1 at $DIR/enum_opt.rs:+3:7: +3:34 + _4 = NotTrunctable::C(move _5); // scope 1 at $DIR/enum_opt.rs:+3:7: +3:34 StorageDead(_5); // scope 1 at $DIR/enum_opt.rs:+3:33: +3:34 _1 = move _4; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:34 StorageDead(_4); // scope 1 at $DIR/enum_opt.rs:+3:33: +3:34 - _0 = const (); // scope 0 at $DIR/enum_opt.rs:+0:16: +4:2 - StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+4:1: +4:2 - return; // scope 0 at $DIR/enum_opt.rs:+4:2: +4:2 + _0 = move _1; // scope 1 at $DIR/enum_opt.rs:+4:3: +4:4 + StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+5:1: +5:2 + return; // scope 0 at $DIR/enum_opt.rs:+5:2: +5:2 } } diff --git a/tests/mir-opt/enum_opt.unin.EnumSizeOpt.32bit.diff b/tests/mir-opt/enum_opt.unin.EnumSizeOpt.32bit.diff index 168677b173d53..ad9f12cf95953 100644 --- a/tests/mir-opt/enum_opt.unin.EnumSizeOpt.32bit.diff +++ b/tests/mir-opt/enum_opt.unin.EnumSizeOpt.32bit.diff @@ -1,11 +1,11 @@ - // MIR for `unin` before EnumSizeOpt + // MIR for `unin` after EnumSizeOpt - fn unin() -> () { - let mut _0: (); // return place in scope 0 at $DIR/enum_opt.rs:+0:15: +0:15 + fn unin() -> NoData { + let mut _0: NoData; // return place in scope 0 at $DIR/enum_opt.rs:+0:18: +0:24 let mut _1: NoData; // in scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 let mut _2: NoData; // in scope 0 at $DIR/enum_opt.rs:+2:7: +2:31 - let mut _3: [u8; 8192]; // in scope 0 at $DIR/enum_opt.rs:+2:21: +2:30 + let mut _3: [u8; 8196]; // in scope 0 at $DIR/enum_opt.rs:+2:21: +2:30 + let mut _4: [usize; 2]; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 + let mut _5: isize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 + let mut _6: usize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 @@ -14,24 +14,29 @@ + let mut _9: *mut u8; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 + let mut _10: *const NoData; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 + let mut _11: *const u8; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _12: [usize; 2]; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _13: isize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _14: usize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _15: usize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _16: *mut NoData; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _17: *mut u8; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _18: *const NoData; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _19: *const u8; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 scope 1 { debug a => _1; // in scope 1 at $DIR/enum_opt.rs:+1:7: +1:12 } bb0: { StorageLive(_1); // scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 - Deinit(_1); // scope 0 at $DIR/enum_opt.rs:+1:15: +1:27 - discriminant(_1) = 1; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:27 + _1 = NoData::None; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:27 StorageLive(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:31 StorageLive(_3); // scope 1 at $DIR/enum_opt.rs:+2:21: +2:30 - _3 = [const 1_u8; 8192]; // scope 1 at $DIR/enum_opt.rs:+2:21: +2:30 - Deinit(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:31 - ((_2 as Large).0: [u8; 8192]) = move _3; // scope 1 at $DIR/enum_opt.rs:+2:7: +2:31 - discriminant(_2) = 0; // scope 1 at $DIR/enum_opt.rs:+2:7: +2:31 + _3 = [const 1_u8; 8196]; // scope 1 at $DIR/enum_opt.rs:+2:21: +2:30 + _2 = NoData::Large(move _3); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:31 StorageDead(_3); // scope 1 at $DIR/enum_opt.rs:+2:30: +2:31 - _1 = move _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + StorageLive(_4); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 -+ _4 = const [8196_usize, 4_usize]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _4 = const [8197_usize, 1_usize]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + _5 = discriminant(_2); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + _6 = _5 as usize (IntToInt); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + _7 = _4[_6]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 @@ -39,12 +44,25 @@ + _9 = _8 as *mut u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + _10 = &raw const _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + _11 = _10 as *const u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ Deinit(_8); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + copy_nonoverlapping(dst = _9, src = _11, count = _7); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + StorageDead(_4); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 StorageDead(_2); // scope 1 at $DIR/enum_opt.rs:+2:30: +2:31 - _0 = const (); // scope 0 at $DIR/enum_opt.rs:+0:15: +3:2 - StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+3:1: +3:2 - return; // scope 0 at $DIR/enum_opt.rs:+3:2: +3:2 +- _0 = move _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ StorageLive(_12); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _12 = const [8197_usize, 1_usize]; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _13 = discriminant(_1); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _14 = _13 as usize (IntToInt); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _15 = _12[_14]; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _16 = &raw mut _0; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _17 = _16 as *mut u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _18 = &raw const _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _19 = _18 as *const u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ Deinit(_16); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ copy_nonoverlapping(dst = _17, src = _19, count = _15); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ StorageDead(_12); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 + StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+4:1: +4:2 + return; // scope 0 at $DIR/enum_opt.rs:+4:2: +4:2 } } diff --git a/tests/mir-opt/enum_opt.unin.EnumSizeOpt.64bit.diff b/tests/mir-opt/enum_opt.unin.EnumSizeOpt.64bit.diff index 168677b173d53..ad9f12cf95953 100644 --- a/tests/mir-opt/enum_opt.unin.EnumSizeOpt.64bit.diff +++ b/tests/mir-opt/enum_opt.unin.EnumSizeOpt.64bit.diff @@ -1,11 +1,11 @@ - // MIR for `unin` before EnumSizeOpt + // MIR for `unin` after EnumSizeOpt - fn unin() -> () { - let mut _0: (); // return place in scope 0 at $DIR/enum_opt.rs:+0:15: +0:15 + fn unin() -> NoData { + let mut _0: NoData; // return place in scope 0 at $DIR/enum_opt.rs:+0:18: +0:24 let mut _1: NoData; // in scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 let mut _2: NoData; // in scope 0 at $DIR/enum_opt.rs:+2:7: +2:31 - let mut _3: [u8; 8192]; // in scope 0 at $DIR/enum_opt.rs:+2:21: +2:30 + let mut _3: [u8; 8196]; // in scope 0 at $DIR/enum_opt.rs:+2:21: +2:30 + let mut _4: [usize; 2]; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 + let mut _5: isize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 + let mut _6: usize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 @@ -14,24 +14,29 @@ + let mut _9: *mut u8; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 + let mut _10: *const NoData; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 + let mut _11: *const u8; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _12: [usize; 2]; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _13: isize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _14: usize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _15: usize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _16: *mut NoData; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _17: *mut u8; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _18: *const NoData; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _19: *const u8; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 scope 1 { debug a => _1; // in scope 1 at $DIR/enum_opt.rs:+1:7: +1:12 } bb0: { StorageLive(_1); // scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 - Deinit(_1); // scope 0 at $DIR/enum_opt.rs:+1:15: +1:27 - discriminant(_1) = 1; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:27 + _1 = NoData::None; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:27 StorageLive(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:31 StorageLive(_3); // scope 1 at $DIR/enum_opt.rs:+2:21: +2:30 - _3 = [const 1_u8; 8192]; // scope 1 at $DIR/enum_opt.rs:+2:21: +2:30 - Deinit(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:31 - ((_2 as Large).0: [u8; 8192]) = move _3; // scope 1 at $DIR/enum_opt.rs:+2:7: +2:31 - discriminant(_2) = 0; // scope 1 at $DIR/enum_opt.rs:+2:7: +2:31 + _3 = [const 1_u8; 8196]; // scope 1 at $DIR/enum_opt.rs:+2:21: +2:30 + _2 = NoData::Large(move _3); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:31 StorageDead(_3); // scope 1 at $DIR/enum_opt.rs:+2:30: +2:31 - _1 = move _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + StorageLive(_4); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 -+ _4 = const [8196_usize, 4_usize]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _4 = const [8197_usize, 1_usize]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + _5 = discriminant(_2); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + _6 = _5 as usize (IntToInt); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + _7 = _4[_6]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 @@ -39,12 +44,25 @@ + _9 = _8 as *mut u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + _10 = &raw const _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + _11 = _10 as *const u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ Deinit(_8); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + copy_nonoverlapping(dst = _9, src = _11, count = _7); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + StorageDead(_4); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 StorageDead(_2); // scope 1 at $DIR/enum_opt.rs:+2:30: +2:31 - _0 = const (); // scope 0 at $DIR/enum_opt.rs:+0:15: +3:2 - StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+3:1: +3:2 - return; // scope 0 at $DIR/enum_opt.rs:+3:2: +3:2 +- _0 = move _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ StorageLive(_12); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _12 = const [8197_usize, 1_usize]; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _13 = discriminant(_1); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _14 = _13 as usize (IntToInt); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _15 = _12[_14]; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _16 = &raw mut _0; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _17 = _16 as *mut u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _18 = &raw const _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _19 = _18 as *const u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ Deinit(_16); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ copy_nonoverlapping(dst = _17, src = _19, count = _15); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ StorageDead(_12); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 + StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+4:1: +4:2 + return; // scope 0 at $DIR/enum_opt.rs:+4:2: +4:2 } }