From faaf81bbbcd5114ad8268190f3cc235868997ae3 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 12 Feb 2024 04:56:03 +0100 Subject: [PATCH] Start blocks eagerly --- .../rustc_mir_build/src/build/matches/mod.rs | 132 ++++++++---------- ...await.b-{closure#0}.coroutine_resume.0.mir | 14 +- .../issue_101867.main.built.after.mir | 17 ++- .../building/issue_49232.main.built.after.mir | 31 ++-- ...n_conditional.test_complex.built.after.mir | 116 ++++++++------- ...se_edges.full_tested_match.built.after.mir | 25 ++-- ...e_edges.full_tested_match2.built.after.mir | 27 ++-- .../match_false_edges.main.built.after.mir | 80 ++++++----- .../simple_match.match_bool.built.after.mir | 15 +- ...e_out.move_out_by_subslice.built.after.mir | 35 +++-- ...move_out.move_out_from_end.built.after.mir | 35 +++-- ...ssue_107511.main.CopyProp.panic-abort.diff | 10 +- ...sue_107511.main.CopyProp.panic-unwind.diff | 10 +- ...enum.constant.DataflowConstProp.32bit.diff | 12 +- ...enum.constant.DataflowConstProp.64bit.diff | 12 +- ...enum.multiple.DataflowConstProp.32bit.diff | 8 +- ...enum.multiple.DataflowConstProp.64bit.diff | 8 +- tests/mir-opt/dataflow-const-prop/enum.rs | 6 +- .../enum.simple.DataflowConstProp.32bit.diff | 12 +- .../enum.simple.DataflowConstProp.64bit.diff | 12 +- .../enum.statics.DataflowConstProp.32bit.diff | 14 +- .../enum.statics.DataflowConstProp.64bit.diff | 14 +- ...mment_2.DeduplicateBlocks.panic-abort.diff | 46 +++--- ...ment_2.DeduplicateBlocks.panic-unwind.diff | 46 +++--- ...complex_case.main.Derefer.panic-abort.diff | 10 +- ...omplex_case.main.Derefer.panic-unwind.diff | 10 +- ...wise_branch.opt2.EarlyOtherwiseBranch.diff | 15 +- ...ch_68867.try_sum.EarlyOtherwiseBranch.diff | 20 +-- ...nch_noopt.noopt1.EarlyOtherwiseBranch.diff | 14 +- .../gvn.wrap_unwrap.GVN.panic-abort.diff | 10 +- .../gvn.wrap_unwrap.GVN.panic-unwind.diff | 10 +- ...d.unwrap_unchecked.Inline.panic-abort.diff | 12 +- ....unwrap_unchecked.Inline.panic-unwind.diff | 12 +- ...test.ElaborateDrops.before.panic-abort.mir | 10 +- ...est.ElaborateDrops.before.panic-unwind.mir | 10 +- tests/mir-opt/issue_72181.bar.built.after.mir | 5 + .../mir-opt/issue_72181.main.built.after.mir | 16 ++- tests/mir-opt/issue_72181_1.f.built.after.mir | 6 +- tests/mir-opt/issue_91633.bar.built.after.mir | 15 +- tests/mir-opt/issue_91633.hey.built.after.mir | 9 +- .../issue_99325.main.built.after.32bit.mir | 82 ++++++----- .../issue_99325.main.built.after.64bit.mir | 82 ++++++----- ...reading.dfa.JumpThreading.panic-abort.diff | 10 +- ...eading.dfa.JumpThreading.panic-unwind.diff | 10 +- ...ng.identity.JumpThreading.panic-abort.diff | 14 +- ...g.identity.JumpThreading.panic-unwind.diff | 14 +- tests/mir-opt/jump_threading.rs | 20 +-- ...too_complex.JumpThreading.panic-abort.diff | 12 +- ...oo_complex.JumpThreading.panic-unwind.diff | 12 +- ...fg-initial.after-ElaborateDrops.after.diff | 28 ++-- ...fg-initial.after-ElaborateDrops.after.diff | 28 ++-- ...ch_test.main.SimplifyCfg-initial.after.mir | 14 +- ...stive_match.MatchBranchSimplification.diff | 8 +- ...ve_match_i8.MatchBranchSimplification.diff | 8 +- ...yCfg-elaborate-drops.after.panic-abort.mir | 8 +- ...Cfg-elaborate-drops.after.panic-unwind.mir | 8 +- ...e_prop.debuginfo.ReferencePropagation.diff | 10 +- ...main.RemoveStorageMarkers.panic-abort.diff | 10 +- ...ain.RemoveStorageMarkers.panic-unwind.diff | 10 +- ....map.SimplifyLocals-before-const-prop.diff | 10 +- ...nching.byref.UninhabitedEnumBranching.diff | 14 +- ...discriminant.UninhabitedEnumBranching.diff | 12 +- tests/mir-opt/uninhabited_enum_branching.rs | 6 +- ...ching.simple.UninhabitedEnumBranching.diff | 12 +- ...ch.UnreachablePropagation.panic-abort.diff | 8 +- ...h.UnreachablePropagation.panic-unwind.diff | 8 +- 66 files changed, 744 insertions(+), 635 deletions(-) diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index 906b3205ca75d..35f5a6bfac5f4 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -319,7 +319,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // them. let mut fake_borrows = match_has_guard.then(FxIndexSet::default); - let mut otherwise = None; + let otherwise_block = self.cfg.start_new_block(); // This will generate code to test scrutinee_place and // branch to the appropriate arm block @@ -327,46 +327,44 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { match_start_span, scrutinee_span, block, - &mut otherwise, + otherwise_block, candidates, &mut fake_borrows, ); - if let Some(otherwise_block) = otherwise { - // See the doc comment on `match_candidates` for why we may have an - // otherwise block. Match checking will ensure this is actually - // unreachable. - let source_info = self.source_info(scrutinee_span); - - // Matching on a `scrutinee_place` with an uninhabited type doesn't - // generate any memory reads by itself, and so if the place "expression" - // contains unsafe operations like raw pointer dereferences or union - // field projections, we wouldn't know to require an `unsafe` block - // around a `match` equivalent to `std::intrinsics::unreachable()`. - // See issue #47412 for this hole being discovered in the wild. - // - // HACK(eddyb) Work around the above issue by adding a dummy inspection - // of `scrutinee_place`, specifically by applying `ReadForMatch`. - // - // NOTE: ReadForMatch also checks that the scrutinee is initialized. - // This is currently needed to not allow matching on an uninitialized, - // uninhabited value. If we get never patterns, those will check that - // the place is initialized, and so this read would only be used to - // check safety. - let cause_matched_place = FakeReadCause::ForMatchedPlace(None); - - if let Some(scrutinee_place) = scrutinee_place_builder.try_to_place(self) { - self.cfg.push_fake_read( - otherwise_block, - source_info, - cause_matched_place, - scrutinee_place, - ); - } + // See the doc comment on `match_candidates` for why we may have an + // otherwise block. Match checking will ensure this is actually + // unreachable. + let source_info = self.source_info(scrutinee_span); + + // Matching on a `scrutinee_place` with an uninhabited type doesn't + // generate any memory reads by itself, and so if the place "expression" + // contains unsafe operations like raw pointer dereferences or union + // field projections, we wouldn't know to require an `unsafe` block + // around a `match` equivalent to `std::intrinsics::unreachable()`. + // See issue #47412 for this hole being discovered in the wild. + // + // HACK(eddyb) Work around the above issue by adding a dummy inspection + // of `scrutinee_place`, specifically by applying `ReadForMatch`. + // + // NOTE: ReadForMatch also checks that the scrutinee is initialized. + // This is currently needed to not allow matching on an uninitialized, + // uninhabited value. If we get never patterns, those will check that + // the place is initialized, and so this read would only be used to + // check safety. + let cause_matched_place = FakeReadCause::ForMatchedPlace(None); - self.cfg.terminate(otherwise_block, source_info, TerminatorKind::Unreachable); + if let Some(scrutinee_place) = scrutinee_place_builder.try_to_place(self) { + self.cfg.push_fake_read( + otherwise_block, + source_info, + cause_matched_place, + scrutinee_place, + ); } + self.cfg.terminate(otherwise_block, source_info, TerminatorKind::Unreachable); + // Link each leaf candidate to the `pre_binding_block` of the next one. let mut previous_candidate: Option<&mut Candidate<'_, '_>> = None; @@ -1163,7 +1161,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { span: Span, scrutinee_span: Span, start_block: BasicBlock, - otherwise_block: &mut Option, + otherwise_block: BasicBlock, candidates: &mut [&mut Candidate<'pat, 'tcx>], fake_borrows: &mut Option>>, ) { @@ -1210,7 +1208,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { span: Span, scrutinee_span: Span, start_block: BasicBlock, - otherwise_block: &mut Option, + otherwise_block: BasicBlock, candidates: &mut [&mut Candidate<'_, 'tcx>], fake_borrows: &mut Option>>, ) { @@ -1243,11 +1241,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // never reach this point. if unmatched_candidates.is_empty() { let source_info = self.source_info(span); - if let Some(otherwise) = *otherwise_block { - self.cfg.goto(block, source_info, otherwise); - } else { - *otherwise_block = Some(block); - } + self.cfg.goto(block, source_info, otherwise_block); return; } @@ -1428,7 +1422,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { scrutinee_span: Span, candidates: &mut [&mut Candidate<'_, 'tcx>], block: BasicBlock, - otherwise_block: &mut Option, + otherwise_block: BasicBlock, fake_borrows: &mut Option>>, ) { let (first_candidate, remaining_candidates) = candidates.split_first_mut().unwrap(); @@ -1453,7 +1447,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let match_pairs = mem::take(&mut first_candidate.match_pairs); first_candidate.pre_binding_block = Some(block); - let mut otherwise = None; + let remainder_start = self.cfg.start_new_block(); for match_pair in match_pairs { let PatKind::Or { ref pats } = &match_pair.pattern.kind else { bug!("Or-patterns should have been sorted to the end"); @@ -1463,7 +1457,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { first_candidate.visit_leaves(|leaf_candidate| { self.test_or_pattern( leaf_candidate, - &mut otherwise, + remainder_start, pats, or_span, &match_pair.place, @@ -1472,8 +1466,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }); } - let remainder_start = otherwise.unwrap_or_else(|| self.cfg.start_new_block()); - self.match_candidates( span, scrutinee_span, @@ -1491,7 +1483,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { fn test_or_pattern<'pat>( &mut self, candidate: &mut Candidate<'pat, 'tcx>, - otherwise: &mut Option, + otherwise: BasicBlock, pats: &'pat [Box>], or_span: Span, place: &PlaceBuilder<'tcx>, @@ -1503,8 +1495,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .map(|pat| Candidate::new(place.clone(), pat, candidate.has_guard, self)) .collect(); let mut or_candidate_refs: Vec<_> = or_candidates.iter_mut().collect(); - let otherwise = if candidate.otherwise_block.is_some() { - &mut candidate.otherwise_block + let otherwise = if let Some(otherwise_block) = candidate.otherwise_block { + otherwise_block } else { otherwise }; @@ -1680,8 +1672,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { span: Span, scrutinee_span: Span, mut candidates: &'b mut [&'c mut Candidate<'pat, 'tcx>], - block: BasicBlock, - otherwise_block: &mut Option, + start_block: BasicBlock, + otherwise_block: BasicBlock, fake_borrows: &mut Option>>, ) { // extract the match-pair from the highest priority candidate @@ -1749,12 +1741,21 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { debug!("untested_candidates: {}", candidates.len()); // The block that we should branch to if none of the - // `target_candidates` match. This is either the block where we - // start matching the untested candidates if there are any, - // otherwise it's the `otherwise_block`. - let remainder_start = &mut None; - let remainder_start = - if candidates.is_empty() { &mut *otherwise_block } else { remainder_start }; + // `target_candidates` match. + let remainder_start = if !candidates.is_empty() { + let remainder_start = self.cfg.start_new_block(); + self.match_candidates( + span, + scrutinee_span, + remainder_start, + otherwise_block, + candidates, + fake_borrows, + ); + remainder_start + } else { + otherwise_block + }; // For each outcome of test, process the candidates that still // apply. Collect a list of blocks where control flow will @@ -1775,24 +1776,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ); candidate_start } else { - *remainder_start.get_or_insert_with(|| self.cfg.start_new_block()) + remainder_start } }) .collect(); - if !candidates.is_empty() { - let remainder_start = remainder_start.unwrap_or_else(|| self.cfg.start_new_block()); - self.match_candidates( - span, - scrutinee_span, - remainder_start, - otherwise_block, - candidates, - fake_borrows, - ); - } - - self.perform_test(span, scrutinee_span, block, &match_place, &test, target_blocks); + // Perform the test, branching to one of N blocks. + self.perform_test(span, scrutinee_span, start_block, &match_place, &test, target_blocks); } /// Determine the fake borrows that are needed from a set of places that diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir index 9c8cf8763fdf1..2f7c4f7d40221 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir @@ -110,7 +110,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:15:18: 18:2}>, bb0: { _39 = discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2}))); - switchInt(move _39) -> [0: bb1, 1: bb29, 3: bb27, 4: bb28, otherwise: bb9]; + switchInt(move _39) -> [0: bb1, 1: bb29, 3: bb27, 4: bb28, otherwise: bb8]; } bb1: { @@ -165,10 +165,14 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:15:18: 18:2}>, StorageDead(_10); PlaceMention(_9); _16 = discriminant(_9); - switchInt(move _16) -> [0: bb10, 1: bb8, otherwise: bb9]; + switchInt(move _16) -> [0: bb10, 1: bb9, otherwise: bb8]; } bb8: { + unreachable; + } + + bb9: { _8 = const (); StorageDead(_14); StorageDead(_12); @@ -186,10 +190,6 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:15:18: 18:2}>, return; } - bb9: { - unreachable; - } - bb10: { StorageLive(_17); _17 = ((_9 as Ready).0: ()); @@ -267,7 +267,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:15:18: 18:2}>, StorageDead(_26); PlaceMention(_25); _32 = discriminant(_25); - switchInt(move _32) -> [0: bb21, 1: bb20, otherwise: bb9]; + switchInt(move _32) -> [0: bb21, 1: bb20, otherwise: bb8]; } bb20: { diff --git a/tests/mir-opt/building/issue_101867.main.built.after.mir b/tests/mir-opt/building/issue_101867.main.built.after.mir index 57f8cca9abc75..028d7ee7cd868 100644 --- a/tests/mir-opt/building/issue_101867.main.built.after.mir +++ b/tests/mir-opt/building/issue_101867.main.built.after.mir @@ -27,13 +27,13 @@ fn main() -> () { StorageLive(_5); PlaceMention(_1); _6 = discriminant(_1); - switchInt(move _6) -> [1: bb4, otherwise: bb3]; + switchInt(move _6) -> [1: bb5, otherwise: bb4]; } bb1: { StorageLive(_3); StorageLive(_4); - _4 = begin_panic::<&str>(const "explicit panic") -> bb7; + _4 = begin_panic::<&str>(const "explicit panic") -> bb8; } bb2: { @@ -43,14 +43,19 @@ fn main() -> () { } bb3: { - goto -> bb6; + FakeRead(ForMatchedPlace(None), _1); + unreachable; } bb4: { - falseEdge -> [real: bb5, imaginary: bb3]; + goto -> bb7; } bb5: { + falseEdge -> [real: bb6, imaginary: bb4]; + } + + bb6: { _5 = ((_1 as Some).0: u8); _0 = const (); StorageDead(_5); @@ -58,12 +63,12 @@ fn main() -> () { return; } - bb6: { + bb7: { StorageDead(_5); goto -> bb1; } - bb7 (cleanup): { + bb8 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/issue_49232.main.built.after.mir b/tests/mir-opt/building/issue_49232.main.built.after.mir index ac50b38891079..7c1f5a6ec72d5 100644 --- a/tests/mir-opt/building/issue_49232.main.built.after.mir +++ b/tests/mir-opt/building/issue_49232.main.built.after.mir @@ -17,7 +17,7 @@ fn main() -> () { } bb1: { - falseUnwind -> [real: bb2, unwind: bb11]; + falseUnwind -> [real: bb2, unwind: bb12]; } bb2: { @@ -25,41 +25,46 @@ fn main() -> () { StorageLive(_3); _3 = const true; PlaceMention(_3); - switchInt(_3) -> [0: bb3, otherwise: bb4]; + switchInt(_3) -> [0: bb4, otherwise: bb5]; } bb3: { - falseEdge -> [real: bb5, imaginary: bb4]; + FakeRead(ForMatchedPlace(None), _3); + unreachable; } bb4: { - _0 = const (); - goto -> bb10; + falseEdge -> [real: bb6, imaginary: bb5]; } bb5: { - _2 = const 4_i32; - goto -> bb8; + _0 = const (); + goto -> bb11; } bb6: { - unreachable; + _2 = const 4_i32; + goto -> bb9; } bb7: { - goto -> bb8; + unreachable; } bb8: { + goto -> bb9; + } + + bb9: { FakeRead(ForLet(None), _2); StorageDead(_3); StorageLive(_5); StorageLive(_6); _6 = &_2; - _5 = std::mem::drop::<&i32>(move _6) -> [return: bb9, unwind: bb11]; + _5 = std::mem::drop::<&i32>(move _6) -> [return: bb10, unwind: bb12]; } - bb9: { + bb10: { StorageDead(_6); StorageDead(_5); _1 = const (); @@ -67,13 +72,13 @@ fn main() -> () { goto -> bb1; } - bb10: { + bb11: { StorageDead(_3); StorageDead(_2); return; } - bb11 (cleanup): { + bb12 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir b/tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir index 7407e7a8b2a17..d7c758d8876aa 100644 --- a/tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir +++ b/tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir @@ -19,168 +19,178 @@ fn test_complex() -> () { bb0: { StorageLive(_1); StorageLive(_2); - _2 = E::f() -> [return: bb1, unwind: bb31]; + _2 = E::f() -> [return: bb1, unwind: bb33]; } bb1: { PlaceMention(_2); _3 = discriminant(_2); - switchInt(move _3) -> [0: bb2, otherwise: bb3]; + switchInt(move _3) -> [0: bb4, otherwise: bb3]; } bb2: { - falseEdge -> [real: bb4, imaginary: bb3]; + FakeRead(ForMatchedPlace(None), _2); + unreachable; } bb3: { - goto -> bb19; + goto -> bb20; } bb4: { - StorageLive(_4); - _4 = always_true() -> [return: bb5, unwind: bb31]; + falseEdge -> [real: bb5, imaginary: bb3]; } bb5: { - switchInt(move _4) -> [0: bb7, otherwise: bb6]; + StorageLive(_4); + _4 = always_true() -> [return: bb6, unwind: bb33]; } bb6: { + switchInt(move _4) -> [0: bb8, otherwise: bb7]; + } + + bb7: { StorageLive(_5); StorageLive(_6); StorageLive(_7); _7 = Droppy(const 0_u8); _6 = (_7.0: u8); _5 = Gt(move _6, const 0_u8); - switchInt(move _5) -> [0: bb9, otherwise: bb8]; - } - - bb7: { - goto -> bb13; + switchInt(move _5) -> [0: bb10, otherwise: bb9]; } bb8: { - drop(_7) -> [return: bb10, unwind: bb31]; + goto -> bb14; } bb9: { - goto -> bb11; + drop(_7) -> [return: bb11, unwind: bb33]; } bb10: { - StorageDead(_7); - StorageDead(_6); - goto -> bb16; + goto -> bb12; } bb11: { - drop(_7) -> [return: bb12, unwind: bb31]; + StorageDead(_7); + StorageDead(_6); + goto -> bb17; } bb12: { + drop(_7) -> [return: bb13, unwind: bb33]; + } + + bb13: { StorageDead(_7); StorageDead(_6); - goto -> bb13; + goto -> bb14; } - bb13: { + bb14: { StorageLive(_8); StorageLive(_9); StorageLive(_10); _10 = Droppy(const 1_u8); _9 = (_10.0: u8); _8 = Gt(move _9, const 1_u8); - switchInt(move _8) -> [0: bb15, otherwise: bb14]; - } - - bb14: { - drop(_10) -> [return: bb16, unwind: bb31]; + switchInt(move _8) -> [0: bb16, otherwise: bb15]; } bb15: { - goto -> bb17; + drop(_10) -> [return: bb17, unwind: bb33]; } bb16: { + goto -> bb18; + } + + bb17: { StorageDead(_10); StorageDead(_9); _1 = const (); - goto -> bb20; + goto -> bb21; } - bb17: { - drop(_10) -> [return: bb18, unwind: bb31]; + bb18: { + drop(_10) -> [return: bb19, unwind: bb33]; } - bb18: { + bb19: { StorageDead(_10); StorageDead(_9); - goto -> bb19; + goto -> bb20; } - bb19: { + bb20: { _1 = const (); - goto -> bb20; + goto -> bb21; } - bb20: { + bb21: { StorageDead(_8); StorageDead(_5); StorageDead(_4); StorageDead(_2); StorageDead(_1); StorageLive(_11); - _11 = always_true() -> [return: bb21, unwind: bb31]; - } - - bb21: { - switchInt(move _11) -> [0: bb23, otherwise: bb22]; + _11 = always_true() -> [return: bb22, unwind: bb33]; } bb22: { - goto -> bb29; + switchInt(move _11) -> [0: bb24, otherwise: bb23]; } bb23: { - goto -> bb24; + goto -> bb31; } bb24: { - StorageLive(_12); - _12 = E::f() -> [return: bb25, unwind: bb31]; + goto -> bb25; } bb25: { - PlaceMention(_12); - _13 = discriminant(_12); - switchInt(move _13) -> [1: bb27, otherwise: bb26]; + StorageLive(_12); + _12 = E::f() -> [return: bb26, unwind: bb33]; } bb26: { - goto -> bb29; + PlaceMention(_12); + _13 = discriminant(_12); + switchInt(move _13) -> [1: bb29, otherwise: bb28]; } bb27: { - falseEdge -> [real: bb28, imaginary: bb26]; + FakeRead(ForMatchedPlace(None), _12); + unreachable; } bb28: { - _0 = const (); - goto -> bb30; + goto -> bb31; } bb29: { - _0 = const (); - goto -> bb30; + falseEdge -> [real: bb30, imaginary: bb28]; } bb30: { + _0 = const (); + goto -> bb32; + } + + bb31: { + _0 = const (); + goto -> bb32; + } + + bb32: { StorageDead(_11); StorageDead(_12); return; } - bb31 (cleanup): { + bb33 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir b/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir index b99b0b99559a5..88292dd05972e 100644 --- a/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir +++ b/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir @@ -28,25 +28,25 @@ fn full_tested_match() -> () { _2 = Option::::Some(const 42_i32); PlaceMention(_2); _3 = discriminant(_2); - switchInt(move _3) -> [0: bb1, 1: bb2, otherwise: bb4]; + switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; } bb1: { - _1 = (const 3_i32, const 3_i32); - goto -> bb11; + FakeRead(ForMatchedPlace(None), _2); + unreachable; } bb2: { - falseEdge -> [real: bb5, imaginary: bb3]; + _1 = (const 3_i32, const 3_i32); + goto -> bb11; } bb3: { - falseEdge -> [real: bb10, imaginary: bb1]; + falseEdge -> [real: bb5, imaginary: bb4]; } bb4: { - FakeRead(ForMatchedPlace(None), _2); - unreachable; + falseEdge -> [real: bb10, imaginary: bb2]; } bb5: { @@ -54,7 +54,7 @@ fn full_tested_match() -> () { _6 = &((_2 as Some).0: i32); _4 = &fake _2; StorageLive(_7); - _7 = guard() -> [return: bb6, unwind: bb12]; + _7 = guard() -> [return: bb6, unwind: bb13]; } bb6: { @@ -83,7 +83,7 @@ fn full_tested_match() -> () { bb9: { StorageDead(_7); StorageDead(_6); - goto -> bb3; + goto -> bb4; } bb10: { @@ -105,7 +105,12 @@ fn full_tested_match() -> () { return; } - bb12 (cleanup): { + bb12: { + FakeRead(ForMatchedPlace(None), _1); + unreachable; + } + + bb13 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir b/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir index d1d86b55d686f..205bb4980d904 100644 --- a/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir +++ b/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir @@ -28,18 +28,23 @@ fn full_tested_match2() -> () { _2 = Option::::Some(const 42_i32); PlaceMention(_2); _3 = discriminant(_2); - switchInt(move _3) -> [0: bb1, 1: bb2, otherwise: bb4]; + switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; } bb1: { - falseEdge -> [real: bb10, imaginary: bb3]; + FakeRead(ForMatchedPlace(None), _2); + unreachable; } bb2: { - falseEdge -> [real: bb5, imaginary: bb1]; + falseEdge -> [real: bb10, imaginary: bb4]; } bb3: { + falseEdge -> [real: bb5, imaginary: bb2]; + } + + bb4: { StorageLive(_9); _9 = ((_2 as Some).0: i32); StorageLive(_10); @@ -50,17 +55,12 @@ fn full_tested_match2() -> () { goto -> bb11; } - bb4: { - FakeRead(ForMatchedPlace(None), _2); - unreachable; - } - bb5: { StorageLive(_6); _6 = &((_2 as Some).0: i32); _4 = &fake _2; StorageLive(_7); - _7 = guard() -> [return: bb6, unwind: bb12]; + _7 = guard() -> [return: bb6, unwind: bb13]; } bb6: { @@ -89,7 +89,7 @@ fn full_tested_match2() -> () { bb9: { StorageDead(_7); StorageDead(_6); - falseEdge -> [real: bb3, imaginary: bb1]; + falseEdge -> [real: bb4, imaginary: bb2]; } bb10: { @@ -105,7 +105,12 @@ fn full_tested_match2() -> () { return; } - bb12 (cleanup): { + bb12: { + FakeRead(ForMatchedPlace(None), _1); + unreachable; + } + + bb13 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/match_false_edges.main.built.after.mir b/tests/mir-opt/building/match_false_edges.main.built.after.mir index 1d4fe67f350ca..21f377a640452 100644 --- a/tests/mir-opt/building/match_false_edges.main.built.after.mir +++ b/tests/mir-opt/building/match_false_edges.main.built.after.mir @@ -39,55 +39,60 @@ fn main() -> () { _2 = Option::::Some(const 1_i32); PlaceMention(_2); _4 = discriminant(_2); - switchInt(move _4) -> [1: bb2, otherwise: bb1]; + switchInt(move _4) -> [1: bb7, otherwise: bb2]; } bb1: { - falseEdge -> [real: bb13, imaginary: bb6]; + FakeRead(ForMatchedPlace(None), _2); + unreachable; } bb2: { - falseEdge -> [real: bb8, imaginary: bb1]; + falseEdge -> [real: bb14, imaginary: bb5]; } bb3: { - goto -> bb1; - } - - bb4: { _3 = discriminant(_2); - switchInt(move _3) -> [1: bb6, otherwise: bb5]; + switchInt(move _3) -> [1: bb5, otherwise: bb4]; } - bb5: { + bb4: { StorageLive(_14); _14 = _2; _1 = const 4_i32; StorageDead(_14); - goto -> bb19; + goto -> bb20; + } + + bb5: { + falseEdge -> [real: bb15, imaginary: bb4]; } bb6: { - falseEdge -> [real: bb14, imaginary: bb5]; + goto -> bb4; } bb7: { - goto -> bb5; + falseEdge -> [real: bb9, imaginary: bb2]; } bb8: { + goto -> bb2; + } + + bb9: { StorageLive(_7); _7 = &((_2 as Some).0: i32); _5 = &fake _2; StorageLive(_8); - _8 = guard() -> [return: bb9, unwind: bb20]; + _8 = guard() -> [return: bb10, unwind: bb22]; } - bb9: { - switchInt(move _8) -> [0: bb11, otherwise: bb10]; + bb10: { + switchInt(move _8) -> [0: bb12, otherwise: bb11]; } - bb10: { + bb11: { StorageDead(_8); FakeRead(ForMatchGuard, _5); FakeRead(ForGuardBinding, _7); @@ -96,42 +101,42 @@ fn main() -> () { _1 = const 1_i32; StorageDead(_6); StorageDead(_7); - goto -> bb19; + goto -> bb20; } - bb11: { - goto -> bb12; + bb12: { + goto -> bb13; } - bb12: { + bb13: { StorageDead(_8); StorageDead(_7); - falseEdge -> [real: bb3, imaginary: bb1]; + falseEdge -> [real: bb8, imaginary: bb2]; } - bb13: { + bb14: { StorageLive(_9); _9 = _2; _1 = const 2_i32; StorageDead(_9); - goto -> bb19; + goto -> bb20; } - bb14: { + bb15: { StorageLive(_11); _11 = &((_2 as Some).0: i32); _5 = &fake _2; StorageLive(_12); StorageLive(_13); _13 = (*_11); - _12 = guard2(move _13) -> [return: bb15, unwind: bb20]; + _12 = guard2(move _13) -> [return: bb16, unwind: bb22]; } - bb15: { - switchInt(move _12) -> [0: bb17, otherwise: bb16]; + bb16: { + switchInt(move _12) -> [0: bb18, otherwise: bb17]; } - bb16: { + bb17: { StorageDead(_13); StorageDead(_12); FakeRead(ForMatchGuard, _5); @@ -141,21 +146,21 @@ fn main() -> () { _1 = const 3_i32; StorageDead(_10); StorageDead(_11); - goto -> bb19; + goto -> bb20; } - bb17: { - goto -> bb18; + bb18: { + goto -> bb19; } - bb18: { + bb19: { StorageDead(_13); StorageDead(_12); StorageDead(_11); - falseEdge -> [real: bb7, imaginary: bb5]; + falseEdge -> [real: bb6, imaginary: bb4]; } - bb19: { + bb20: { PlaceMention(_1); StorageDead(_2); StorageDead(_1); @@ -163,7 +168,12 @@ fn main() -> () { return; } - bb20 (cleanup): { + bb21: { + FakeRead(ForMatchedPlace(None), _1); + unreachable; + } + + bb22 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/simple_match.match_bool.built.after.mir b/tests/mir-opt/building/simple_match.match_bool.built.after.mir index 06de4c5105125..cd51c942bee08 100644 --- a/tests/mir-opt/building/simple_match.match_bool.built.after.mir +++ b/tests/mir-opt/building/simple_match.match_bool.built.after.mir @@ -6,24 +6,29 @@ fn match_bool(_1: bool) -> usize { bb0: { PlaceMention(_1); - switchInt(_1) -> [0: bb2, otherwise: bb1]; + switchInt(_1) -> [0: bb2, otherwise: bb3]; } bb1: { - falseEdge -> [real: bb3, imaginary: bb2]; + FakeRead(ForMatchedPlace(None), _1); + unreachable; } bb2: { _0 = const 20_usize; - goto -> bb4; + goto -> bb5; } bb3: { - _0 = const 10_usize; - goto -> bb4; + falseEdge -> [real: bb4, imaginary: bb2]; } bb4: { + _0 = const 10_usize; + goto -> bb5; + } + + bb5: { return; } } diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir index 82424de03926d..282c9704ffca7 100644 --- a/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir +++ b/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir @@ -30,7 +30,7 @@ fn move_out_by_subslice() -> () { StorageLive(_2); _3 = SizeOf(i32); _4 = AlignOf(i32); - _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; + _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb13]; } bb1: { @@ -38,7 +38,7 @@ fn move_out_by_subslice() -> () { _6 = ShallowInitBox(move _5, i32); (*_6) = const 1_i32; _2 = move _6; - drop(_6) -> [return: bb2, unwind: bb11]; + drop(_6) -> [return: bb2, unwind: bb12]; } bb2: { @@ -46,7 +46,7 @@ fn move_out_by_subslice() -> () { StorageLive(_7); _8 = SizeOf(i32); _9 = AlignOf(i32); - _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; + _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb12]; } bb3: { @@ -54,18 +54,18 @@ fn move_out_by_subslice() -> () { _11 = ShallowInitBox(move _10, i32); (*_11) = const 2_i32; _7 = move _11; - drop(_11) -> [return: bb4, unwind: bb10]; + drop(_11) -> [return: bb4, unwind: bb11]; } bb4: { StorageDead(_11); _1 = [move _2, move _7]; - drop(_7) -> [return: bb5, unwind: bb11]; + drop(_7) -> [return: bb5, unwind: bb12]; } bb5: { StorageDead(_7); - drop(_2) -> [return: bb6, unwind: bb12]; + drop(_2) -> [return: bb6, unwind: bb13]; } bb6: { @@ -75,32 +75,37 @@ fn move_out_by_subslice() -> () { StorageLive(_12); _12 = move _1[0..2]; _0 = const (); - drop(_12) -> [return: bb7, unwind: bb9]; + drop(_12) -> [return: bb8, unwind: bb10]; } bb7: { - StorageDead(_12); - drop(_1) -> [return: bb8, unwind: bb12]; + FakeRead(ForMatchedPlace(None), _1); + unreachable; } bb8: { - StorageDead(_1); - return; + StorageDead(_12); + drop(_1) -> [return: bb9, unwind: bb13]; } - bb9 (cleanup): { - drop(_1) -> [return: bb12, unwind terminate(cleanup)]; + bb9: { + StorageDead(_1); + return; } bb10 (cleanup): { - drop(_7) -> [return: bb11, unwind terminate(cleanup)]; + drop(_1) -> [return: bb13, unwind terminate(cleanup)]; } bb11 (cleanup): { - drop(_2) -> [return: bb12, unwind terminate(cleanup)]; + drop(_7) -> [return: bb12, unwind terminate(cleanup)]; } bb12 (cleanup): { + drop(_2) -> [return: bb13, unwind terminate(cleanup)]; + } + + bb13 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir index 0872d1b6ac0c2..d1956c91b88c0 100644 --- a/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir +++ b/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir @@ -30,7 +30,7 @@ fn move_out_from_end() -> () { StorageLive(_2); _3 = SizeOf(i32); _4 = AlignOf(i32); - _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; + _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb13]; } bb1: { @@ -38,7 +38,7 @@ fn move_out_from_end() -> () { _6 = ShallowInitBox(move _5, i32); (*_6) = const 1_i32; _2 = move _6; - drop(_6) -> [return: bb2, unwind: bb11]; + drop(_6) -> [return: bb2, unwind: bb12]; } bb2: { @@ -46,7 +46,7 @@ fn move_out_from_end() -> () { StorageLive(_7); _8 = SizeOf(i32); _9 = AlignOf(i32); - _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; + _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb12]; } bb3: { @@ -54,18 +54,18 @@ fn move_out_from_end() -> () { _11 = ShallowInitBox(move _10, i32); (*_11) = const 2_i32; _7 = move _11; - drop(_11) -> [return: bb4, unwind: bb10]; + drop(_11) -> [return: bb4, unwind: bb11]; } bb4: { StorageDead(_11); _1 = [move _2, move _7]; - drop(_7) -> [return: bb5, unwind: bb11]; + drop(_7) -> [return: bb5, unwind: bb12]; } bb5: { StorageDead(_7); - drop(_2) -> [return: bb6, unwind: bb12]; + drop(_2) -> [return: bb6, unwind: bb13]; } bb6: { @@ -75,32 +75,37 @@ fn move_out_from_end() -> () { StorageLive(_12); _12 = move _1[1 of 2]; _0 = const (); - drop(_12) -> [return: bb7, unwind: bb9]; + drop(_12) -> [return: bb8, unwind: bb10]; } bb7: { - StorageDead(_12); - drop(_1) -> [return: bb8, unwind: bb12]; + FakeRead(ForMatchedPlace(None), _1); + unreachable; } bb8: { - StorageDead(_1); - return; + StorageDead(_12); + drop(_1) -> [return: bb9, unwind: bb13]; } - bb9 (cleanup): { - drop(_1) -> [return: bb12, unwind terminate(cleanup)]; + bb9: { + StorageDead(_1); + return; } bb10 (cleanup): { - drop(_7) -> [return: bb11, unwind terminate(cleanup)]; + drop(_1) -> [return: bb13, unwind terminate(cleanup)]; } bb11 (cleanup): { - drop(_2) -> [return: bb12, unwind terminate(cleanup)]; + drop(_7) -> [return: bb12, unwind terminate(cleanup)]; } bb12 (cleanup): { + drop(_2) -> [return: bb13, unwind terminate(cleanup)]; + } + + bb13 (cleanup): { resume; } } diff --git a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-abort.diff index a802d0256d486..51390e2abbe9a 100644 --- a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-abort.diff +++ b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-abort.diff @@ -79,10 +79,14 @@ bb4: { StorageDead(_12); _14 = discriminant(_11); - switchInt(move _14) -> [0: bb7, 1: bb5, otherwise: bb6]; + switchInt(move _14) -> [0: bb7, 1: bb6, otherwise: bb5]; } bb5: { + unreachable; + } + + bb6: { - StorageLive(_16); _16 = ((_11 as Some).0: usize); StorageLive(_17); @@ -95,10 +99,6 @@ + assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _16) -> [success: bb8, unwind unreachable]; } - bb6: { - unreachable; - } - bb7: { _0 = const (); StorageDead(_13); diff --git a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff index 35f852098c354..8a2cbb68824c8 100644 --- a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff @@ -79,10 +79,14 @@ bb4: { StorageDead(_12); _14 = discriminant(_11); - switchInt(move _14) -> [0: bb7, 1: bb5, otherwise: bb6]; + switchInt(move _14) -> [0: bb7, 1: bb6, otherwise: bb5]; } bb5: { + unreachable; + } + + bb6: { - StorageLive(_16); _16 = ((_11 as Some).0: usize); StorageLive(_17); @@ -95,10 +99,6 @@ + assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _16) -> [success: bb8, unwind continue]; } - bb6: { - unreachable; - } - bb7: { _0 = const (); StorageDead(_13); diff --git a/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.32bit.diff index f50a763ef9a05..fc814f7e7a993 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.32bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.32bit.diff @@ -26,12 +26,16 @@ _1 = const _; StorageLive(_2); - _3 = discriminant(_1); -- switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; +- switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; + _3 = const 0_isize; -+ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2]; ++ switchInt(const 0_isize) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_5); _5 = ((_1 as V2).0: i32); _2 = _5; @@ -39,10 +43,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { StorageLive(_4); - _4 = ((_1 as V1).0: i32); diff --git a/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.64bit.diff index f50a763ef9a05..fc814f7e7a993 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.64bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.64bit.diff @@ -26,12 +26,16 @@ _1 = const _; StorageLive(_2); - _3 = discriminant(_1); -- switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; +- switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; + _3 = const 0_isize; -+ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2]; ++ switchInt(const 0_isize) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_5); _5 = ((_1 as V2).0: i32); _2 = _5; @@ -39,10 +43,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { StorageLive(_4); - _4 = ((_1 as V1).0: i32); diff --git a/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.32bit.diff index 6bf702b856815..10d33767c90d9 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.32bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.32bit.diff @@ -49,16 +49,16 @@ StorageDead(_4); StorageLive(_6); _7 = discriminant(_3); - switchInt(move _7) -> [0: bb4, 1: bb6, otherwise: bb5]; + switchInt(move _7) -> [0: bb5, 1: bb6, otherwise: bb4]; } bb4: { - _6 = const 0_u8; - goto -> bb7; + unreachable; } bb5: { - unreachable; + _6 = const 0_u8; + goto -> bb7; } bb6: { diff --git a/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.64bit.diff index 6bf702b856815..10d33767c90d9 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.64bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.64bit.diff @@ -49,16 +49,16 @@ StorageDead(_4); StorageLive(_6); _7 = discriminant(_3); - switchInt(move _7) -> [0: bb4, 1: bb6, otherwise: bb5]; + switchInt(move _7) -> [0: bb5, 1: bb6, otherwise: bb4]; } bb4: { - _6 = const 0_u8; - goto -> bb7; + unreachable; } bb5: { - unreachable; + _6 = const 0_u8; + goto -> bb7; } bb6: { diff --git a/tests/mir-opt/dataflow-const-prop/enum.rs b/tests/mir-opt/dataflow-const-prop/enum.rs index 7ad64d05be434..78410e49d2a49 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.rs +++ b/tests/mir-opt/dataflow-const-prop/enum.rs @@ -20,7 +20,7 @@ fn simple() { // CHECK: [[e]] = const E::V1(0_i32); let e = E::V1(0); - // CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb1, otherwise: bb2]; + // CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb2, otherwise: bb1]; // CHECK: [[target_bb]]: { // CHECK: [[x]] = const 0_i32; let x = match e { E::V1(x1) => x1, E::V2(x2) => x2 }; @@ -36,7 +36,7 @@ fn constant() { // CHECK: [[e]] = const _; let e = C; - // CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb1, otherwise: bb2]; + // CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb2, otherwise: bb1]; // CHECK: [[target_bb]]: { // CHECK: [[x]] = const 0_i32; let x = match e { E::V1(x1) => x1, E::V2(x2) => x2 }; @@ -55,7 +55,7 @@ fn statics() { // CHECK: [[e1]] = const E::V1(0_i32); let e1 = C; - // CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb1, otherwise: bb2]; + // CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb2, otherwise: bb1]; // CHECK: [[target_bb]]: { // CHECK: [[x1]] = const 0_i32; let x1 = match e1 { E::V1(x11) => x11, E::V2(x12) => x12 }; diff --git a/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.32bit.diff index b31f98460e45b..89ed26f065b28 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.32bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.32bit.diff @@ -27,12 +27,16 @@ + _1 = const E::V1(0_i32); StorageLive(_2); - _3 = discriminant(_1); -- switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; +- switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; + _3 = const 0_isize; -+ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2]; ++ switchInt(const 0_isize) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_5); _5 = ((_1 as V2).0: i32); _2 = _5; @@ -40,10 +44,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { StorageLive(_4); - _4 = ((_1 as V1).0: i32); diff --git a/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.64bit.diff index b31f98460e45b..89ed26f065b28 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.64bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.64bit.diff @@ -27,12 +27,16 @@ + _1 = const E::V1(0_i32); StorageLive(_2); - _3 = discriminant(_1); -- switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; +- switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; + _3 = const 0_isize; -+ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2]; ++ switchInt(const 0_isize) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_5); _5 = ((_1 as V2).0: i32); _2 = _5; @@ -40,10 +44,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { StorageLive(_4); - _4 = ((_1 as V1).0: i32); diff --git a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff index 44e8d39cca333..fe8ed0114897d 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff @@ -49,12 +49,16 @@ StorageDead(_2); StorageLive(_3); - _4 = discriminant(_1); -- switchInt(move _4) -> [0: bb3, 1: bb1, otherwise: bb2]; +- switchInt(move _4) -> [0: bb3, 1: bb2, otherwise: bb1]; + _4 = const 0_isize; -+ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2]; ++ switchInt(const 0_isize) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_6); _6 = ((_1 as V2).0: i32); _3 = _6; @@ -62,10 +66,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { StorageLive(_5); - _5 = ((_1 as V1).0: i32); @@ -84,7 +84,7 @@ StorageDead(_8); StorageLive(_9); _10 = discriminant((*_7)); - switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb2]; + switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb1]; } bb5: { diff --git a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff index ac4ca086d0fed..df3a989d09eba 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff @@ -49,12 +49,16 @@ StorageDead(_2); StorageLive(_3); - _4 = discriminant(_1); -- switchInt(move _4) -> [0: bb3, 1: bb1, otherwise: bb2]; +- switchInt(move _4) -> [0: bb3, 1: bb2, otherwise: bb1]; + _4 = const 0_isize; -+ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2]; ++ switchInt(const 0_isize) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_6); _6 = ((_1 as V2).0: i32); _3 = _6; @@ -62,10 +66,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { StorageLive(_5); - _5 = ((_1 as V1).0: i32); @@ -84,7 +84,7 @@ StorageDead(_8); StorageLive(_9); _10 = discriminant((*_7)); - switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb2]; + switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb1]; } bb5: { diff --git a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff index 5c4fc06a2baec..938b9bb14ade2 100644 --- a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff +++ b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff @@ -25,58 +25,66 @@ _7 = Len((*_2)); _8 = const 4_usize; _9 = Ge(move _7, move _8); - switchInt(move _9) -> [0: bb6, otherwise: bb2]; +- switchInt(move _9) -> [0: bb2, otherwise: bb7]; ++ switchInt(move _9) -> [0: bb2, otherwise: bb6]; } bb2: { - switchInt((*_2)[0 of 4]) -> [47: bb3, otherwise: bb6]; + _4 = Len((*_2)); + _5 = const 3_usize; + _6 = Ge(move _4, move _5); +- switchInt(move _6) -> [0: bb3, otherwise: bb4]; ++ switchInt(move _6) -> [0: bb10, otherwise: bb3]; } bb3: { - switchInt((*_2)[1 of 4]) -> [47: bb4, otherwise: bb6]; +- _0 = const false; +- goto -> bb14; ++ switchInt((*_2)[0 of 3]) -> [47: bb4, otherwise: bb10]; } bb4: { - switchInt((*_2)[2 of 4]) -> [47: bb5, otherwise: bb6]; +- switchInt((*_2)[0 of 3]) -> [47: bb5, otherwise: bb3]; ++ switchInt((*_2)[1 of 3]) -> [47: bb5, otherwise: bb10]; } bb5: { -- switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb6]; -+ switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb6]; +- switchInt((*_2)[1 of 3]) -> [47: bb6, otherwise: bb3]; ++ switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10]; } bb6: { - _4 = Len((*_2)); - _5 = const 3_usize; - _6 = Ge(move _4, move _5); - switchInt(move _6) -> [0: bb10, otherwise: bb7]; +- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb3]; ++ switchInt((*_2)[0 of 4]) -> [47: bb7, otherwise: bb2]; } bb7: { - switchInt((*_2)[0 of 3]) -> [47: bb8, otherwise: bb10]; +- switchInt((*_2)[0 of 4]) -> [47: bb8, otherwise: bb2]; ++ switchInt((*_2)[1 of 4]) -> [47: bb8, otherwise: bb2]; } bb8: { - switchInt((*_2)[1 of 3]) -> [47: bb9, otherwise: bb10]; +- switchInt((*_2)[1 of 4]) -> [47: bb9, otherwise: bb2]; ++ switchInt((*_2)[2 of 4]) -> [47: bb9, otherwise: bb2]; } bb9: { -- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb10]; -+ switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10]; +- switchInt((*_2)[2 of 4]) -> [47: bb10, otherwise: bb2]; ++ switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb2]; } bb10: { +- switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2]; +- } +- +- bb11: { _0 = const false; - goto -> bb14; + goto -> bb12; } - bb11: { -- _0 = const false; -- goto -> bb14; -- } -- - bb12: { ++ bb11: { _0 = const true; - goto -> bb14; + goto -> bb12; diff --git a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff index 3d9aa829052dd..ce89694076b04 100644 --- a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff +++ b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff @@ -25,58 +25,66 @@ _7 = Len((*_2)); _8 = const 4_usize; _9 = Ge(move _7, move _8); - switchInt(move _9) -> [0: bb6, otherwise: bb2]; +- switchInt(move _9) -> [0: bb2, otherwise: bb7]; ++ switchInt(move _9) -> [0: bb2, otherwise: bb6]; } bb2: { - switchInt((*_2)[0 of 4]) -> [47: bb3, otherwise: bb6]; + _4 = Len((*_2)); + _5 = const 3_usize; + _6 = Ge(move _4, move _5); +- switchInt(move _6) -> [0: bb3, otherwise: bb4]; ++ switchInt(move _6) -> [0: bb10, otherwise: bb3]; } bb3: { - switchInt((*_2)[1 of 4]) -> [47: bb4, otherwise: bb6]; +- _0 = const false; +- goto -> bb14; ++ switchInt((*_2)[0 of 3]) -> [47: bb4, otherwise: bb10]; } bb4: { - switchInt((*_2)[2 of 4]) -> [47: bb5, otherwise: bb6]; +- switchInt((*_2)[0 of 3]) -> [47: bb5, otherwise: bb3]; ++ switchInt((*_2)[1 of 3]) -> [47: bb5, otherwise: bb10]; } bb5: { -- switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb6]; -+ switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb6]; +- switchInt((*_2)[1 of 3]) -> [47: bb6, otherwise: bb3]; ++ switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10]; } bb6: { - _4 = Len((*_2)); - _5 = const 3_usize; - _6 = Ge(move _4, move _5); - switchInt(move _6) -> [0: bb10, otherwise: bb7]; +- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb3]; ++ switchInt((*_2)[0 of 4]) -> [47: bb7, otherwise: bb2]; } bb7: { - switchInt((*_2)[0 of 3]) -> [47: bb8, otherwise: bb10]; +- switchInt((*_2)[0 of 4]) -> [47: bb8, otherwise: bb2]; ++ switchInt((*_2)[1 of 4]) -> [47: bb8, otherwise: bb2]; } bb8: { - switchInt((*_2)[1 of 3]) -> [47: bb9, otherwise: bb10]; +- switchInt((*_2)[1 of 4]) -> [47: bb9, otherwise: bb2]; ++ switchInt((*_2)[2 of 4]) -> [47: bb9, otherwise: bb2]; } bb9: { -- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb10]; -+ switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10]; +- switchInt((*_2)[2 of 4]) -> [47: bb10, otherwise: bb2]; ++ switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb2]; } bb10: { +- switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2]; +- } +- +- bb11: { _0 = const false; - goto -> bb14; + goto -> bb12; } - bb11: { -- _0 = const false; -- goto -> bb14; -- } -- - bb12: { ++ bb11: { _0 = const true; - goto -> bb14; + goto -> bb12; diff --git a/tests/mir-opt/derefer_complex_case.main.Derefer.panic-abort.diff b/tests/mir-opt/derefer_complex_case.main.Derefer.panic-abort.diff index 0fad716a2cb63..6654e710625a0 100644 --- a/tests/mir-opt/derefer_complex_case.main.Derefer.panic-abort.diff +++ b/tests/mir-opt/derefer_complex_case.main.Derefer.panic-abort.diff @@ -55,10 +55,14 @@ StorageDead(_8); PlaceMention(_7); _10 = discriminant(_7); - switchInt(move _10) -> [0: bb6, 1: bb4, otherwise: bb5]; + switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb4]; } bb4: { + unreachable; + } + + bb5: { StorageLive(_12); - _12 = (*((_7 as Some).0: &i32)); + _15 = deref_copy ((_7 as Some).0: &i32); @@ -68,10 +72,6 @@ _6 = std::mem::drop::(move _13) -> [return: bb7, unwind: bb8]; } - bb5: { - unreachable; - } - bb6: { _0 = const (); StorageDead(_9); diff --git a/tests/mir-opt/derefer_complex_case.main.Derefer.panic-unwind.diff b/tests/mir-opt/derefer_complex_case.main.Derefer.panic-unwind.diff index ae5656f02a5a8..18fc27e7cf7d4 100644 --- a/tests/mir-opt/derefer_complex_case.main.Derefer.panic-unwind.diff +++ b/tests/mir-opt/derefer_complex_case.main.Derefer.panic-unwind.diff @@ -55,10 +55,14 @@ StorageDead(_8); PlaceMention(_7); _10 = discriminant(_7); - switchInt(move _10) -> [0: bb6, 1: bb4, otherwise: bb5]; + switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb4]; } bb4: { + unreachable; + } + + bb5: { StorageLive(_12); - _12 = (*((_7 as Some).0: &i32)); + _15 = deref_copy ((_7 as Some).0: &i32); @@ -68,10 +72,6 @@ _6 = std::mem::drop::(move _13) -> [return: bb7, unwind continue]; } - bb5: { - unreachable; - } - bb6: { _0 = const (); StorageDead(_9); diff --git a/tests/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff index b91a469225cd2..32a8dd8b8b4fb 100644 --- a/tests/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff @@ -30,7 +30,7 @@ StorageDead(_5); StorageDead(_4); _8 = discriminant((_3.0: std::option::Option)); -- switchInt(move _8) -> [0: bb1, 1: bb3, otherwise: bb2]; +- switchInt(move _8) -> [0: bb2, 1: bb3, otherwise: bb1]; + StorageLive(_11); + _11 = discriminant((_3.1: std::option::Option)); + StorageLive(_12); @@ -40,24 +40,23 @@ } bb1: { -- _6 = discriminant((_3.1: std::option::Option)); -- switchInt(move _6) -> [0: bb5, otherwise: bb2]; -- } -- -- bb2: { + StorageDead(_12); _0 = const 1_u32; - goto -> bb6; + goto -> bb4; } + bb2: { +- _6 = discriminant((_3.1: std::option::Option)); +- switchInt(move _6) -> [0: bb5, otherwise: bb1]; +- } +- - bb3: { - _7 = discriminant((_3.1: std::option::Option)); -- switchInt(move _7) -> [1: bb4, otherwise: bb2]; +- switchInt(move _7) -> [1: bb4, otherwise: bb1]; - } - - bb4: { -+ bb2: { StorageLive(_10); _10 = (((_3.1: std::option::Option) as Some).0: u32); StorageLive(_9); diff --git a/tests/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff index 79cf1c0e34ad5..6179bab11fecc 100644 --- a/tests/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff @@ -78,16 +78,10 @@ StorageDead(_5); _34 = deref_copy (_4.0: &ViewportPercentageLength); _11 = discriminant((*_34)); - switchInt(move _11) -> [0: bb1, 1: bb3, 2: bb4, 3: bb5, otherwise: bb2]; + switchInt(move _11) -> [0: bb2, 1: bb3, 2: bb4, 3: bb5, otherwise: bb1]; } bb1: { - _35 = deref_copy (_4.1: &ViewportPercentageLength); - _7 = discriminant((*_35)); - switchInt(move _7) -> [0: bb6, otherwise: bb2]; - } - - bb2: { StorageLive(_33); _33 = (); _0 = Result::::Err(move _33); @@ -97,22 +91,28 @@ goto -> bb11; } + bb2: { + _35 = deref_copy (_4.1: &ViewportPercentageLength); + _7 = discriminant((*_35)); + switchInt(move _7) -> [0: bb6, otherwise: bb1]; + } + bb3: { _36 = deref_copy (_4.1: &ViewportPercentageLength); _8 = discriminant((*_36)); - switchInt(move _8) -> [1: bb7, otherwise: bb2]; + switchInt(move _8) -> [1: bb7, otherwise: bb1]; } bb4: { _37 = deref_copy (_4.1: &ViewportPercentageLength); _9 = discriminant((*_37)); - switchInt(move _9) -> [2: bb8, otherwise: bb2]; + switchInt(move _9) -> [2: bb8, otherwise: bb1]; } bb5: { _38 = deref_copy (_4.1: &ViewportPercentageLength); _10 = discriminant((*_38)); - switchInt(move _10) -> [3: bb9, otherwise: bb2]; + switchInt(move _10) -> [3: bb9, otherwise: bb1]; } bb6: { diff --git a/tests/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff index af0337d0a7e71..d7908ab3cd2ad 100644 --- a/tests/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff @@ -36,26 +36,26 @@ StorageDead(_5); StorageDead(_4); _8 = discriminant((_3.0: std::option::Option)); - switchInt(move _8) -> [0: bb1, 1: bb4, otherwise: bb3]; + switchInt(move _8) -> [0: bb2, 1: bb4, otherwise: bb1]; } bb1: { - _6 = discriminant((_3.1: std::option::Option)); - switchInt(move _6) -> [0: bb2, 1: bb7, otherwise: bb3]; + unreachable; } bb2: { - _0 = const 3_u32; - goto -> bb8; + _6 = discriminant((_3.1: std::option::Option)); + switchInt(move _6) -> [0: bb3, 1: bb7, otherwise: bb1]; } bb3: { - unreachable; + _0 = const 3_u32; + goto -> bb8; } bb4: { _7 = discriminant((_3.1: std::option::Option)); - switchInt(move _7) -> [0: bb6, 1: bb5, otherwise: bb3]; + switchInt(move _7) -> [0: bb6, 1: bb5, otherwise: bb1]; } bb5: { diff --git a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff index 62710ba8fbf5f..a5c29c191ad5c 100644 --- a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff @@ -21,18 +21,18 @@ + _2 = Option::::Some(_1); StorageDead(_3); - _4 = discriminant(_2); -- switchInt(move _4) -> [0: bb1, 1: bb3, otherwise: bb2]; +- switchInt(move _4) -> [0: bb2, 1: bb3, otherwise: bb1]; + _4 = const 1_isize; -+ switchInt(const 1_isize) -> [0: bb1, 1: bb3, otherwise: bb2]; ++ switchInt(const 1_isize) -> [0: bb2, 1: bb3, otherwise: bb1]; } bb1: { - StorageLive(_6); - _6 = begin_panic::<&str>(const "explicit panic") -> unwind unreachable; + unreachable; } bb2: { - unreachable; + StorageLive(_6); + _6 = begin_panic::<&str>(const "explicit panic") -> unwind unreachable; } bb3: { diff --git a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff index ad46a065b1e3d..6f2e52482716d 100644 --- a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff @@ -21,18 +21,18 @@ + _2 = Option::::Some(_1); StorageDead(_3); - _4 = discriminant(_2); -- switchInt(move _4) -> [0: bb1, 1: bb3, otherwise: bb2]; +- switchInt(move _4) -> [0: bb2, 1: bb3, otherwise: bb1]; + _4 = const 1_isize; -+ switchInt(const 1_isize) -> [0: bb1, 1: bb3, otherwise: bb2]; ++ switchInt(const 1_isize) -> [0: bb2, 1: bb3, otherwise: bb1]; } bb1: { - StorageLive(_6); - _6 = begin_panic::<&str>(const "explicit panic") -> unwind continue; + unreachable; } bb2: { - unreachable; + StorageLive(_6); + _6 = begin_panic::<&str>(const "explicit panic") -> unwind continue; } bb3: { diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff index 9358a64b4fabe..52688c2e86729 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff @@ -28,18 +28,18 @@ + StorageLive(_3); + StorageLive(_5); + _3 = discriminant(_2); -+ switchInt(move _3) -> [0: bb1, 1: bb3, otherwise: bb2]; ++ switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; } bb1: { -+ StorageLive(_4); -+ _4 = cfg!(debug_assertions); -+ assume(_4); -+ _5 = unreachable_unchecked::precondition_check() -> [return: bb2, unwind unreachable]; ++ unreachable; + } + + bb2: { -+ unreachable; ++ StorageLive(_4); ++ _4 = cfg!(debug_assertions); ++ assume(_4); ++ _5 = unreachable_unchecked::precondition_check() -> [return: bb1, unwind unreachable]; + } + + bb3: { diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff index ac33c126155ca..fd83f1cb33152 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff @@ -28,22 +28,22 @@ + StorageLive(_3); + StorageLive(_5); + _3 = discriminant(_2); -+ switchInt(move _3) -> [0: bb1, 1: bb3, otherwise: bb2]; ++ switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; } bb1: { - StorageDead(_2); - return; -+ StorageLive(_4); -+ _4 = cfg!(debug_assertions); -+ assume(_4); -+ _5 = unreachable_unchecked::precondition_check() -> [return: bb2, unwind unreachable]; ++ unreachable; } - bb2 (cleanup): { - resume; + bb2: { -+ unreachable; ++ StorageLive(_4); ++ _4 = cfg!(debug_assertions); ++ assume(_4); ++ _5 = unreachable_unchecked::precondition_check() -> [return: bb1, unwind unreachable]; + } + + bb3: { diff --git a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir index fadfdfc87be89..91dee82fde06a 100644 --- a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir +++ b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir @@ -47,10 +47,14 @@ fn test() -> Option> { StorageDead(_7); PlaceMention(_6); _8 = discriminant(_6); - switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb4]; + switchInt(move _8) -> [0: bb4, 1: bb5, otherwise: bb3]; } bb3: { + unreachable; + } + + bb4: { StorageLive(_12); _12 = ((_6 as Continue).0: u32); (*_5) = _12; @@ -59,10 +63,6 @@ fn test() -> Option> { drop(_5) -> [return: bb7, unwind: bb11]; } - bb4: { - unreachable; - } - bb5: { StorageLive(_9); _9 = ((_6 as Break).0: std::option::Option); diff --git a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir index 8f94165a108ef..ff7fc74ff61f1 100644 --- a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir +++ b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir @@ -47,10 +47,14 @@ fn test() -> Option> { StorageDead(_7); PlaceMention(_6); _8 = discriminant(_6); - switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb4]; + switchInt(move _8) -> [0: bb4, 1: bb5, otherwise: bb3]; } bb3: { + unreachable; + } + + bb4: { StorageLive(_12); _12 = ((_6 as Continue).0: u32); (*_5) = _12; @@ -59,10 +63,6 @@ fn test() -> Option> { drop(_5) -> [return: bb7, unwind: bb11]; } - bb4: { - unreachable; - } - bb5: { StorageLive(_9); _9 = ((_6 as Break).0: std::option::Option); diff --git a/tests/mir-opt/issue_72181.bar.built.after.mir b/tests/mir-opt/issue_72181.bar.built.after.mir index c2e4e2072de5a..b6cc7d2219569 100644 --- a/tests/mir-opt/issue_72181.bar.built.after.mir +++ b/tests/mir-opt/issue_72181.bar.built.after.mir @@ -14,4 +14,9 @@ fn bar(_1: [(Never, u32); 1]) -> u32 { StorageDead(_2); return; } + + bb1: { + FakeRead(ForMatchedPlace(None), _1); + unreachable; + } } diff --git a/tests/mir-opt/issue_72181.main.built.after.mir b/tests/mir-opt/issue_72181.main.built.after.mir index 4e4071536b1cd..12c4a2b63253d 100644 --- a/tests/mir-opt/issue_72181.main.built.after.mir +++ b/tests/mir-opt/issue_72181.main.built.after.mir @@ -22,7 +22,7 @@ fn main() -> () { bb0: { StorageLive(_1); - _1 = std::mem::size_of::() -> [return: bb1, unwind: bb3]; + _1 = std::mem::size_of::() -> [return: bb1, unwind: bb5]; } bb1: { @@ -42,10 +42,15 @@ fn main() -> () { _6 = const 0_usize; _7 = Len(_2); _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb2, unwind: bb3]; + assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb3, unwind: bb5]; } bb2: { + FakeRead(ForMatchedPlace(None), _1); + unreachable; + } + + bb3: { _5 = (_2[_6].0: u64); PlaceMention(_5); StorageDead(_6); @@ -55,7 +60,12 @@ fn main() -> () { return; } - bb3 (cleanup): { + bb4: { + FakeRead(ForMatchedPlace(None), _5); + unreachable; + } + + bb5 (cleanup): { resume; } } diff --git a/tests/mir-opt/issue_72181_1.f.built.after.mir b/tests/mir-opt/issue_72181_1.f.built.after.mir index 89da9a8011361..674a4013fe773 100644 --- a/tests/mir-opt/issue_72181_1.f.built.after.mir +++ b/tests/mir-opt/issue_72181_1.f.built.after.mir @@ -6,11 +6,15 @@ fn f(_1: Void) -> ! { bb0: { PlaceMention(_1); + goto -> bb1; + } + + bb1: { FakeRead(ForMatchedPlace(None), _1); unreachable; } - bb1: { + bb2: { return; } } diff --git a/tests/mir-opt/issue_91633.bar.built.after.mir b/tests/mir-opt/issue_91633.bar.built.after.mir index cce1a1fd2ef4a..53829588a1b36 100644 --- a/tests/mir-opt/issue_91633.bar.built.after.mir +++ b/tests/mir-opt/issue_91633.bar.built.after.mir @@ -12,7 +12,7 @@ fn bar(_1: Box<[T]>) -> () { StorageLive(_2); StorageLive(_3); _3 = &(*_1); - _2 = <[T] as Index>::index(move _3, const 0_usize) -> [return: bb1, unwind: bb3]; + _2 = <[T] as Index>::index(move _3, const 0_usize) -> [return: bb1, unwind: bb4]; } bb1: { @@ -20,18 +20,23 @@ fn bar(_1: Box<[T]>) -> () { PlaceMention((*_2)); StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb2, unwind: bb4]; + drop(_1) -> [return: bb3, unwind: bb5]; } bb2: { - return; + FakeRead(ForMatchedPlace(None), (*_2)); + unreachable; } - bb3 (cleanup): { - drop(_1) -> [return: bb4, unwind terminate(cleanup)]; + bb3: { + return; } bb4 (cleanup): { + drop(_1) -> [return: bb5, unwind terminate(cleanup)]; + } + + bb5 (cleanup): { resume; } } diff --git a/tests/mir-opt/issue_91633.hey.built.after.mir b/tests/mir-opt/issue_91633.hey.built.after.mir index aa8f31f8156d0..a537e509996d7 100644 --- a/tests/mir-opt/issue_91633.hey.built.after.mir +++ b/tests/mir-opt/issue_91633.hey.built.after.mir @@ -14,7 +14,7 @@ fn hey(_1: &[T]) -> () { StorageLive(_3); StorageLive(_4); _4 = &(*_1); - _3 = <[T] as Index>::index(move _4, const 0_usize) -> [return: bb1, unwind: bb2]; + _3 = <[T] as Index>::index(move _4, const 0_usize) -> [return: bb1, unwind: bb3]; } bb1: { @@ -27,7 +27,12 @@ fn hey(_1: &[T]) -> () { return; } - bb2 (cleanup): { + bb2: { + FakeRead(ForMatchedPlace(None), _2); + unreachable; + } + + bb3 (cleanup): { resume; } } diff --git a/tests/mir-opt/issue_99325.main.built.after.32bit.mir b/tests/mir-opt/issue_99325.main.built.after.32bit.mir index a10061ed9412c..53254f76dbcb9 100644 --- a/tests/mir-opt/issue_99325.main.built.after.32bit.mir +++ b/tests/mir-opt/issue_99325.main.built.after.32bit.mir @@ -67,7 +67,7 @@ fn main() -> () { StorageLive(_2); StorageLive(_3); StorageLive(_4); - _4 = function_with_bytes::<&*b"AAAA">() -> [return: bb1, unwind: bb21]; + _4 = function_with_bytes::<&*b"AAAA">() -> [return: bb1, unwind: bb23]; } bb1: { @@ -91,24 +91,29 @@ fn main() -> () { _11 = &(*_8); StorageLive(_12); _12 = &(*_9); - _10 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _11, move _12) -> [return: bb2, unwind: bb21]; + _10 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _11, move _12) -> [return: bb3, unwind: bb23]; } bb2: { - switchInt(move _10) -> [0: bb4, otherwise: bb3]; + FakeRead(ForMatchedPlace(None), _2); + unreachable; } bb3: { - StorageDead(_12); - StorageDead(_11); - goto -> bb8; + switchInt(move _10) -> [0: bb5, otherwise: bb4]; } bb4: { - goto -> bb5; + StorageDead(_12); + StorageDead(_11); + goto -> bb9; } bb5: { + goto -> bb6; + } + + bb6: { StorageDead(_12); StorageDead(_11); StorageLive(_14); @@ -127,10 +132,10 @@ fn main() -> () { _19 = &(*_20); StorageLive(_21); _21 = Option::>::None; - _15 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _16, move _17, move _19, move _21) -> bb21; + _15 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _16, move _17, move _19, move _21) -> bb23; } - bb6: { + bb7: { StorageDead(_21); StorageDead(_19); StorageDead(_17); @@ -142,23 +147,23 @@ fn main() -> () { unreachable; } - bb7: { - goto -> bb9; + bb8: { + goto -> bb10; } - bb8: { + bb9: { _1 = const (); - goto -> bb9; + goto -> bb10; } - bb9: { + bb10: { StorageDead(_10); StorageDead(_9); StorageDead(_8); - goto -> bb10; + goto -> bb11; } - bb10: { + bb11: { StorageDead(_7); StorageDead(_6); StorageDead(_4); @@ -168,10 +173,10 @@ fn main() -> () { StorageLive(_23); StorageLive(_24); StorageLive(_25); - _25 = function_with_bytes::<&*b"AAAA">() -> [return: bb11, unwind: bb21]; + _25 = function_with_bytes::<&*b"AAAA">() -> [return: bb12, unwind: bb23]; } - bb11: { + bb12: { _24 = &_25; StorageLive(_26); StorageLive(_27); @@ -190,24 +195,29 @@ fn main() -> () { _31 = &(*_28); StorageLive(_32); _32 = &(*_29); - _30 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _31, move _32) -> [return: bb12, unwind: bb21]; + _30 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _31, move _32) -> [return: bb14, unwind: bb23]; } - bb12: { - switchInt(move _30) -> [0: bb14, otherwise: bb13]; + bb13: { + FakeRead(ForMatchedPlace(None), _23); + unreachable; } - bb13: { + bb14: { + switchInt(move _30) -> [0: bb16, otherwise: bb15]; + } + + bb15: { StorageDead(_32); StorageDead(_31); - goto -> bb18; + goto -> bb20; } - bb14: { - goto -> bb15; + bb16: { + goto -> bb17; } - bb15: { + bb17: { StorageDead(_32); StorageDead(_31); StorageLive(_34); @@ -226,10 +236,10 @@ fn main() -> () { _39 = &(*_40); StorageLive(_41); _41 = Option::>::None; - _35 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _36, move _37, move _39, move _41) -> bb21; + _35 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _36, move _37, move _39, move _41) -> bb23; } - bb16: { + bb18: { StorageDead(_41); StorageDead(_39); StorageDead(_37); @@ -241,23 +251,23 @@ fn main() -> () { unreachable; } - bb17: { - goto -> bb19; + bb19: { + goto -> bb21; } - bb18: { + bb20: { _22 = const (); - goto -> bb19; + goto -> bb21; } - bb19: { + bb21: { StorageDead(_30); StorageDead(_29); StorageDead(_28); - goto -> bb20; + goto -> bb22; } - bb20: { + bb22: { StorageDead(_27); StorageDead(_25); StorageDead(_23); @@ -266,7 +276,7 @@ fn main() -> () { return; } - bb21 (cleanup): { + bb23 (cleanup): { resume; } } diff --git a/tests/mir-opt/issue_99325.main.built.after.64bit.mir b/tests/mir-opt/issue_99325.main.built.after.64bit.mir index a10061ed9412c..53254f76dbcb9 100644 --- a/tests/mir-opt/issue_99325.main.built.after.64bit.mir +++ b/tests/mir-opt/issue_99325.main.built.after.64bit.mir @@ -67,7 +67,7 @@ fn main() -> () { StorageLive(_2); StorageLive(_3); StorageLive(_4); - _4 = function_with_bytes::<&*b"AAAA">() -> [return: bb1, unwind: bb21]; + _4 = function_with_bytes::<&*b"AAAA">() -> [return: bb1, unwind: bb23]; } bb1: { @@ -91,24 +91,29 @@ fn main() -> () { _11 = &(*_8); StorageLive(_12); _12 = &(*_9); - _10 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _11, move _12) -> [return: bb2, unwind: bb21]; + _10 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _11, move _12) -> [return: bb3, unwind: bb23]; } bb2: { - switchInt(move _10) -> [0: bb4, otherwise: bb3]; + FakeRead(ForMatchedPlace(None), _2); + unreachable; } bb3: { - StorageDead(_12); - StorageDead(_11); - goto -> bb8; + switchInt(move _10) -> [0: bb5, otherwise: bb4]; } bb4: { - goto -> bb5; + StorageDead(_12); + StorageDead(_11); + goto -> bb9; } bb5: { + goto -> bb6; + } + + bb6: { StorageDead(_12); StorageDead(_11); StorageLive(_14); @@ -127,10 +132,10 @@ fn main() -> () { _19 = &(*_20); StorageLive(_21); _21 = Option::>::None; - _15 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _16, move _17, move _19, move _21) -> bb21; + _15 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _16, move _17, move _19, move _21) -> bb23; } - bb6: { + bb7: { StorageDead(_21); StorageDead(_19); StorageDead(_17); @@ -142,23 +147,23 @@ fn main() -> () { unreachable; } - bb7: { - goto -> bb9; + bb8: { + goto -> bb10; } - bb8: { + bb9: { _1 = const (); - goto -> bb9; + goto -> bb10; } - bb9: { + bb10: { StorageDead(_10); StorageDead(_9); StorageDead(_8); - goto -> bb10; + goto -> bb11; } - bb10: { + bb11: { StorageDead(_7); StorageDead(_6); StorageDead(_4); @@ -168,10 +173,10 @@ fn main() -> () { StorageLive(_23); StorageLive(_24); StorageLive(_25); - _25 = function_with_bytes::<&*b"AAAA">() -> [return: bb11, unwind: bb21]; + _25 = function_with_bytes::<&*b"AAAA">() -> [return: bb12, unwind: bb23]; } - bb11: { + bb12: { _24 = &_25; StorageLive(_26); StorageLive(_27); @@ -190,24 +195,29 @@ fn main() -> () { _31 = &(*_28); StorageLive(_32); _32 = &(*_29); - _30 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _31, move _32) -> [return: bb12, unwind: bb21]; + _30 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _31, move _32) -> [return: bb14, unwind: bb23]; } - bb12: { - switchInt(move _30) -> [0: bb14, otherwise: bb13]; + bb13: { + FakeRead(ForMatchedPlace(None), _23); + unreachable; } - bb13: { + bb14: { + switchInt(move _30) -> [0: bb16, otherwise: bb15]; + } + + bb15: { StorageDead(_32); StorageDead(_31); - goto -> bb18; + goto -> bb20; } - bb14: { - goto -> bb15; + bb16: { + goto -> bb17; } - bb15: { + bb17: { StorageDead(_32); StorageDead(_31); StorageLive(_34); @@ -226,10 +236,10 @@ fn main() -> () { _39 = &(*_40); StorageLive(_41); _41 = Option::>::None; - _35 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _36, move _37, move _39, move _41) -> bb21; + _35 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _36, move _37, move _39, move _41) -> bb23; } - bb16: { + bb18: { StorageDead(_41); StorageDead(_39); StorageDead(_37); @@ -241,23 +251,23 @@ fn main() -> () { unreachable; } - bb17: { - goto -> bb19; + bb19: { + goto -> bb21; } - bb18: { + bb20: { _22 = const (); - goto -> bb19; + goto -> bb21; } - bb19: { + bb21: { StorageDead(_30); StorageDead(_29); StorageDead(_28); - goto -> bb20; + goto -> bb22; } - bb20: { + bb22: { StorageDead(_27); StorageDead(_25); StorageDead(_23); @@ -266,7 +276,7 @@ fn main() -> () { return; } - bb21 (cleanup): { + bb23 (cleanup): { resume; } } diff --git a/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-abort.diff index ad5846c97decc..bbbfe90691f97 100644 --- a/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-abort.diff +++ b/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-abort.diff @@ -24,20 +24,20 @@ bb1: { _4 = discriminant(_1); - switchInt(move _4) -> [0: bb4, 1: bb5, 2: bb6, 3: bb2, otherwise: bb3]; + switchInt(move _4) -> [0: bb4, 1: bb5, 2: bb6, 3: bb3, otherwise: bb2]; } bb2: { + unreachable; + } + + bb3: { _0 = const (); StorageDead(_2); StorageDead(_1); return; } - bb3: { - unreachable; - } - bb4: { StorageLive(_5); _5 = DFA::B; diff --git a/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-unwind.diff index ad5846c97decc..bbbfe90691f97 100644 --- a/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-unwind.diff +++ b/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-unwind.diff @@ -24,20 +24,20 @@ bb1: { _4 = discriminant(_1); - switchInt(move _4) -> [0: bb4, 1: bb5, 2: bb6, 3: bb2, otherwise: bb3]; + switchInt(move _4) -> [0: bb4, 1: bb5, 2: bb6, 3: bb3, otherwise: bb2]; } bb2: { + unreachable; + } + + bb3: { _0 = const (); StorageDead(_2); StorageDead(_1); return; } - bb3: { - unreachable; - } - bb4: { StorageLive(_5); _5 = DFA::B; diff --git a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff index 9cc4385f60b87..d67477ab1b9b3 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff @@ -56,10 +56,14 @@ StorageLive(_11); StorageLive(_12); _10 = discriminant(_4); - switchInt(move _10) -> [0: bb7, 1: bb6, otherwise: bb2]; + switchInt(move _10) -> [0: bb7, 1: bb6, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_9); _9 = ((_3 as Continue).0: i32); _2 = _9; @@ -70,10 +74,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { StorageLive(_6); _6 = ((_3 as Break).0: std::result::Result); @@ -103,8 +103,8 @@ StorageDead(_10); StorageDead(_4); _5 = discriminant(_3); -- switchInt(move _5) -> [0: bb1, 1: bb3, otherwise: bb2]; -+ goto -> bb1; +- switchInt(move _5) -> [0: bb2, 1: bb3, otherwise: bb1]; ++ goto -> bb2; } bb6: { diff --git a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff index 9cc4385f60b87..d67477ab1b9b3 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff @@ -56,10 +56,14 @@ StorageLive(_11); StorageLive(_12); _10 = discriminant(_4); - switchInt(move _10) -> [0: bb7, 1: bb6, otherwise: bb2]; + switchInt(move _10) -> [0: bb7, 1: bb6, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_9); _9 = ((_3 as Continue).0: i32); _2 = _9; @@ -70,10 +74,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { StorageLive(_6); _6 = ((_3 as Break).0: std::result::Result); @@ -103,8 +103,8 @@ StorageDead(_10); StorageDead(_4); _5 = discriminant(_3); -- switchInt(move _5) -> [0: bb1, 1: bb3, otherwise: bb2]; -+ goto -> bb1; +- switchInt(move _5) -> [0: bb2, 1: bb3, otherwise: bb1]; ++ goto -> bb2; } bb6: { diff --git a/tests/mir-opt/jump_threading.rs b/tests/mir-opt/jump_threading.rs index a66fe8b57e718..512aebd857a67 100644 --- a/tests/mir-opt/jump_threading.rs +++ b/tests/mir-opt/jump_threading.rs @@ -12,12 +12,12 @@ use std::ops::ControlFlow; fn too_complex(x: Result) -> Option { // CHECK-LABEL: fn too_complex( // CHECK: bb0: { - // CHECK: switchInt(move {{_.*}}) -> [0: bb3, 1: bb1, otherwise: bb2]; + // CHECK: switchInt(move {{_.*}}) -> [0: bb3, 1: bb2, otherwise: bb1]; // CHECK: bb1: { + // CHECK: unreachable; + // CHECK: bb2: { // CHECK: [[controlflow:_.*]] = ControlFlow::::Break( // CHECK: goto -> bb8; - // CHECK: bb2: { - // CHECK: unreachable; // CHECK: bb3: { // CHECK: [[controlflow]] = ControlFlow::::Continue( // CHECK: goto -> bb4; @@ -50,13 +50,13 @@ fn identity(x: Result) -> Result { // CHECK-LABEL: fn identity( // CHECK: bb0: { // CHECK: [[x:_.*]] = _1; - // CHECK: switchInt(move {{_.*}}) -> [0: bb7, 1: bb6, otherwise: bb2]; + // CHECK: switchInt(move {{_.*}}) -> [0: bb7, 1: bb6, otherwise: bb1]; // CHECK: bb1: { + // CHECK: unreachable; + // CHECK: bb2: { // CHECK: {{_.*}} = (([[controlflow:_.*]] as Continue).0: i32); // CHECK: _0 = Result::::Ok( // CHECK: goto -> bb4; - // CHECK: bb2: { - // CHECK: unreachable; // CHECK: bb3: { // CHECK: {{_.*}} = (([[controlflow]] as Break).0: std::result::Result); // CHECK: _0 = Result::::Err( @@ -64,7 +64,7 @@ fn identity(x: Result) -> Result { // CHECK: bb4: { // CHECK: return; // CHECK: bb5: { - // CHECK: goto -> bb1; + // CHECK: goto -> bb2; // CHECK: bb6: { // CHECK: {{_.*}} = move (([[x]] as Err).0: i32); // CHECK: [[controlflow]] = ControlFlow::, i32>::Break( @@ -93,11 +93,11 @@ fn dfa() { // CHECK: {{_.*}} = DFA::A; // CHECK: goto -> bb1; // CHECK: bb1: { - // CHECK: switchInt({{.*}}) -> [0: bb4, 1: bb5, 2: bb6, 3: bb2, otherwise: bb3]; + // CHECK: switchInt({{.*}}) -> [0: bb4, 1: bb5, 2: bb6, 3: bb3, otherwise: bb2]; // CHECK: bb2: { - // CHECK: return; - // CHECK: bb3: { // CHECK: unreachable; + // CHECK: bb3: { + // CHECK: return; // CHECK: bb4: { // CHECK: {{_.*}} = DFA::B; // CHECK: goto -> bb1; diff --git a/tests/mir-opt/jump_threading.too_complex.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.too_complex.JumpThreading.panic-abort.diff index f5eade4a9149e..365d9d6b32bde 100644 --- a/tests/mir-opt/jump_threading.too_complex.JumpThreading.panic-abort.diff +++ b/tests/mir-opt/jump_threading.too_complex.JumpThreading.panic-abort.diff @@ -30,10 +30,14 @@ bb0: { StorageLive(_2); _3 = discriminant(_1); - switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; + switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_6); _6 = ((_1 as Err).0: usize); StorageLive(_7); @@ -45,10 +49,6 @@ + goto -> bb8; } - bb2: { - unreachable; - } - bb3: { StorageLive(_4); _4 = ((_1 as Ok).0: i32); @@ -62,7 +62,7 @@ bb4: { _8 = discriminant(_2); -- switchInt(move _8) -> [0: bb6, 1: bb5, otherwise: bb2]; +- switchInt(move _8) -> [0: bb6, 1: bb5, otherwise: bb1]; + goto -> bb6; } diff --git a/tests/mir-opt/jump_threading.too_complex.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.too_complex.JumpThreading.panic-unwind.diff index f5eade4a9149e..365d9d6b32bde 100644 --- a/tests/mir-opt/jump_threading.too_complex.JumpThreading.panic-unwind.diff +++ b/tests/mir-opt/jump_threading.too_complex.JumpThreading.panic-unwind.diff @@ -30,10 +30,14 @@ bb0: { StorageLive(_2); _3 = discriminant(_1); - switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; + switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_6); _6 = ((_1 as Err).0: usize); StorageLive(_7); @@ -45,10 +49,6 @@ + goto -> bb8; } - bb2: { - unreachable; - } - bb3: { StorageLive(_4); _4 = ((_1 as Ok).0: i32); @@ -62,7 +62,7 @@ bb4: { _8 = discriminant(_2); -- switchInt(move _8) -> [0: bb6, 1: bb5, otherwise: bb2]; +- switchInt(move _8) -> [0: bb6, 1: bb5, otherwise: bb1]; + goto -> bb6; } diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff index b4bd45ba597f2..307f7105dd2f1 100644 --- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -32,33 +32,25 @@ bb0: { PlaceMention(_2); -- switchInt((_2.0: bool)) -> [0: bb1, otherwise: bb2]; +- switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb1]; + switchInt((_2.0: bool)) -> [0: bb5, otherwise: bb1]; } bb1: { -- falseEdge -> [real: bb8, imaginary: bb3]; +- switchInt((_2.1: bool)) -> [0: bb5, otherwise: bb2]; + switchInt((_2.1: bool)) -> [0: bb10, otherwise: bb2]; } bb2: { -- switchInt((_2.1: bool)) -> [0: bb3, otherwise: bb4]; +- switchInt((_2.0: bool)) -> [0: bb4, otherwise: bb3]; + switchInt((_2.0: bool)) -> [0: bb3, otherwise: bb17]; } bb3: { -- falseEdge -> [real: bb13, imaginary: bb5]; +- falseEdge -> [real: bb20, imaginary: bb4]; - } - - bb4: { -- switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb5]; -- } -- -- bb5: { -- falseEdge -> [real: bb20, imaginary: bb6]; -- } -- -- bb6: { StorageLive(_15); _15 = (_2.1: bool); StorageLive(_16); @@ -67,6 +59,14 @@ + goto -> bb16; } +- bb5: { +- falseEdge -> [real: bb13, imaginary: bb3]; +- } +- +- bb6: { +- falseEdge -> [real: bb8, imaginary: bb5]; +- } +- - bb7: { + bb4: { _0 = const 1_i32; @@ -127,7 +127,7 @@ StorageDead(_9); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb2, imaginary: bb3]; +- falseEdge -> [real: bb1, imaginary: bb5]; + goto -> bb1; } @@ -184,7 +184,7 @@ StorageDead(_12); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb4, imaginary: bb5]; +- falseEdge -> [real: bb2, imaginary: bb3]; + goto -> bb2; } diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff index b4bd45ba597f2..307f7105dd2f1 100644 --- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -32,33 +32,25 @@ bb0: { PlaceMention(_2); -- switchInt((_2.0: bool)) -> [0: bb1, otherwise: bb2]; +- switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb1]; + switchInt((_2.0: bool)) -> [0: bb5, otherwise: bb1]; } bb1: { -- falseEdge -> [real: bb8, imaginary: bb3]; +- switchInt((_2.1: bool)) -> [0: bb5, otherwise: bb2]; + switchInt((_2.1: bool)) -> [0: bb10, otherwise: bb2]; } bb2: { -- switchInt((_2.1: bool)) -> [0: bb3, otherwise: bb4]; +- switchInt((_2.0: bool)) -> [0: bb4, otherwise: bb3]; + switchInt((_2.0: bool)) -> [0: bb3, otherwise: bb17]; } bb3: { -- falseEdge -> [real: bb13, imaginary: bb5]; +- falseEdge -> [real: bb20, imaginary: bb4]; - } - - bb4: { -- switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb5]; -- } -- -- bb5: { -- falseEdge -> [real: bb20, imaginary: bb6]; -- } -- -- bb6: { StorageLive(_15); _15 = (_2.1: bool); StorageLive(_16); @@ -67,6 +59,14 @@ + goto -> bb16; } +- bb5: { +- falseEdge -> [real: bb13, imaginary: bb3]; +- } +- +- bb6: { +- falseEdge -> [real: bb8, imaginary: bb5]; +- } +- - bb7: { + bb4: { _0 = const 1_i32; @@ -127,7 +127,7 @@ StorageDead(_9); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb2, imaginary: bb3]; +- falseEdge -> [real: bb1, imaginary: bb5]; + goto -> bb1; } @@ -184,7 +184,7 @@ StorageDead(_12); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb4, imaginary: bb5]; +- falseEdge -> [real: bb2, imaginary: bb3]; + goto -> bb2; } diff --git a/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir b/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir index 5bf78b6150f1a..107f56f7f6912 100644 --- a/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir @@ -32,12 +32,12 @@ fn main() -> () { } bb1: { - falseEdge -> [real: bb9, imaginary: bb4]; + _3 = const 3_i32; + goto -> bb14; } bb2: { - _3 = const 3_i32; - goto -> bb14; + falseEdge -> [real: bb9, imaginary: bb4]; } bb3: { @@ -50,11 +50,11 @@ fn main() -> () { } bb5: { - switchInt(_1) -> [4294967295: bb6, otherwise: bb2]; + switchInt(_1) -> [4294967295: bb6, otherwise: bb1]; } bb6: { - falseEdge -> [real: bb13, imaginary: bb2]; + falseEdge -> [real: bb13, imaginary: bb1]; } bb7: { @@ -64,7 +64,7 @@ fn main() -> () { bb8: { _7 = Lt(_1, const 10_i32); - switchInt(move _7) -> [0: bb3, otherwise: bb1]; + switchInt(move _7) -> [0: bb3, otherwise: bb2]; } bb9: { @@ -83,7 +83,7 @@ fn main() -> () { bb11: { StorageDead(_9); - falseEdge -> [real: bb2, imaginary: bb4]; + falseEdge -> [real: bb1, imaginary: bb4]; } bb12: { diff --git a/tests/mir-opt/matches_u8.exhaustive_match.MatchBranchSimplification.diff b/tests/mir-opt/matches_u8.exhaustive_match.MatchBranchSimplification.diff index fec5855636605..157f9c98353e7 100644 --- a/tests/mir-opt/matches_u8.exhaustive_match.MatchBranchSimplification.diff +++ b/tests/mir-opt/matches_u8.exhaustive_match.MatchBranchSimplification.diff @@ -8,16 +8,16 @@ bb0: { _2 = discriminant(_1); - switchInt(move _2) -> [0: bb3, 1: bb1, otherwise: bb2]; + switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { - _0 = const 1_u8; - goto -> bb4; + unreachable; } bb2: { - unreachable; + _0 = const 1_u8; + goto -> bb4; } bb3: { diff --git a/tests/mir-opt/matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff b/tests/mir-opt/matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff index 94d3ce6c97158..19083771fd954 100644 --- a/tests/mir-opt/matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff +++ b/tests/mir-opt/matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff @@ -8,16 +8,16 @@ bb0: { _2 = discriminant(_1); - switchInt(move _2) -> [0: bb3, 1: bb1, otherwise: bb2]; + switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { - _0 = const 1_i8; - goto -> bb4; + unreachable; } bb2: { - unreachable; + _0 = const 1_i8; + goto -> bb4; } bb3: { diff --git a/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.panic-abort.mir b/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.panic-abort.mir index 086955236466f..31a6a1d8b3daa 100644 --- a/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.panic-abort.mir +++ b/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.panic-abort.mir @@ -15,16 +15,16 @@ fn unwrap(_1: Option) -> T { bb0: { _2 = discriminant(_1); - switchInt(move _2) -> [0: bb1, 1: bb3, otherwise: bb2]; + switchInt(move _2) -> [0: bb2, 1: bb3, otherwise: bb1]; } bb1: { - StorageLive(_4); - _4 = begin_panic::<&str>(const "explicit panic") -> unwind unreachable; + unreachable; } bb2: { - unreachable; + StorageLive(_4); + _4 = begin_panic::<&str>(const "explicit panic") -> unwind unreachable; } bb3: { diff --git a/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.panic-unwind.mir b/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.panic-unwind.mir index 6276d85484618..53352fbb19f4c 100644 --- a/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.panic-unwind.mir +++ b/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.panic-unwind.mir @@ -15,16 +15,16 @@ fn unwrap(_1: Option) -> T { bb0: { _2 = discriminant(_1); - switchInt(move _2) -> [0: bb1, 1: bb3, otherwise: bb2]; + switchInt(move _2) -> [0: bb2, 1: bb3, otherwise: bb1]; } bb1: { - StorageLive(_4); - _4 = begin_panic::<&str>(const "explicit panic") -> bb4; + unreachable; } bb2: { - unreachable; + StorageLive(_4); + _4 = begin_panic::<&str>(const "explicit panic") -> bb4; } bb3: { diff --git a/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff b/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff index 1648f5dd8ca63..84350b0dc51b1 100644 --- a/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff +++ b/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff @@ -67,10 +67,14 @@ StorageLive(_7); _7 = Option::::Some(const 0_i32); _8 = discriminant(_7); - switchInt(move _8) -> [0: bb3, 1: bb1, otherwise: bb2]; + switchInt(move _8) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_9); _27 = const _; _9 = &(((*_27) as Some).0: i32); @@ -79,10 +83,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { - _6 = const (); goto -> bb4; diff --git a/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-abort.diff b/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-abort.diff index 8804e671527e8..14762b9c40f46 100644 --- a/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-abort.diff +++ b/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-abort.diff @@ -55,10 +55,14 @@ bb3: { - StorageDead(_8); _10 = discriminant(_7); - switchInt(move _10) -> [0: bb6, 1: bb4, otherwise: bb5]; + switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb4]; } bb4: { + unreachable; + } + + bb5: { - StorageLive(_12); _12 = ((_7 as Some).0: i32); - StorageLive(_13); @@ -74,10 +78,6 @@ goto -> bb2; } - bb5: { - unreachable; - } - bb6: { _0 = const (); - StorageDead(_9); diff --git a/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-unwind.diff b/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-unwind.diff index faaebc300efa2..24797424b5c8a 100644 --- a/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-unwind.diff +++ b/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-unwind.diff @@ -55,10 +55,14 @@ bb3: { - StorageDead(_8); _10 = discriminant(_7); - switchInt(move _10) -> [0: bb6, 1: bb4, otherwise: bb5]; + switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb4]; } bb4: { + unreachable; + } + + bb5: { - StorageLive(_12); _12 = ((_7 as Some).0: i32); - StorageLive(_13); @@ -74,10 +78,6 @@ goto -> bb2; } - bb5: { - unreachable; - } - bb6: { _0 = const (); - StorageDead(_9); diff --git a/tests/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff b/tests/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff index 9ff32b26b77ed..5611d679b7801 100644 --- a/tests/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff +++ b/tests/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff @@ -18,10 +18,14 @@ - _5 = const false; - _5 = const true; _2 = discriminant(_1); - switchInt(move _2) -> [0: bb3, 1: bb1, otherwise: bb2]; + switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_3); _3 = move ((_1 as Some).0: std::boxed::Box<()>); StorageLive(_4); @@ -32,10 +36,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { _0 = Option::>::None; goto -> bb4; diff --git a/tests/mir-opt/uninhabited_enum_branching.byref.UninhabitedEnumBranching.diff b/tests/mir-opt/uninhabited_enum_branching.byref.UninhabitedEnumBranching.diff index 7919450cdc52a..5a3544f85387b 100644 --- a/tests/mir-opt/uninhabited_enum_branching.byref.UninhabitedEnumBranching.diff +++ b/tests/mir-opt/uninhabited_enum_branching.byref.UninhabitedEnumBranching.diff @@ -30,11 +30,15 @@ StorageLive(_4); _4 = &(_1.1: Test3); _5 = discriminant((*_4)); -- switchInt(move _5) -> [0: bb3, 1: bb4, 2: bb5, 3: bb1, otherwise: bb2]; -+ switchInt(move _5) -> [0: bb12, 1: bb12, 2: bb5, 3: bb1, otherwise: bb12]; +- switchInt(move _5) -> [0: bb3, 1: bb4, 2: bb5, 3: bb2, otherwise: bb1]; ++ switchInt(move _5) -> [0: bb12, 1: bb12, 2: bb5, 3: bb2, otherwise: bb12]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_8); _8 = const "D"; _3 = &(*_8); @@ -42,10 +46,6 @@ goto -> bb6; } - bb2: { - unreachable; - } - bb3: { _3 = const "A(Empty)"; goto -> bb6; @@ -72,7 +72,7 @@ StorageDead(_3); StorageLive(_9); _10 = discriminant((_1.1: Test3)); -- switchInt(move _10) -> [0: bb8, 1: bb9, 2: bb10, 3: bb7, otherwise: bb2]; +- switchInt(move _10) -> [0: bb8, 1: bb9, 2: bb10, 3: bb7, otherwise: bb1]; + switchInt(move _10) -> [0: bb12, 1: bb12, 2: bb10, 3: bb7, otherwise: bb12]; } diff --git a/tests/mir-opt/uninhabited_enum_branching.custom_discriminant.UninhabitedEnumBranching.diff b/tests/mir-opt/uninhabited_enum_branching.custom_discriminant.UninhabitedEnumBranching.diff index 5e15298a78c12..121374553ed87 100644 --- a/tests/mir-opt/uninhabited_enum_branching.custom_discriminant.UninhabitedEnumBranching.diff +++ b/tests/mir-opt/uninhabited_enum_branching.custom_discriminant.UninhabitedEnumBranching.diff @@ -13,11 +13,15 @@ StorageLive(_2); _2 = Test2::D; _3 = discriminant(_2); -- switchInt(move _3) -> [4: bb3, 5: bb1, otherwise: bb2]; -+ switchInt(move _3) -> [4: bb3, 5: bb1, otherwise: bb5]; +- switchInt(move _3) -> [4: bb3, 5: bb2, otherwise: bb1]; ++ switchInt(move _3) -> [4: bb3, 5: bb2, otherwise: bb5]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_4); _4 = const "E"; _1 = &(*_4); @@ -25,10 +29,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { _1 = const "D"; goto -> bb4; diff --git a/tests/mir-opt/uninhabited_enum_branching.rs b/tests/mir-opt/uninhabited_enum_branching.rs index 60389117b1614..65552fb058a4b 100644 --- a/tests/mir-opt/uninhabited_enum_branching.rs +++ b/tests/mir-opt/uninhabited_enum_branching.rs @@ -32,7 +32,7 @@ struct Plop { fn simple() { // CHECK-LABEL: fn simple( // CHECK: [[discr:_.*]] = discriminant( - // CHECK: switchInt(move [[discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: bb1, otherwise: [[unreachable]]]; + // CHECK: switchInt(move [[discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: bb2, otherwise: [[unreachable]]]; // CHECK: [[unreachable]]: { // CHECK-NEXT: unreachable; match Test1::C { @@ -46,7 +46,7 @@ fn simple() { fn custom_discriminant() { // CHECK-LABEL: fn custom_discriminant( // CHECK: [[discr:_.*]] = discriminant( - // CHECK: switchInt(move [[discr]]) -> [4: bb3, 5: bb1, otherwise: bb5]; + // CHECK: switchInt(move [[discr]]) -> [4: bb3, 5: bb2, otherwise: bb5]; // CHECK: bb5: { // CHECK-NEXT: unreachable; match Test2::D { @@ -61,7 +61,7 @@ fn byref() { let plop = Plop { xx: 51, test3: Test3::C }; // CHECK: [[ref_discr:_.*]] = discriminant((* - // CHECK: switchInt(move [[ref_discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: bb5, 3: bb1, otherwise: [[unreachable]]]; + // CHECK: switchInt(move [[ref_discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: bb5, 3: bb2, otherwise: [[unreachable]]]; match &plop.test3 { Test3::A(_) => "A(Empty)", Test3::B(_) => "B(Empty)", diff --git a/tests/mir-opt/uninhabited_enum_branching.simple.UninhabitedEnumBranching.diff b/tests/mir-opt/uninhabited_enum_branching.simple.UninhabitedEnumBranching.diff index 410db79802edc..6ce61e1528748 100644 --- a/tests/mir-opt/uninhabited_enum_branching.simple.UninhabitedEnumBranching.diff +++ b/tests/mir-opt/uninhabited_enum_branching.simple.UninhabitedEnumBranching.diff @@ -14,11 +14,15 @@ StorageLive(_2); _2 = Test1::C; _3 = discriminant(_2); -- switchInt(move _3) -> [0: bb3, 1: bb4, 2: bb1, otherwise: bb2]; -+ switchInt(move _3) -> [0: bb6, 1: bb6, 2: bb1, otherwise: bb6]; +- switchInt(move _3) -> [0: bb3, 1: bb4, 2: bb2, otherwise: bb1]; ++ switchInt(move _3) -> [0: bb6, 1: bb6, 2: bb2, otherwise: bb6]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_5); _5 = const "C"; _1 = &(*_5); @@ -26,10 +30,6 @@ goto -> bb5; } - bb2: { - unreachable; - } - bb3: { _1 = const "A(Empty)"; goto -> bb5; diff --git a/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-abort.diff b/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-abort.diff index f6e594ffac765..da7a2bd10e01a 100644 --- a/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-abort.diff +++ b/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-abort.diff @@ -19,20 +19,20 @@ bb1: { _2 = discriminant(_1); -- switchInt(move _2) -> [0: bb4, 1: bb2, otherwise: bb3]; +- switchInt(move _2) -> [0: bb4, 1: bb3, otherwise: bb2]; + _5 = Eq(_2, const 0_isize); + assume(move _5); + goto -> bb4; } bb2: { -- StorageLive(_3); -- _3 = move ((_1 as Some).0: Empty); -- StorageLive(_4); unreachable; } bb3: { +- StorageLive(_3); +- _3 = move ((_1 as Some).0: Empty); +- StorageLive(_4); unreachable; } diff --git a/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-unwind.diff b/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-unwind.diff index 2813d64672e6a..a2121fc684f5b 100644 --- a/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-unwind.diff +++ b/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-unwind.diff @@ -19,20 +19,20 @@ bb1: { _2 = discriminant(_1); -- switchInt(move _2) -> [0: bb4, 1: bb2, otherwise: bb3]; +- switchInt(move _2) -> [0: bb4, 1: bb3, otherwise: bb2]; + _5 = Eq(_2, const 0_isize); + assume(move _5); + goto -> bb4; } bb2: { -- StorageLive(_3); -- _3 = move ((_1 as Some).0: Empty); -- StorageLive(_4); unreachable; } bb3: { +- StorageLive(_3); +- _3 = move ((_1 as Some).0: Empty); +- StorageLive(_4); unreachable; }