Skip to content

move Deaggregate pass to post_borrowck_cleanup #73656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/librustc_mir/interpret/step.rs
Original file line number Diff line number Diff line change
@@ -74,7 +74,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
Ok(true)
}

fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> {
/// Runs the interpretation logic for the given `mir::Statement` at the current frame and
/// statement counter. This also moves the statement counter forward.
crate fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> {
info!("{:?}", stmt);

use rustc_middle::mir::StatementKind::*;
26 changes: 23 additions & 3 deletions src/librustc_mir/transform/const_prop.rs
Original file line number Diff line number Diff line change
@@ -252,6 +252,11 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
throw_machine_stop_str!("tried to write to a local that is marked as not propagatable")
}
if frame == 0 && ecx.machine.only_propagate_inside_block_locals.contains(local) {
trace!(
"mutating local {:?} which is restricted to its block. \
Will remove it from const-prop after block is finished.",
local
);
ecx.machine.written_only_inside_own_block_locals.insert(local);
}
ecx.machine.stack[frame].locals[local].access_mut()
@@ -427,6 +432,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
match f(self) {
Ok(val) => Some(val),
Err(error) => {
trace!("InterpCx operation failed: {:?}", error);
// Some errors shouldn't come up because creating them causes
// an allocation, which we should avoid. When that happens,
// dedicated error variants should be introduced instead.
@@ -969,10 +975,10 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
ConstPropMode::OnlyPropagateInto => {}
other @ ConstPropMode::FullConstProp => {
trace!(
"local {:?} can't be propagated because of multiple assignments",
local,
"local {:?} can't be propagated because of multiple assignments. Previous state: {:?}",
local, other,
);
*other = ConstPropMode::OnlyPropagateInto;
*other = ConstPropMode::OnlyInsideOwnBlock;
}
}
}
@@ -1089,6 +1095,20 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
}
} else {
match statement.kind {
StatementKind::SetDiscriminant { ref place, .. } => {
match self.ecx.machine.can_const_prop[place.local] {
ConstPropMode::FullConstProp | ConstPropMode::OnlyInsideOwnBlock => {
if self.use_ecx(|this| this.ecx.statement(statement)).is_some() {
trace!("propped discriminant into {:?}", place);
} else {
Self::remove_const(&mut self.ecx, place.local);
}
}
ConstPropMode::OnlyPropagateInto | ConstPropMode::NoPropagation => {
Self::remove_const(&mut self.ecx, place.local);
}
}
}
StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => {
let frame = self.ecx.frame_mut();
frame.locals[local].value =
11 changes: 3 additions & 8 deletions src/librustc_mir/transform/mod.rs
Original file line number Diff line number Diff line change
@@ -408,6 +408,9 @@ fn run_post_borrowck_cleanup_passes<'tcx>(
// but before optimizations begin.
&add_retag::AddRetag,
&simplify::SimplifyCfg::new("elaborate-drops"),
// `Deaggregator` is conceptually part of MIR building, some backends rely on it happening
// and it can help optimizations.
&deaggregator::Deaggregator,
];

run_passes(
@@ -439,11 +442,6 @@ fn run_optimization_passes<'tcx>(
&instcombine::InstCombine,
&const_prop::ConstProp,
&simplify_branches::SimplifyBranches::new("after-const-prop"),
// Run deaggregation here because:
// 1. Some codegen backends require it
// 2. It creates additional possibilities for some MIR optimizations to trigger
// FIXME(#70073): Why is this done here and not in `post_borrowck_cleanup`?
&deaggregator::Deaggregator,
&simplify_try::SimplifyArmIdentity,
&simplify_try::SimplifyBranchSame,
&copy_prop::CopyPropagation,
@@ -460,9 +458,6 @@ fn run_optimization_passes<'tcx>(
&generator::StateTransform,
// FIXME(#70073): This pass is responsible for both optimization as well as some lints.
&const_prop::ConstProp,
// Even if we don't do optimizations, still run deaggregation because some backends assume
// that deaggregation always occurs.
&deaggregator::Deaggregator,
];

let pre_codegen_cleanup: &[&dyn MirPass<'tcx>] = &[
4 changes: 2 additions & 2 deletions src/test/codegen/consts.rs
Original file line number Diff line number Diff line change
@@ -10,11 +10,11 @@
// CHECK: @STATIC = {{.*}}, align 4

// This checks the constants from inline_enum_const
// CHECK: @alloc7 = {{.*}}, align 2
// CHECK: @alloc8 = {{.*}}, align 2

// This checks the constants from {low,high}_align_const, they share the same
// constant, but the alignment differs, so the higher one should be used
// CHECK: [[LOW_HIGH:@[0-9]+]] = {{.*}} getelementptr inbounds (<{ [8 x i8] }>, <{ [8 x i8] }>* @alloc19, i32 0, i32 0, i32 0), {{.*}}
// CHECK: [[LOW_HIGH:@[0-9]+]] = {{.*}} getelementptr inbounds (<{ [8 x i8] }>, <{ [8 x i8] }>* @alloc20, i32 0, i32 0, i32 0), {{.*}}

#[derive(Copy, Clone)]
// repr(i16) is required for the {low,high}_align_const test
4 changes: 3 additions & 1 deletion src/test/mir-opt/const_prop/aggregate.main.ConstProp.diff
Original file line number Diff line number Diff line change
@@ -14,19 +14,21 @@
StorageLive(_1); // scope 0 at $DIR/aggregate.rs:5:9: 5:10
StorageLive(_2); // scope 0 at $DIR/aggregate.rs:5:13: 5:24
StorageLive(_3); // scope 0 at $DIR/aggregate.rs:5:13: 5:22
_3 = (const 0_i32, const 1_i32, const 2_i32); // scope 0 at $DIR/aggregate.rs:5:13: 5:22
(_3.0: i32) = const 0_i32; // scope 0 at $DIR/aggregate.rs:5:13: 5:22
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000000))
// mir::Constant
// + span: $DIR/aggregate.rs:5:14: 5:15
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
(_3.1: i32) = const 1_i32; // scope 0 at $DIR/aggregate.rs:5:13: 5:22
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000001))
// mir::Constant
// + span: $DIR/aggregate.rs:5:17: 5:18
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
(_3.2: i32) = const 2_i32; // scope 0 at $DIR/aggregate.rs:5:13: 5:22
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000002))
22 changes: 6 additions & 16 deletions src/test/mir-opt/const_prop/discriminant.main.ConstProp.diff.32bit
Original file line number Diff line number Diff line change
@@ -15,19 +15,16 @@
StorageLive(_1); // scope 0 at $DIR/discriminant.rs:11:9: 11:10
StorageLive(_2); // scope 0 at $DIR/discriminant.rs:11:13: 11:64
StorageLive(_3); // scope 0 at $DIR/discriminant.rs:11:34: 11:44
- _3 = std::option::Option::<bool>::Some(const true); // scope 0 at $DIR/discriminant.rs:11:34: 11:44
+ _3 = const std::option::Option::<bool>::Some(true); // scope 0 at $DIR/discriminant.rs:11:34: 11:44
((_3 as Some).0: bool) = const true; // scope 0 at $DIR/discriminant.rs:11:34: 11:44
// ty::Const
- // + ty: bool
+ // + ty: std::option::Option<bool>
// + ty: bool
// + val: Value(Scalar(0x01))
// mir::Constant
- // + span: $DIR/discriminant.rs:11:39: 11:43
- // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
// + span: $DIR/discriminant.rs:11:39: 11:43
// + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
discriminant(_3) = 1; // scope 0 at $DIR/discriminant.rs:11:34: 11:44
- _4 = discriminant(_3); // scope 0 at $DIR/discriminant.rs:11:21: 11:31
- switchInt(move _4) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/discriminant.rs:11:21: 11:31
+ // + span: $DIR/discriminant.rs:11:34: 11:44
+ // + literal: Const { ty: std::option::Option<bool>, val: Value(Scalar(0x01)) }
+ _4 = const 1_isize; // scope 0 at $DIR/discriminant.rs:11:21: 11:31
+ // ty::Const
+ // + ty: isize
@@ -56,14 +53,7 @@
}

bb2: {
- switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:11:26: 11:30
+ switchInt(const true) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:11:26: 11:30
+ // ty::Const
+ // + ty: bool
+ // + val: Value(Scalar(0x01))
+ // mir::Constant
+ // + span: $DIR/discriminant.rs:11:26: 11:30
+ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:11:26: 11:30
}

bb3: {
22 changes: 6 additions & 16 deletions src/test/mir-opt/const_prop/discriminant.main.ConstProp.diff.64bit
Original file line number Diff line number Diff line change
@@ -15,19 +15,16 @@
StorageLive(_1); // scope 0 at $DIR/discriminant.rs:11:9: 11:10
StorageLive(_2); // scope 0 at $DIR/discriminant.rs:11:13: 11:64
StorageLive(_3); // scope 0 at $DIR/discriminant.rs:11:34: 11:44
- _3 = std::option::Option::<bool>::Some(const true); // scope 0 at $DIR/discriminant.rs:11:34: 11:44
+ _3 = const std::option::Option::<bool>::Some(true); // scope 0 at $DIR/discriminant.rs:11:34: 11:44
((_3 as Some).0: bool) = const true; // scope 0 at $DIR/discriminant.rs:11:34: 11:44
// ty::Const
- // + ty: bool
+ // + ty: std::option::Option<bool>
// + ty: bool
// + val: Value(Scalar(0x01))
// mir::Constant
- // + span: $DIR/discriminant.rs:11:39: 11:43
- // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
// + span: $DIR/discriminant.rs:11:39: 11:43
// + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
discriminant(_3) = 1; // scope 0 at $DIR/discriminant.rs:11:34: 11:44
- _4 = discriminant(_3); // scope 0 at $DIR/discriminant.rs:11:21: 11:31
- switchInt(move _4) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/discriminant.rs:11:21: 11:31
+ // + span: $DIR/discriminant.rs:11:34: 11:44
+ // + literal: Const { ty: std::option::Option<bool>, val: Value(Scalar(0x01)) }
+ _4 = const 1_isize; // scope 0 at $DIR/discriminant.rs:11:21: 11:31
+ // ty::Const
+ // + ty: isize
@@ -56,14 +53,7 @@
}

bb2: {
- switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:11:26: 11:30
+ switchInt(const true) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:11:26: 11:30
+ // ty::Const
+ // + ty: bool
+ // + val: Value(Scalar(0x01))
+ // mir::Constant
+ // + span: $DIR/discriminant.rs:11:26: 11:30
+ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:11:26: 11:30
}

bb3: {
9 changes: 5 additions & 4 deletions src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff
Original file line number Diff line number Diff line change
@@ -11,21 +11,22 @@
StorageLive(_1); // scope 0 at $DIR/issue-66971.rs:16:5: 16:23
StorageLive(_2); // scope 0 at $DIR/issue-66971.rs:16:12: 16:22
StorageLive(_3); // scope 0 at $DIR/issue-66971.rs:16:13: 16:15
- _3 = (); // scope 0 at $DIR/issue-66971.rs:16:13: 16:15
+ _3 = const (); // scope 0 at $DIR/issue-66971.rs:16:13: 16:15
- (_2.0: ()) = move _3; // scope 0 at $DIR/issue-66971.rs:16:12: 16:22
+ (_2.0: ()) = const (); // scope 0 at $DIR/issue-66971.rs:16:12: 16:22
+ // ty::Const
+ // + ty: ()
+ // + val: Value(Scalar(<ZST>))
+ // mir::Constant
+ // + span: $DIR/issue-66971.rs:16:13: 16:15
+ // + span: $DIR/issue-66971.rs:16:12: 16:22
+ // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
_2 = (move _3, const 0_u8, const 0_u8); // scope 0 at $DIR/issue-66971.rs:16:12: 16:22
(_2.1: u8) = const 0_u8; // scope 0 at $DIR/issue-66971.rs:16:12: 16:22
// ty::Const
// + ty: u8
// + val: Value(Scalar(0x00))
// mir::Constant
// + span: $DIR/issue-66971.rs:16:17: 16:18
// + literal: Const { ty: u8, val: Value(Scalar(0x00)) }
(_2.2: u8) = const 0_u8; // scope 0 at $DIR/issue-66971.rs:16:12: 16:22
// ty::Const
// + ty: u8
// + val: Value(Scalar(0x00))
24 changes: 18 additions & 6 deletions src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff
Original file line number Diff line number Diff line change
@@ -11,22 +11,34 @@
StorageLive(_1); // scope 0 at $DIR/issue-67019.rs:11:5: 11:20
StorageLive(_2); // scope 0 at $DIR/issue-67019.rs:11:10: 11:19
StorageLive(_3); // scope 0 at $DIR/issue-67019.rs:11:11: 11:17
_3 = (const 1_u8, const 2_u8); // scope 0 at $DIR/issue-67019.rs:11:11: 11:17
(_3.0: u8) = const 1_u8; // scope 0 at $DIR/issue-67019.rs:11:11: 11:17
// ty::Const
// + ty: u8
// + val: Value(Scalar(0x01))
// mir::Constant
- // + span: $DIR/issue-67019.rs:11:12: 11:13
+ // + span: $DIR/issue-67019.rs:11:11: 11:17
// + span: $DIR/issue-67019.rs:11:12: 11:13
// + literal: Const { ty: u8, val: Value(Scalar(0x01)) }
(_3.1: u8) = const 2_u8; // scope 0 at $DIR/issue-67019.rs:11:11: 11:17
// ty::Const
// + ty: u8
// + val: Value(Scalar(0x02))
// mir::Constant
- // + span: $DIR/issue-67019.rs:11:15: 11:16
+ // + span: $DIR/issue-67019.rs:11:11: 11:17
// + span: $DIR/issue-67019.rs:11:15: 11:16
// + literal: Const { ty: u8, val: Value(Scalar(0x02)) }
_2 = (move _3,); // scope 0 at $DIR/issue-67019.rs:11:10: 11:19
- (_2.0: (u8, u8)) = move _3; // scope 0 at $DIR/issue-67019.rs:11:10: 11:19
+ (_2.0: (u8, u8)) = (const 1_u8, const 2_u8); // scope 0 at $DIR/issue-67019.rs:11:10: 11:19
+ // ty::Const
+ // + ty: u8
+ // + val: Value(Scalar(0x01))
+ // mir::Constant
+ // + span: $DIR/issue-67019.rs:11:10: 11:19
+ // + literal: Const { ty: u8, val: Value(Scalar(0x01)) }
+ // ty::Const
+ // + ty: u8
+ // + val: Value(Scalar(0x02))
+ // mir::Constant
+ // + span: $DIR/issue-67019.rs:11:10: 11:19
+ // + literal: Const { ty: u8, val: Value(Scalar(0x02)) }
StorageDead(_3); // scope 0 at $DIR/issue-67019.rs:11:18: 11:19
_1 = const test(move _2) -> bb1; // scope 0 at $DIR/issue-67019.rs:11:5: 11:20
// ty::Const
Original file line number Diff line number Diff line change
@@ -14,20 +14,19 @@

bb0: {
StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:5:9: 5:14
_1 = (const 42_i32, const 43_i32); // scope 0 at $DIR/mutable_variable_aggregate.rs:5:17: 5:25
(_1.0: i32) = const 42_i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:5:17: 5:25
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x0000002a))
// mir::Constant
- // + span: $DIR/mutable_variable_aggregate.rs:5:18: 5:20
+ // + span: $DIR/mutable_variable_aggregate.rs:5:17: 5:25
// + span: $DIR/mutable_variable_aggregate.rs:5:18: 5:20
// + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) }
(_1.1: i32) = const 43_i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:5:17: 5:25
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x0000002b))
// mir::Constant
- // + span: $DIR/mutable_variable_aggregate.rs:5:22: 5:24
+ // + span: $DIR/mutable_variable_aggregate.rs:5:17: 5:25
// + span: $DIR/mutable_variable_aggregate.rs:5:22: 5:24
// + literal: Const { ty: i32, val: Value(Scalar(0x0000002b)) }
(_1.1: i32) = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:6:5: 6:13
// ty::Const
Original file line number Diff line number Diff line change
@@ -18,13 +18,14 @@

bb0: {
StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:5:9: 5:14
_1 = (const 42_i32, const 43_i32); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:5:17: 5:25
(_1.0: i32) = const 42_i32; // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:5:17: 5:25
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x0000002a))
// mir::Constant
// + span: $DIR/mutable_variable_aggregate_mut_ref.rs:5:18: 5:20
// + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) }
(_1.1: i32) = const 43_i32; // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:5:17: 5:25
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x0000002b))
Original file line number Diff line number Diff line change
@@ -34,20 +34,19 @@

bb1: {
StorageLive(_2); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:6:9: 6:14
_2 = (const 1_i32, const 2_i32); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:6:29: 6:35
(_2.0: i32) = const 1_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:6:29: 6:35
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000001))
// mir::Constant
- // + span: $DIR/mutable_variable_unprop_assign.rs:6:30: 6:31
+ // + span: $DIR/mutable_variable_unprop_assign.rs:6:29: 6:35
// + span: $DIR/mutable_variable_unprop_assign.rs:6:30: 6:31
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
(_2.1: i32) = const 2_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:6:29: 6:35
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000002))
// mir::Constant
- // + span: $DIR/mutable_variable_unprop_assign.rs:6:33: 6:34
+ // + span: $DIR/mutable_variable_unprop_assign.rs:6:29: 6:35
// + span: $DIR/mutable_variable_unprop_assign.rs:6:33: 6:34
// + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
StorageLive(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:7:11: 7:12
_3 = _1; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:7:11: 7:12
Original file line number Diff line number Diff line change
@@ -173,13 +173,14 @@
StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35
StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
_9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
(_9.0: u32) = const 12_u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
// ty::Const
// + ty: u32
// + val: Value(Scalar(0x0000000c))
// mir::Constant
// + span: $DIR/optimizes_into_variable.rs:14:25: 14:27
// + literal: Const { ty: u32, val: Value(Scalar(0x0000000c)) }
(_9.1: u32) = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
// ty::Const
// + ty: u32
// + val: Value(Scalar(0x0000002a))
Original file line number Diff line number Diff line change
@@ -173,13 +173,14 @@
StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35
StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
_9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
(_9.0: u32) = const 12_u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
// ty::Const
// + ty: u32
// + val: Value(Scalar(0x0000000c))
// mir::Constant
// + span: $DIR/optimizes_into_variable.rs:14:25: 14:27
// + literal: Const { ty: u32, val: Value(Scalar(0x0000000c)) }
(_9.1: u32) = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
// ty::Const
// + ty: u32
// + val: Value(Scalar(0x0000002a))
Original file line number Diff line number Diff line change
@@ -12,20 +12,19 @@

bb0: {
StorageLive(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:3:9: 3:10
_1 = (const 1_u32, const 2_u32); // scope 0 at $DIR/tuple_literal_propagation.rs:3:13: 3:19
(_1.0: u32) = const 1_u32; // scope 0 at $DIR/tuple_literal_propagation.rs:3:13: 3:19
// ty::Const
// + ty: u32
// + val: Value(Scalar(0x00000001))
// mir::Constant
- // + span: $DIR/tuple_literal_propagation.rs:3:14: 3:15
+ // + span: $DIR/tuple_literal_propagation.rs:3:13: 3:19
// + span: $DIR/tuple_literal_propagation.rs:3:14: 3:15
// + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
(_1.1: u32) = const 2_u32; // scope 0 at $DIR/tuple_literal_propagation.rs:3:13: 3:19
// ty::Const
// + ty: u32
// + val: Value(Scalar(0x00000002))
// mir::Constant
- // + span: $DIR/tuple_literal_propagation.rs:3:17: 3:18
+ // + span: $DIR/tuple_literal_propagation.rs:3:13: 3:19
// + span: $DIR/tuple_literal_propagation.rs:3:17: 3:18
// + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
StorageLive(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:5:5: 5:15
StorageLive(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:5:13: 5:14
12 changes: 4 additions & 8 deletions src/test/mir-opt/const_prop_miscompile.bar.ConstProp.diff
Original file line number Diff line number Diff line change
@@ -19,17 +19,13 @@

bb0: {
StorageLive(_1); // scope 0 at $DIR/const_prop_miscompile.rs:12:9: 12:14
- _1 = (const 1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:12:17: 12:21
+ _1 = const (1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:12:17: 12:21
(_1.0: i32) = const 1_i32; // scope 0 at $DIR/const_prop_miscompile.rs:12:17: 12:21
// ty::Const
- // + ty: i32
+ // + ty: (i32,)
// + ty: i32
// + val: Value(Scalar(0x00000001))
// mir::Constant
- // + span: $DIR/const_prop_miscompile.rs:12:18: 12:19
- // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+ // + span: $DIR/const_prop_miscompile.rs:12:17: 12:21
+ // + literal: Const { ty: (i32,), val: Value(Scalar(0x00000001)) }
// + span: $DIR/const_prop_miscompile.rs:12:18: 12:19
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
StorageLive(_2); // scope 1 at $DIR/const_prop_miscompile.rs:13:5: 15:6
StorageLive(_3); // scope 2 at $DIR/const_prop_miscompile.rs:14:10: 14:22
_3 = &raw mut (_1.0: i32); // scope 2 at $DIR/const_prop_miscompile.rs:14:10: 14:22
12 changes: 4 additions & 8 deletions src/test/mir-opt/const_prop_miscompile.foo.ConstProp.diff
Original file line number Diff line number Diff line change
@@ -16,17 +16,13 @@

bb0: {
StorageLive(_1); // scope 0 at $DIR/const_prop_miscompile.rs:5:9: 5:14
- _1 = (const 1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:5:17: 5:21
+ _1 = const (1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:5:17: 5:21
(_1.0: i32) = const 1_i32; // scope 0 at $DIR/const_prop_miscompile.rs:5:17: 5:21
// ty::Const
- // + ty: i32
+ // + ty: (i32,)
// + ty: i32
// + val: Value(Scalar(0x00000001))
// mir::Constant
- // + span: $DIR/const_prop_miscompile.rs:5:18: 5:19
- // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+ // + span: $DIR/const_prop_miscompile.rs:5:17: 5:21
+ // + literal: Const { ty: (i32,), val: Value(Scalar(0x00000001)) }
// + span: $DIR/const_prop_miscompile.rs:5:18: 5:19
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
StorageLive(_2); // scope 1 at $DIR/const_prop_miscompile.rs:6:6: 6:14
_2 = &mut (_1.0: i32); // scope 1 at $DIR/const_prop_miscompile.rs:6:6: 6:14
(*_2) = const 5_i32; // scope 1 at $DIR/const_prop_miscompile.rs:6:5: 6:18
162 changes: 162 additions & 0 deletions src/test/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
- // MIR for `float_to_exponential_common` before ConstProp
+ // MIR for `float_to_exponential_common` after ConstProp

fn float_to_exponential_common(_1: &mut std::fmt::Formatter, _2: &T, _3: bool) -> std::result::Result<(), std::fmt::Error> {
debug fmt => _1; // in scope 0 at $DIR/funky_arms.rs:11:35: 11:38
debug num => _2; // in scope 0 at $DIR/funky_arms.rs:11:60: 11:63
debug upper => _3; // in scope 0 at $DIR/funky_arms.rs:11:69: 11:74
let mut _0: std::result::Result<(), std::fmt::Error>; // return place in scope 0 at $DIR/funky_arms.rs:11:85: 11:91
let _4: bool; // in scope 0 at $DIR/funky_arms.rs:15:9: 15:19
let mut _5: &std::fmt::Formatter; // in scope 0 at $DIR/funky_arms.rs:15:22: 15:25
let mut _7: std::option::Option<usize>; // in scope 0 at $DIR/funky_arms.rs:24:30: 24:45
let mut _8: &std::fmt::Formatter; // in scope 0 at $DIR/funky_arms.rs:24:30: 24:33
let mut _9: isize; // in scope 0 at $DIR/funky_arms.rs:24:12: 24:27
let mut _11: &mut std::fmt::Formatter; // in scope 0 at $DIR/funky_arms.rs:26:43: 26:46
let mut _12: &T; // in scope 0 at $DIR/funky_arms.rs:26:48: 26:51
let mut _13: core::num::flt2dec::Sign; // in scope 0 at $DIR/funky_arms.rs:26:53: 26:57
let mut _14: u32; // in scope 0 at $DIR/funky_arms.rs:26:59: 26:79
let mut _15: u32; // in scope 0 at $DIR/funky_arms.rs:26:59: 26:75
let mut _16: usize; // in scope 0 at $DIR/funky_arms.rs:26:59: 26:68
let mut _17: bool; // in scope 0 at $DIR/funky_arms.rs:26:81: 26:86
let mut _18: &mut std::fmt::Formatter; // in scope 0 at $DIR/funky_arms.rs:28:46: 28:49
let mut _19: &T; // in scope 0 at $DIR/funky_arms.rs:28:51: 28:54
let mut _20: core::num::flt2dec::Sign; // in scope 0 at $DIR/funky_arms.rs:28:56: 28:60
let mut _21: bool; // in scope 0 at $DIR/funky_arms.rs:28:62: 28:67
scope 1 {
debug force_sign => _4; // in scope 1 at $DIR/funky_arms.rs:15:9: 15:19
let _6: core::num::flt2dec::Sign; // in scope 1 at $DIR/funky_arms.rs:19:9: 19:13
scope 2 {
debug sign => _6; // in scope 2 at $DIR/funky_arms.rs:19:9: 19:13
let _10: usize; // in scope 2 at $DIR/funky_arms.rs:24:17: 24:26
scope 3 {
debug precision => _10; // in scope 3 at $DIR/funky_arms.rs:24:17: 24:26
}
}
}

bb0: {
StorageLive(_4); // scope 0 at $DIR/funky_arms.rs:15:9: 15:19
StorageLive(_5); // scope 0 at $DIR/funky_arms.rs:15:22: 15:25
_5 = &(*_1); // scope 0 at $DIR/funky_arms.rs:15:22: 15:25
_4 = const std::fmt::Formatter::sign_plus(move _5) -> bb1; // scope 0 at $DIR/funky_arms.rs:15:22: 15:37
// ty::Const
// + ty: for<'r> fn(&'r std::fmt::Formatter) -> bool {std::fmt::Formatter::sign_plus}
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/funky_arms.rs:15:26: 15:35
// + literal: Const { ty: for<'r> fn(&'r std::fmt::Formatter) -> bool {std::fmt::Formatter::sign_plus}, val: Value(Scalar(<ZST>)) }
}

bb1: {
StorageDead(_5); // scope 0 at $DIR/funky_arms.rs:15:36: 15:37
StorageLive(_6); // scope 1 at $DIR/funky_arms.rs:19:9: 19:13
switchInt(_4) -> [false: bb3, otherwise: bb2]; // scope 1 at $DIR/funky_arms.rs:20:9: 20:14
}

bb2: {
discriminant(_6) = 2; // scope 1 at $DIR/funky_arms.rs:21:17: 21:41
goto -> bb4; // scope 1 at $DIR/funky_arms.rs:19:16: 22:6
}

bb3: {
discriminant(_6) = 0; // scope 1 at $DIR/funky_arms.rs:20:18: 20:38
goto -> bb4; // scope 1 at $DIR/funky_arms.rs:19:16: 22:6
}

bb4: {
StorageLive(_7); // scope 2 at $DIR/funky_arms.rs:24:30: 24:45
StorageLive(_8); // scope 2 at $DIR/funky_arms.rs:24:30: 24:33
_8 = &(*_1); // scope 2 at $DIR/funky_arms.rs:24:30: 24:33
_7 = const std::fmt::Formatter::precision(move _8) -> bb5; // scope 2 at $DIR/funky_arms.rs:24:30: 24:45
// ty::Const
// + ty: for<'r> fn(&'r std::fmt::Formatter) -> std::option::Option<usize> {std::fmt::Formatter::precision}
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/funky_arms.rs:24:34: 24:43
// + literal: Const { ty: for<'r> fn(&'r std::fmt::Formatter) -> std::option::Option<usize> {std::fmt::Formatter::precision}, val: Value(Scalar(<ZST>)) }
}

bb5: {
StorageDead(_8); // scope 2 at $DIR/funky_arms.rs:24:44: 24:45
_9 = discriminant(_7); // scope 2 at $DIR/funky_arms.rs:24:12: 24:27
switchInt(move _9) -> [1_isize: bb7, otherwise: bb6]; // scope 2 at $DIR/funky_arms.rs:24:12: 24:27
}

bb6: {
StorageLive(_18); // scope 2 at $DIR/funky_arms.rs:28:46: 28:49
_18 = &mut (*_1); // scope 2 at $DIR/funky_arms.rs:28:46: 28:49
StorageLive(_19); // scope 2 at $DIR/funky_arms.rs:28:51: 28:54
_19 = _2; // scope 2 at $DIR/funky_arms.rs:28:51: 28:54
StorageLive(_20); // scope 2 at $DIR/funky_arms.rs:28:56: 28:60
_20 = _6; // scope 2 at $DIR/funky_arms.rs:28:56: 28:60
StorageLive(_21); // scope 2 at $DIR/funky_arms.rs:28:62: 28:67
_21 = _3; // scope 2 at $DIR/funky_arms.rs:28:62: 28:67
_0 = const float_to_exponential_common_shortest::<T>(move _18, move _19, move _20, move _21) -> bb9; // scope 2 at $DIR/funky_arms.rs:28:9: 28:68
// ty::Const
// + ty: for<'r, 's, 't0> fn(&'r mut std::fmt::Formatter<'s>, &'t0 T, core::num::flt2dec::Sign, bool) -> std::result::Result<(), std::fmt::Error> {float_to_exponential_common_shortest::<T>}
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/funky_arms.rs:28:9: 28:45
// + literal: Const { ty: for<'r, 's, 't0> fn(&'r mut std::fmt::Formatter<'s>, &'t0 T, core::num::flt2dec::Sign, bool) -> std::result::Result<(), std::fmt::Error> {float_to_exponential_common_shortest::<T>}, val: Value(Scalar(<ZST>)) }
}

bb7: {
StorageLive(_10); // scope 2 at $DIR/funky_arms.rs:24:17: 24:26
_10 = ((_7 as Some).0: usize); // scope 2 at $DIR/funky_arms.rs:24:17: 24:26
StorageLive(_11); // scope 3 at $DIR/funky_arms.rs:26:43: 26:46
_11 = &mut (*_1); // scope 3 at $DIR/funky_arms.rs:26:43: 26:46
StorageLive(_12); // scope 3 at $DIR/funky_arms.rs:26:48: 26:51
_12 = _2; // scope 3 at $DIR/funky_arms.rs:26:48: 26:51
StorageLive(_13); // scope 3 at $DIR/funky_arms.rs:26:53: 26:57
_13 = _6; // scope 3 at $DIR/funky_arms.rs:26:53: 26:57
StorageLive(_14); // scope 3 at $DIR/funky_arms.rs:26:59: 26:79
StorageLive(_15); // scope 3 at $DIR/funky_arms.rs:26:59: 26:75
StorageLive(_16); // scope 3 at $DIR/funky_arms.rs:26:59: 26:68
_16 = _10; // scope 3 at $DIR/funky_arms.rs:26:59: 26:68
_15 = move _16 as u32 (Misc); // scope 3 at $DIR/funky_arms.rs:26:59: 26:75
StorageDead(_16); // scope 3 at $DIR/funky_arms.rs:26:74: 26:75
_14 = Add(move _15, const 1_u32); // scope 3 at $DIR/funky_arms.rs:26:59: 26:79
// ty::Const
// + ty: u32
// + val: Value(Scalar(0x00000001))
// mir::Constant
// + span: $DIR/funky_arms.rs:26:78: 26:79
// + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
StorageDead(_15); // scope 3 at $DIR/funky_arms.rs:26:78: 26:79
StorageLive(_17); // scope 3 at $DIR/funky_arms.rs:26:81: 26:86
_17 = _3; // scope 3 at $DIR/funky_arms.rs:26:81: 26:86
_0 = const float_to_exponential_common_exact::<T>(move _11, move _12, move _13, move _14, move _17) -> bb8; // scope 3 at $DIR/funky_arms.rs:26:9: 26:87
// ty::Const
// + ty: for<'r, 's, 't0> fn(&'r mut std::fmt::Formatter<'s>, &'t0 T, core::num::flt2dec::Sign, u32, bool) -> std::result::Result<(), std::fmt::Error> {float_to_exponential_common_exact::<T>}
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/funky_arms.rs:26:9: 26:42
// + literal: Const { ty: for<'r, 's, 't0> fn(&'r mut std::fmt::Formatter<'s>, &'t0 T, core::num::flt2dec::Sign, u32, bool) -> std::result::Result<(), std::fmt::Error> {float_to_exponential_common_exact::<T>}, val: Value(Scalar(<ZST>)) }
}

bb8: {
StorageDead(_17); // scope 3 at $DIR/funky_arms.rs:26:86: 26:87
StorageDead(_14); // scope 3 at $DIR/funky_arms.rs:26:86: 26:87
StorageDead(_13); // scope 3 at $DIR/funky_arms.rs:26:86: 26:87
StorageDead(_12); // scope 3 at $DIR/funky_arms.rs:26:86: 26:87
StorageDead(_11); // scope 3 at $DIR/funky_arms.rs:26:86: 26:87
StorageDead(_10); // scope 2 at $DIR/funky_arms.rs:27:5: 27:6
goto -> bb10; // scope 2 at $DIR/funky_arms.rs:24:5: 29:6
}

bb9: {
StorageDead(_21); // scope 2 at $DIR/funky_arms.rs:28:67: 28:68
StorageDead(_20); // scope 2 at $DIR/funky_arms.rs:28:67: 28:68
StorageDead(_19); // scope 2 at $DIR/funky_arms.rs:28:67: 28:68
StorageDead(_18); // scope 2 at $DIR/funky_arms.rs:28:67: 28:68
goto -> bb10; // scope 2 at $DIR/funky_arms.rs:24:5: 29:6
}

bb10: {
StorageDead(_6); // scope 1 at $DIR/funky_arms.rs:30:1: 30:2
StorageDead(_4); // scope 0 at $DIR/funky_arms.rs:30:1: 30:2
StorageDead(_7); // scope 0 at $DIR/funky_arms.rs:30:1: 30:2
return; // scope 0 at $DIR/funky_arms.rs:30:2: 30:2
}
}

56 changes: 56 additions & 0 deletions src/test/mir-opt/funky_arms.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// compile-flags: --crate-type lib -Cdebug-assertions=no

#![feature(flt2dec)]

extern crate core;

use core::num::flt2dec;
use std::fmt::{Formatter, Result};

// EMIT_MIR funky_arms.float_to_exponential_common.ConstProp.diff
fn float_to_exponential_common<T>(fmt: &mut Formatter<'_>, num: &T, upper: bool) -> Result
where
T: flt2dec::DecodableFloat,
{
let force_sign = fmt.sign_plus();
// A bug in const propagation (never reached master, but during dev of a PR) caused the
// `sign = Minus` assignment to get propagated into all future reads of `sign`. This is
// wrong because `sign` could also have `MinusPlus` value.
let sign = match force_sign {
false => flt2dec::Sign::Minus,
true => flt2dec::Sign::MinusPlus,
};

if let Some(precision) = fmt.precision() {
// 1 integral digit + `precision` fractional digits = `precision + 1` total digits
float_to_exponential_common_exact(fmt, num, sign, precision as u32 + 1, upper)
} else {
float_to_exponential_common_shortest(fmt, num, sign, upper)
}
}
#[inline(never)]
fn float_to_exponential_common_exact<T>(
fmt: &mut Formatter<'_>,
num: &T,
sign: flt2dec::Sign,
precision: u32,
upper: bool,
) -> Result
where
T: flt2dec::DecodableFloat,
{
unimplemented!()
}

#[inline(never)]
fn float_to_exponential_common_shortest<T>(
fmt: &mut Formatter<'_>,
num: &T,
sign: flt2dec::Sign,
upper: bool,
) -> Result
where
T: flt2dec::DecodableFloat,
{
unimplemented!()
}
Original file line number Diff line number Diff line change
@@ -21,15 +21,15 @@ yields ()

bb0: {
StorageLive(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:23:13: 23:14
_3 = Foo(const 5_i32); // scope 0 at $DIR/generator-storage-dead-unwind.rs:23:17: 23:23
(_3.0: i32) = const 5_i32; // scope 0 at $DIR/generator-storage-dead-unwind.rs:23:17: 23:23
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000005))
// mir::Constant
// + span: $DIR/generator-storage-dead-unwind.rs:23:21: 23:22
// + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) }
StorageLive(_4); // scope 1 at $DIR/generator-storage-dead-unwind.rs:24:13: 24:14
_4 = Bar(const 6_i32); // scope 1 at $DIR/generator-storage-dead-unwind.rs:24:17: 24:23
(_4.0: i32) = const 6_i32; // scope 1 at $DIR/generator-storage-dead-unwind.rs:24:17: 24:23
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000006))
@@ -38,7 +38,6 @@ yields ()
// + literal: Const { ty: i32, val: Value(Scalar(0x00000006)) }
StorageLive(_5); // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14
StorageLive(_6); // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14
_6 = (); // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14
_5 = yield(move _6) -> [resume: bb2, drop: bb4]; // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14
}

Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
// MIR for `main::{{closure}}#0` 0 generator_resume
/* generator_layout = GeneratorLayout {
field_tys: {
_0: HasDrop,
},
field_tys: {},
variant_fields: {
Unresumed(0): [],
Returned (1): [],
Panicked (2): [],
Suspend0 (3): [_0],
},
storage_conflicts: BitMatrix(1x1) {
(_0, _0),
Suspend0 (3): [],
},
storage_conflicts: BitMatrix(0x0) {},
} */

fn main::{{closure}}#0(_1: std::pin::Pin<&mut [generator@$DIR/generator-tiny.rs:19:16: 25:6 {u8, HasDrop, ()}]>, _2: u8) -> std::ops::GeneratorState<(), ()> {
@@ -27,7 +23,7 @@ fn main::{{closure}}#0(_1: std::pin::Pin<&mut [generator@$DIR/generator-tiny.rs:
let _10: u8; // in scope 0 at $DIR/generator-tiny.rs:19:17: 19:19
let mut _11: u32; // in scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
scope 1 {
debug _d => (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6 {u8, HasDrop, ()}])) as variant#3).0: HasDrop); // in scope 1 at $DIR/generator-tiny.rs:20:13: 20:15
debug _d => _3; // in scope 1 at $DIR/generator-tiny.rs:20:13: 20:15
}

bb0: {
@@ -37,16 +33,14 @@ fn main::{{closure}}#0(_1: std::pin::Pin<&mut [generator@$DIR/generator-tiny.rs:

bb1: {
_10 = move _2; // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
nop; // scope 0 at $DIR/generator-tiny.rs:20:13: 20:15
(((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6 {u8, HasDrop, ()}])) as variant#3).0: HasDrop) = HasDrop; // scope 0 at $DIR/generator-tiny.rs:20:18: 20:25
StorageLive(_3); // scope 0 at $DIR/generator-tiny.rs:20:13: 20:15
StorageLive(_4); // scope 1 at $DIR/generator-tiny.rs:21:9: 24:10
goto -> bb2; // scope 1 at $DIR/generator-tiny.rs:21:9: 24:10
}

bb2: {
StorageLive(_6); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
StorageLive(_7); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
_7 = (); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
_0 = std::ops::GeneratorState::<(), ()>::Yielded(move _7); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6 {u8, HasDrop, ()}]))) = 3; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
return; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
@@ -78,6 +72,7 @@ fn main::{{closure}}#0(_1: std::pin::Pin<&mut [generator@$DIR/generator-tiny.rs:
}

bb5: {
StorageLive(_3); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
StorageLive(_4); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
StorageLive(_6); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
StorageLive(_7); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
12 changes: 2 additions & 10 deletions src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir
Original file line number Diff line number Diff line change
@@ -21,23 +21,15 @@ fn foo(_1: T, _2: i32) -> i32 {

bb0: {
StorageLive(_3); // scope 0 at $DIR/inline-closure.rs:11:9: 11:10
_3 = [closure@foo::<T>::{{closure}}#0]; // scope 0 at $DIR/inline-closure.rs:11:13: 11:24
// closure
// + def_id: DefId(0:6 ~ inline_closure[317d]::foo[0]::{{closure}}[0])
// + substs: [
// T,
// i8,
// extern "rust-call" fn((i32, i32)) -> i32,
// (),
// ]
StorageLive(_4); // scope 1 at $DIR/inline-closure.rs:12:5: 12:6
_4 = &_3; // scope 1 at $DIR/inline-closure.rs:12:5: 12:6
StorageLive(_5); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12
StorageLive(_6); // scope 1 at $DIR/inline-closure.rs:12:7: 12:8
_6 = _2; // scope 1 at $DIR/inline-closure.rs:12:7: 12:8
StorageLive(_7); // scope 1 at $DIR/inline-closure.rs:12:10: 12:11
_7 = _2; // scope 1 at $DIR/inline-closure.rs:12:10: 12:11
_5 = (move _6, move _7); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12
(_5.0: i32) = move _6; // scope 1 at $DIR/inline-closure.rs:12:5: 12:12
(_5.1: i32) = move _7; // scope 1 at $DIR/inline-closure.rs:12:5: 12:12
_8 = move (_5.0: i32); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12
_9 = move (_5.1: i32); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12
_0 = _8; // scope 2 at $DIR/inline-closure.rs:11:22: 11:24
Original file line number Diff line number Diff line change
@@ -24,23 +24,15 @@ fn foo(_1: T, _2: &i32) -> i32 {

bb0: {
StorageLive(_3); // scope 0 at $DIR/inline-closure-borrows-arg.rs:12:9: 12:10
_3 = [closure@foo::<T>::{{closure}}#0]; // scope 0 at $DIR/inline-closure-borrows-arg.rs:12:13: 15:6
// closure
// + def_id: DefId(0:6 ~ inline_closure_borrows_arg[317d]::foo[0]::{{closure}}[0])
// + substs: [
// T,
// i8,
// for<'r, 's> extern "rust-call" fn((&'r i32, &'s i32)) -> i32,
// (),
// ]
StorageLive(_4); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6
_4 = &_3; // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6
StorageLive(_5); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
StorageLive(_6); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:7: 16:8
_6 = &(*_2); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:7: 16:8
StorageLive(_7); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11
_7 = &(*_2); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11
_5 = (move _6, move _7); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
(_5.0: &i32) = move _6; // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
(_5.1: &i32) = move _7; // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
_8 = move (_5.0: &i32); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
_9 = move (_5.1: &i32); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
_0 = (*_8); // scope 3 at $DIR/inline-closure-borrows-arg.rs:14:9: 14:18
Original file line number Diff line number Diff line change
@@ -28,23 +28,16 @@ fn foo(_1: T, _2: i32) -> (i32, T) {
_4 = &_2; // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
StorageLive(_5); // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
_5 = &_1; // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
_3 = [closure@foo::<T>::{{closure}}#0] { q: move _4, t: move _5 }; // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
// closure
// + def_id: DefId(0:6 ~ inline_closure_captures[317d]::foo[0]::{{closure}}[0])
// + substs: [
// T,
// i8,
// extern "rust-call" fn((i32,)) -> (i32, T),
// (&i32, &T),
// ]
(_3.0: &i32) = move _4; // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
(_3.1: &T) = move _5; // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
StorageDead(_5); // scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24
StorageDead(_4); // scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24
StorageLive(_6); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:6
_6 = &_3; // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:6
StorageLive(_7); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9
StorageLive(_8); // scope 1 at $DIR/inline-closure-captures.rs:12:7: 12:8
_8 = _2; // scope 1 at $DIR/inline-closure-captures.rs:12:7: 12:8
_7 = (move _8,); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9
(_7.0: i32) = move _8; // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9
_11 = move (_7.0: i32); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9
StorageLive(_9); // scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20
_9 = (*((*_6).0: &i32)); // scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20
161 changes: 79 additions & 82 deletions src/test/mir-opt/issue_73223.main.PreCodegen.diff.32bit

Large diffs are not rendered by default.

161 changes: 79 additions & 82 deletions src/test/mir-opt/issue_73223.main.PreCodegen.diff.64bit

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff.32bit
Original file line number Diff line number Diff line change
@@ -165,8 +165,20 @@
StorageLive(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
_17 = (*_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
StorageLive(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
_18 = (*_14); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
_16 = Eq(move _17, move _18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
_18 = const 1_i32; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000001))
// mir::Constant
// + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
_16 = Eq(move _17, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000001))
// mir::Constant
// + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
StorageDead(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
StorageDead(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
_15 = Not(move _16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
16 changes: 14 additions & 2 deletions src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff.64bit
Original file line number Diff line number Diff line change
@@ -165,8 +165,20 @@
StorageLive(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
_17 = (*_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
StorageLive(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
_18 = (*_14); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
_16 = Eq(move _17, move _18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
_18 = const 1_i32; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000001))
// mir::Constant
// + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
_16 = Eq(move _17, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000001))
// mir::Constant
// + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
StorageDead(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
StorageDead(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
_15 = Not(move _16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
Original file line number Diff line number Diff line change
@@ -39,13 +39,14 @@
}

bb1: {
_2 = const Dst::Foo(0_u8); // scope 1 at $DIR/simplify-arm-identity.rs:21:21: 21:32
((_2 as Foo).0: u8) = const 0_u8; // scope 1 at $DIR/simplify-arm-identity.rs:21:21: 21:32
// ty::Const
// + ty: Dst
// + ty: u8
// + val: Value(Scalar(0x00))
// mir::Constant
// + span: $DIR/simplify-arm-identity.rs:21:21: 21:32
// + literal: Const { ty: Dst, val: Value(Scalar(0x00)) }
// + span: $DIR/simplify-arm-identity.rs:21:30: 21:31
// + literal: Const { ty: u8, val: Value(Scalar(0x00)) }
discriminant(_2) = 0; // scope 1 at $DIR/simplify-arm-identity.rs:21:21: 21:32
goto -> bb4; // scope 1 at $DIR/simplify-arm-identity.rs:19:18: 22:6
}

Original file line number Diff line number Diff line change
@@ -39,13 +39,14 @@
}

bb1: {
_2 = const Dst::Foo(0_u8); // scope 1 at $DIR/simplify-arm-identity.rs:21:21: 21:32
((_2 as Foo).0: u8) = const 0_u8; // scope 1 at $DIR/simplify-arm-identity.rs:21:21: 21:32
// ty::Const
// + ty: Dst
// + ty: u8
// + val: Value(Scalar(0x00))
// mir::Constant
// + span: $DIR/simplify-arm-identity.rs:21:21: 21:32
// + literal: Const { ty: Dst, val: Value(Scalar(0x00)) }
// + span: $DIR/simplify-arm-identity.rs:21:30: 21:31
// + literal: Const { ty: u8, val: Value(Scalar(0x00)) }
discriminant(_2) = 0; // scope 1 at $DIR/simplify-arm-identity.rs:21:21: 21:32
goto -> bb4; // scope 1 at $DIR/simplify-arm-identity.rs:19:18: 22:6
}

Original file line number Diff line number Diff line change
@@ -22,58 +22,44 @@
bb0: {
- StorageLive(_1); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28
- StorageLive(_2); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23
- _2 = const (); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23
- StorageLive(_3); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27
- (_1.0: ()) = const (); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28
+ StorageLive(_1); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22
+ _1 = const use_zst(const ((), ())) -> bb1; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22
// ty::Const
- // + ty: ()
- // + val: Value(Scalar(<ZST>))
- // mir::Constant
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28
- // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
- StorageLive(_3); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27
- _3 = const (); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27
- (_1.1: ()) = const (); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28
- // ty::Const
- // + ty: ()
- // + val: Value(Scalar(<ZST>))
- // mir::Constant
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27
- // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
- _1 = const ((), ()); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28
- // ty::Const
- // + ty: ((), ())
- // + val: Value(Scalar(<ZST>))
- // mir::Constant
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28
- // + literal: Const { ty: ((), ()), val: Value(Scalar(<ZST>)) }
- // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
- StorageDead(_3); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:27: 13:28
- StorageDead(_2); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:27: 13:28
- StorageDead(_1); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:28: 13:29
- StorageLive(_4); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22
- StorageLive(_5); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21
- StorageLive(_6); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16
- _6 = const (); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16
- // ty::Const
- // + ty: ()
- // + val: Value(Scalar(<ZST>))
- // mir::Constant
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16
- // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
- StorageLive(_7); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20
- _7 = const (); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20
- (_5.0: ()) = const (); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21
- // ty::Const
- // + ty: ()
- // + val: Value(Scalar(<ZST>))
- // mir::Constant
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21
- // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
- _5 = const ((), ()); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21
- (_5.1: ()) = const (); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21
- // ty::Const
- // + ty: ((), ())
- // + ty: ()
- // + val: Value(Scalar(<ZST>))
- // mir::Constant
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21
- // + literal: Const { ty: ((), ()), val: Value(Scalar(<ZST>)) }
- // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
- StorageDead(_7); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:20: 14:21
- StorageDead(_6); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:20: 14:21
- _4 = const use_zst(const ((), ())) -> bb1; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22
@@ -98,16 +84,16 @@
- StorageLive(_9); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:34
- StorageLive(_10); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:30
- StorageLive(_11); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28
- _11 = const Temp { x: 40_u8 }; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28
- (_11.0: u8) = const 40_u8; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28
+ StorageDead(_1); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:22: 14:23
+ StorageLive(_2); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35
+ _2 = const use_u8(const 42_u8) -> bb2; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35
// ty::Const
- // + ty: Temp
- // + ty: u8
- // + val: Value(Scalar(0x28))
- // mir::Constant
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28
- // + literal: Const { ty: Temp, val: Value(Scalar(0x28)) }
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:16:23: 16:25
- // + literal: Const { ty: u8, val: Value(Scalar(0x28)) }
- _10 = const 40_u8; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:30
- // ty::Const
- // + ty: u8
Original file line number Diff line number Diff line change
@@ -39,13 +39,7 @@
}

bb2: {
_0 = const std::option::Option::<std::boxed::Box<()>>::None; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:17: 3:21
// ty::Const
// + ty: std::option::Option<std::boxed::Box<()>>
// + val: Value(Scalar(0x00000000))
// mir::Constant
// + span: $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:17: 3:21
// + literal: Const { ty: std::option::Option<std::boxed::Box<()>>, val: Value(Scalar(0x00000000)) }
discriminant(_0) = 0; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:17: 3:21
goto -> bb3; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:2:5: 5:6
}

Original file line number Diff line number Diff line change
@@ -39,13 +39,7 @@
}

bb2: {
_0 = const std::option::Option::<std::boxed::Box<()>>::None; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:17: 3:21
// ty::Const
// + ty: std::option::Option<std::boxed::Box<()>>
// + val: Value(Scalar(0x0000000000000000))
// mir::Constant
// + span: $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:17: 3:21
// + literal: Const { ty: std::option::Option<std::boxed::Box<()>>, val: Value(Scalar(0x0000000000000000)) }
discriminant(_0) = 0; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:17: 3:21
goto -> bb3; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:2:5: 5:6
}

Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ fn main() -> () {
bb0: {
StorageLive(_1); // scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6
StorageLive(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
_2 = Test1::C; // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
discriminant(_2) = 2; // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
_3 = discriminant(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20
StorageLive(_5); // scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24
_5 = const "C"; // scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24
@@ -31,7 +31,7 @@ fn main() -> () {
StorageDead(_1); // scope 0 at $DIR/uninhabited_enum_branching.rs:24:6: 24:7
StorageLive(_6); // scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6
StorageLive(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
_7 = Test2::D; // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
discriminant(_7) = 0; // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
_8 = discriminant(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17
switchInt(move _8) -> [4_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17
}
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
bb0: {
StorageLive(_1); // scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6
StorageLive(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
_2 = Test1::C; // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
discriminant(_2) = 2; // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
_3 = discriminant(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20
- switchInt(move _3) -> [0_isize: bb2, 1_isize: bb3, otherwise: bb1]; // scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20
+ switchInt(move _3) -> bb1; // scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20
@@ -66,7 +66,7 @@
StorageDead(_1); // scope 0 at $DIR/uninhabited_enum_branching.rs:24:6: 24:7
StorageLive(_6); // scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6
StorageLive(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
_7 = Test2::D; // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
discriminant(_7) = 0; // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
_8 = discriminant(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17
switchInt(move _8) -> [4_isize: bb6, otherwise: bb5]; // scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
- // MIR for `change_loop_body` before ConstProp
+ // MIR for `change_loop_body` after ConstProp

fn change_loop_body() -> () {
let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:5:27: 5:27
let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
let mut _2: (); // in scope 0 at $DIR/while_let_loops.rs:5:1: 11:2
let mut _3: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:7:28: 7:32
let mut _4: isize; // in scope 0 at $DIR/while_let_loops.rs:7:15: 7:25
let mut _5: !; // in scope 0 at $DIR/while_let_loops.rs:7:33: 10:6
let mut _6: !; // in scope 0 at $DIR/while_let_loops.rs:7:5: 10:6
scope 1 {
debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:6:9: 6:15
}

bb0: {
StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
_1 = const 0_i32; // scope 0 at $DIR/while_let_loops.rs:6:18: 6:19
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000000))
// mir::Constant
// + span: $DIR/while_let_loops.rs:6:18: 6:19
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
StorageLive(_3); // scope 1 at $DIR/while_let_loops.rs:7:28: 7:32
discriminant(_3) = 0; // scope 1 at $DIR/while_let_loops.rs:7:28: 7:32
- _4 = discriminant(_3); // scope 1 at $DIR/while_let_loops.rs:7:15: 7:25
- switchInt(move _4) -> [1_isize: bb2, otherwise: bb1]; // scope 1 at $DIR/while_let_loops.rs:7:15: 7:25
+ _4 = const 0_isize; // scope 1 at $DIR/while_let_loops.rs:7:15: 7:25
+ // ty::Const
+ // + ty: isize
+ // + val: Value(Scalar(0x00000000))
+ // mir::Constant
+ // + span: $DIR/while_let_loops.rs:7:15: 7:25
+ // + literal: Const { ty: isize, val: Value(Scalar(0x00000000)) }
+ switchInt(const 0_isize) -> [1_isize: bb2, otherwise: bb1]; // scope 1 at $DIR/while_let_loops.rs:7:15: 7:25
+ // ty::Const
+ // + ty: isize
+ // + val: Value(Scalar(0x00000000))
+ // mir::Constant
+ // + span: $DIR/while_let_loops.rs:7:15: 7:25
+ // + literal: Const { ty: isize, val: Value(Scalar(0x00000000)) }
}

bb1: {
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/while_let_loops.rs:7:5: 10:6
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
goto -> bb4; // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6
}

bb2: {
switchInt(((_3 as Some).0: u32)) -> [0_u32: bb3, otherwise: bb1]; // scope 1 at $DIR/while_let_loops.rs:7:20: 7:24
}

bb3: {
_1 = const 1_i32; // scope 1 at $DIR/while_let_loops.rs:8:9: 8:15
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000001))
// mir::Constant
// + span: $DIR/while_let_loops.rs:8:14: 8:15
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:9:9: 9:14
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/while_let_loops.rs:9:9: 9:14
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
goto -> bb4; // scope 1 at $DIR/while_let_loops.rs:9:9: 9:14
}

bb4: {
StorageDead(_3); // scope 1 at $DIR/while_let_loops.rs:10:5: 10:6
StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:11:1: 11:2
return; // scope 0 at $DIR/while_let_loops.rs:11:2: 11:2
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
- // MIR for `change_loop_body` before ConstProp
+ // MIR for `change_loop_body` after ConstProp

fn change_loop_body() -> () {
let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:5:27: 5:27
let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
let mut _2: (); // in scope 0 at $DIR/while_let_loops.rs:5:1: 11:2
let mut _3: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:7:28: 7:32
let mut _4: isize; // in scope 0 at $DIR/while_let_loops.rs:7:15: 7:25
let mut _5: !; // in scope 0 at $DIR/while_let_loops.rs:7:33: 10:6
let mut _6: !; // in scope 0 at $DIR/while_let_loops.rs:7:5: 10:6
scope 1 {
debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:6:9: 6:15
}

bb0: {
StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
_1 = const 0_i32; // scope 0 at $DIR/while_let_loops.rs:6:18: 6:19
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000000))
// mir::Constant
// + span: $DIR/while_let_loops.rs:6:18: 6:19
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
StorageLive(_3); // scope 1 at $DIR/while_let_loops.rs:7:28: 7:32
discriminant(_3) = 0; // scope 1 at $DIR/while_let_loops.rs:7:28: 7:32
- _4 = discriminant(_3); // scope 1 at $DIR/while_let_loops.rs:7:15: 7:25
- switchInt(move _4) -> [1_isize: bb2, otherwise: bb1]; // scope 1 at $DIR/while_let_loops.rs:7:15: 7:25
+ _4 = const 0_isize; // scope 1 at $DIR/while_let_loops.rs:7:15: 7:25
+ // ty::Const
+ // + ty: isize
+ // + val: Value(Scalar(0x0000000000000000))
+ // mir::Constant
+ // + span: $DIR/while_let_loops.rs:7:15: 7:25
+ // + literal: Const { ty: isize, val: Value(Scalar(0x0000000000000000)) }
+ switchInt(const 0_isize) -> [1_isize: bb2, otherwise: bb1]; // scope 1 at $DIR/while_let_loops.rs:7:15: 7:25
+ // ty::Const
+ // + ty: isize
+ // + val: Value(Scalar(0x0000000000000000))
+ // mir::Constant
+ // + span: $DIR/while_let_loops.rs:7:15: 7:25
+ // + literal: Const { ty: isize, val: Value(Scalar(0x0000000000000000)) }
}

bb1: {
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/while_let_loops.rs:7:5: 10:6
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
goto -> bb4; // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6
}

bb2: {
switchInt(((_3 as Some).0: u32)) -> [0_u32: bb3, otherwise: bb1]; // scope 1 at $DIR/while_let_loops.rs:7:20: 7:24
}

bb3: {
_1 = const 1_i32; // scope 1 at $DIR/while_let_loops.rs:8:9: 8:15
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000001))
// mir::Constant
// + span: $DIR/while_let_loops.rs:8:14: 8:15
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:9:9: 9:14
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/while_let_loops.rs:9:9: 9:14
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
goto -> bb4; // scope 1 at $DIR/while_let_loops.rs:9:9: 9:14
}

bb4: {
StorageDead(_3); // scope 1 at $DIR/while_let_loops.rs:10:5: 10:6
StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:11:1: 11:2
return; // scope 0 at $DIR/while_let_loops.rs:11:2: 11:2
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// MIR for `change_loop_body` after PreCodegen

fn change_loop_body() -> () {
let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:5:27: 5:27
let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
let mut _2: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:7:28: 7:32
scope 1 {
debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:6:9: 6:15
}

bb0: {
StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
_1 = const 0_i32; // scope 0 at $DIR/while_let_loops.rs:6:18: 6:19
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000000))
// mir::Constant
// + span: $DIR/while_let_loops.rs:6:18: 6:19
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
StorageLive(_2); // scope 1 at $DIR/while_let_loops.rs:7:28: 7:32
discriminant(_2) = 0; // scope 1 at $DIR/while_let_loops.rs:7:28: 7:32
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/while_let_loops.rs:7:5: 10:6
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
StorageDead(_2); // scope 1 at $DIR/while_let_loops.rs:10:5: 10:6
StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:11:1: 11:2
return; // scope 0 at $DIR/while_let_loops.rs:11:2: 11:2
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// MIR for `change_loop_body` after PreCodegen

fn change_loop_body() -> () {
let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:5:27: 5:27
let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
let mut _2: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:7:28: 7:32
scope 1 {
debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:6:9: 6:15
}

bb0: {
StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
_1 = const 0_i32; // scope 0 at $DIR/while_let_loops.rs:6:18: 6:19
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000000))
// mir::Constant
// + span: $DIR/while_let_loops.rs:6:18: 6:19
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
StorageLive(_2); // scope 1 at $DIR/while_let_loops.rs:7:28: 7:32
discriminant(_2) = 0; // scope 1 at $DIR/while_let_loops.rs:7:28: 7:32
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/while_let_loops.rs:7:5: 10:6
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
StorageDead(_2); // scope 1 at $DIR/while_let_loops.rs:10:5: 10:6
StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:11:1: 11:2
return; // scope 0 at $DIR/while_let_loops.rs:11:2: 11:2
}
}
15 changes: 15 additions & 0 deletions src/test/mir-opt/while_let_loops.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// EMIT_MIR while_let_loops.change_loop_body.ConstProp.diff
// EMIT_MIR while_let_loops.change_loop_body.PreCodegen.after.mir
// EMIT_MIR_FOR_EACH_BIT_WIDTH

pub fn change_loop_body() {
let mut _x = 0;
while let Some(0u32) = None {
_x = 1;
break;
}
}

fn main() {
change_loop_body();
}