1
Fork 0

Make ConstProp tests unit.

This commit is contained in:
Camille GILLOT 2023-05-01 11:18:41 +00:00
parent 98c33e47a4
commit a4ef2f5fca
27 changed files with 177 additions and 106 deletions

View file

@ -18,29 +18,35 @@
} }
bb0: { bb0: {
StorageLive(_1); // scope 0 at $DIR/bad_op_mod_by_zero.rs:+1:9: +1:10
_1 = const 0_i32; // scope 0 at $DIR/bad_op_mod_by_zero.rs:+1:13: +1:14 _1 = const 0_i32; // scope 0 at $DIR/bad_op_mod_by_zero.rs:+1:13: +1:14
StorageLive(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:9: +2:11 StorageLive(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:9: +2:11
- _4 = Eq(_1, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 StorageLive(_3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19
- _3 = _1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19
- _4 = Eq(_3, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
- assert(!move _4, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - assert(!move _4, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
+ _3 = const 0_i32; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19
+ _4 = const true; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + _4 = const true; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
+ assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
} }
bb1: { bb1: {
- _5 = Eq(_1, const -1_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - _5 = Eq(_3, const -1_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
- _6 = Eq(const 1_i32, const i32::MIN); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - _6 = Eq(const 1_i32, const i32::MIN); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
- _7 = BitAnd(move _5, move _6); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - _7 = BitAnd(move _5, move _6); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
- assert(!move _7, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _1) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - assert(!move _7, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
+ _5 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + _5 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
+ _6 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + _6 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
+ _7 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + _7 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
+ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, const 0_i32) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
} }
bb2: { bb2: {
- _2 = Rem(const 1_i32, _1); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 _2 = Rem(const 1_i32, move _3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
+ _2 = Rem(const 1_i32, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 StorageDead(_3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19
_0 = const (); // scope 0 at $DIR/bad_op_mod_by_zero.rs:+0:11: +3:2
StorageDead(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+3:1: +3:2 StorageDead(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+3:1: +3:2
StorageDead(_1); // scope 0 at $DIR/bad_op_mod_by_zero.rs:+3:1: +3:2
return; // scope 0 at $DIR/bad_op_mod_by_zero.rs:+3:2: +3:2 return; // scope 0 at $DIR/bad_op_mod_by_zero.rs:+3:2: +3:2
} }
} }

View file

@ -1,3 +1,4 @@
// unit-test: ConstProp
// ignore-wasm32 compiled with panic=abort by default // ignore-wasm32 compiled with panic=abort by default
// EMIT_MIR bad_op_mod_by_zero.main.ConstProp.diff // EMIT_MIR bad_op_mod_by_zero.main.ConstProp.diff
#[allow(unconditional_panic)] #[allow(unconditional_panic)]

View file

@ -6,16 +6,17 @@
let _1: *const [i32]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 let _1: *const [i32]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10
let mut _2: *const [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 let mut _2: *const [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
let _3: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 let _3: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
let _5: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 let _4: [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:26: +1:35
let mut _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 let _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
let mut _7: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 let mut _7: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
let mut _8: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 let mut _8: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
let mut _9: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
scope 1 { scope 1 {
debug a => _1; // in scope 1 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 debug a => _1; // in scope 1 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10
scope 2 { scope 2 {
let _4: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 let _5: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
scope 3 { scope 3 {
debug _b => _4; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 debug _b => _5; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
} }
} }
} }
@ -23,27 +24,31 @@
bb0: { bb0: {
StorageLive(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 StorageLive(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10
StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
_8 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 StorageLive(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
_9 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
// mir::Constant // mir::Constant
// + span: $DIR/bad_op_unsafe_oob_for_slices.rs:6:25: 6:35 // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:9:25: 9:35
// + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) } // + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) }
_2 = &raw const (*_8); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _3 = &(*_9); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
_2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
_1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
StorageDead(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:34: +1:35 StorageDead(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:34: +1:35
StorageLive(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 StorageDead(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:35: +1:36
StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
_5 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 StorageLive(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
_6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 _6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
- _7 = Lt(_5, _6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 _7 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - _8 = Lt(_6, _7); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
+ _7 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
+ assert(const false, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 3_usize) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + _8 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
+ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
} }
bb1: { bb1: {
_4 = (*_1)[_5]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 _5 = (*_1)[_6]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26 StorageDead(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26
StorageDead(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6 _0 = const (); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+2:5: +4:6
StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6
StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:1: +5:2 StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:1: +5:2
return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:2: +5:2 return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:2: +5:2
} }

View file

@ -6,16 +6,17 @@
let _1: *const [i32]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 let _1: *const [i32]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10
let mut _2: *const [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 let mut _2: *const [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
let _3: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 let _3: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
let _5: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 let _4: [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:26: +1:35
let mut _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 let _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
let mut _7: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 let mut _7: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
let mut _8: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 let mut _8: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
let mut _9: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
scope 1 { scope 1 {
debug a => _1; // in scope 1 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 debug a => _1; // in scope 1 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10
scope 2 { scope 2 {
let _4: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 let _5: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
scope 3 { scope 3 {
debug _b => _4; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 debug _b => _5; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
} }
} }
} }
@ -23,27 +24,31 @@
bb0: { bb0: {
StorageLive(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 StorageLive(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10
StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
_8 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 StorageLive(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
_9 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
// mir::Constant // mir::Constant
// + span: $DIR/bad_op_unsafe_oob_for_slices.rs:6:25: 6:35 // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:9:25: 9:35
// + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) } // + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) }
_2 = &raw const (*_8); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _3 = &(*_9); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
_2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
_1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
StorageDead(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:34: +1:35 StorageDead(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:34: +1:35
StorageLive(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 StorageDead(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:35: +1:36
StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
_5 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 StorageLive(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
_6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 _6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
- _7 = Lt(_5, _6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 _7 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - _8 = Lt(_6, _7); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
+ _7 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
+ assert(const false, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 3_usize) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + _8 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
+ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
} }
bb1: { bb1: {
_4 = (*_1)[_5]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 _5 = (*_1)[_6]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26 StorageDead(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26
StorageDead(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6 _0 = const (); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+2:5: +4:6
StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6
StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:1: +5:2 StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:1: +5:2
return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:2: +5:2 return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:2: +5:2
} }

View file

@ -1,4 +1,7 @@
// unit-test: ConstProp
// ignore-wasm32 compiled with panic=abort by default // ignore-wasm32 compiled with panic=abort by default
// compile-flags: -Zmir-enable-passes=+NormalizeArrayLen
// EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR bad_op_unsafe_oob_for_slices.main.ConstProp.diff // EMIT_MIR bad_op_unsafe_oob_for_slices.main.ConstProp.diff
#[allow(unconditional_panic)] #[allow(unconditional_panic)]

View file

@ -7,13 +7,17 @@
let mut _2: main::InvalidChar; // in scope 0 at $DIR/invalid_constant.rs:+6:34: +6:63 let mut _2: main::InvalidChar; // in scope 0 at $DIR/invalid_constant.rs:+6:34: +6:63
let mut _4: E; // in scope 0 at $DIR/invalid_constant.rs:+13:25: +13:59 let mut _4: E; // in scope 0 at $DIR/invalid_constant.rs:+13:25: +13:59
let mut _5: main::InvalidTag; // in scope 0 at $DIR/invalid_constant.rs:+13:34: +13:55 let mut _5: main::InvalidTag; // in scope 0 at $DIR/invalid_constant.rs:+13:34: +13:55
let mut _7: Empty; // in scope 0 at $DIR/invalid_constant.rs:+20:35: +20:73
let mut _8: main::NoVariants; // in scope 0 at $DIR/invalid_constant.rs:+20:44: +20:65
scope 1 { scope 1 {
debug _invalid_char => _1; // in scope 1 at $DIR/invalid_constant.rs:+6:9: +6:22 debug _invalid_char => _1; // in scope 1 at $DIR/invalid_constant.rs:+6:9: +6:22
let _3: [E; 1]; // in scope 1 at $DIR/invalid_constant.rs:+13:9: +13:21 let _3: [E; 1]; // in scope 1 at $DIR/invalid_constant.rs:+13:9: +13:21
scope 3 { scope 3 {
debug _invalid_tag => _3; // in scope 3 at $DIR/invalid_constant.rs:+13:9: +13:21 debug _invalid_tag => _3; // in scope 3 at $DIR/invalid_constant.rs:+13:9: +13:21
let _6: [Empty; 1]; // in scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31
scope 5 { scope 5 {
debug _enum_without_variants => const [ZeroSized: Empty]; // in scope 5 at $DIR/invalid_constant.rs:+20:9: +20:31 debug _enum_without_variants => const [ZeroSized: Empty]; // in scope 5 at $DIR/invalid_constant.rs:+20:9: +20:31
let _9: main::Str<"<22><><EFBFBD>">; // in scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22
scope 7 { scope 7 {
debug _non_utf8_str => const Str::<"<22><><EFBFBD>">; // in scope 7 at $DIR/invalid_constant.rs:+24:9: +24:22 debug _non_utf8_str => const Str::<"<22><><EFBFBD>">; // in scope 7 at $DIR/invalid_constant.rs:+24:9: +24:22
} }
@ -39,17 +43,25 @@
StorageLive(_5); // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55 StorageLive(_5); // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55
_5 = InvalidTag { int: const 4_u32 }; // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55 _5 = InvalidTag { int: const 4_u32 }; // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55
- _4 = (_5.1: E); // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:57 - _4 = (_5.1: E); // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:57
- _3 = [move _4]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60
+ _4 = const Scalar(0x00000004): E; // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:57 + _4 = const Scalar(0x00000004): E; // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:57
+ // mir::Constant + // mir::Constant
+ // + span: no-location + // + span: no-location
+ // + literal: Const { ty: E, val: Value(Scalar(0x00000004)) } + // + literal: Const { ty: E, val: Value(Scalar(0x00000004)) }
+ _3 = [const Scalar(0x00000004): E]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60 _3 = [move _4]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60
+ // mir::Constant
+ // + span: no-location
+ // + literal: Const { ty: E, val: Value(Scalar(0x00000004)) }
StorageDead(_4); // scope 1 at $DIR/invalid_constant.rs:+13:59: +13:60 StorageDead(_4); // scope 1 at $DIR/invalid_constant.rs:+13:59: +13:60
StorageDead(_5); // scope 1 at $DIR/invalid_constant.rs:+13:60: +13:61 StorageDead(_5); // scope 1 at $DIR/invalid_constant.rs:+13:60: +13:61
nop; // scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31
nop; // scope 3 at $DIR/invalid_constant.rs:+20:35: +20:73
StorageLive(_8); // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65
_8 = NoVariants { int: const 0_u32 }; // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65
nop; // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:71
nop; // scope 3 at $DIR/invalid_constant.rs:+20:34: +20:74
nop; // scope 3 at $DIR/invalid_constant.rs:+20:73: +20:74
StorageDead(_8); // scope 3 at $DIR/invalid_constant.rs:+20:74: +20:75
nop; // scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22
nop; // scope 0 at $DIR/invalid_constant.rs:+0:11: +27:2
nop; // scope 5 at $DIR/invalid_constant.rs:+27:1: +27:2
nop; // scope 3 at $DIR/invalid_constant.rs:+27:1: +27:2
StorageDead(_3); // scope 1 at $DIR/invalid_constant.rs:+27:1: +27:2 StorageDead(_3); // scope 1 at $DIR/invalid_constant.rs:+27:1: +27:2
StorageDead(_1); // scope 0 at $DIR/invalid_constant.rs:+27:1: +27:2 StorageDead(_1); // scope 0 at $DIR/invalid_constant.rs:+27:1: +27:2
return; // scope 0 at $DIR/invalid_constant.rs:+27:2: +27:2 return; // scope 0 at $DIR/invalid_constant.rs:+27:2: +27:2

View file

@ -1,3 +1,5 @@
// unit-test: ConstProp
// compile-flags: -Zmir-enable-passes=+RemoveZsts
// Verify that we can pretty print invalid constants. // Verify that we can pretty print invalid constants.
#![feature(adt_const_params)] #![feature(adt_const_params)]

View file

@ -18,17 +18,19 @@
_2 = [const 0_u8; 5000]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:29 _2 = [const 0_u8; 5000]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:29
StorageLive(_3); // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31 StorageLive(_3); // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31
_3 = const 2_usize; // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31 _3 = const 2_usize; // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31
_4 = const 5000_usize; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - _4 = Len(_2); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
- _5 = Lt(_3, _4); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - _5 = Lt(_3, _4); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
+ _4 = const 5000_usize; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
+ _5 = const true; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 + _5 = const true; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 + assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
} }
bb1: { bb1: {
_1 = _2[_3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 _1 = _2[_3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
StorageDead(_3); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33 StorageDead(_3); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33
StorageDead(_2); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33 StorageDead(_2); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33
_0 = const (); // scope 0 at $DIR/large_array_index.rs:+0:11: +3:2
StorageDead(_1); // scope 0 at $DIR/large_array_index.rs:+3:1: +3:2 StorageDead(_1); // scope 0 at $DIR/large_array_index.rs:+3:1: +3:2
return; // scope 0 at $DIR/large_array_index.rs:+3:2: +3:2 return; // scope 0 at $DIR/large_array_index.rs:+3:2: +3:2
} }

View file

@ -18,17 +18,19 @@
_2 = [const 0_u8; 5000]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:29 _2 = [const 0_u8; 5000]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:29
StorageLive(_3); // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31 StorageLive(_3); // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31
_3 = const 2_usize; // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31 _3 = const 2_usize; // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31
_4 = const 5000_usize; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - _4 = Len(_2); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
- _5 = Lt(_3, _4); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - _5 = Lt(_3, _4); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
+ _4 = const 5000_usize; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
+ _5 = const true; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 + _5 = const true; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 + assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
} }
bb1: { bb1: {
_1 = _2[_3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 _1 = _2[_3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
StorageDead(_3); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33 StorageDead(_3); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33
StorageDead(_2); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33 StorageDead(_2); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33
_0 = const (); // scope 0 at $DIR/large_array_index.rs:+0:11: +3:2
StorageDead(_1); // scope 0 at $DIR/large_array_index.rs:+3:1: +3:2 StorageDead(_1); // scope 0 at $DIR/large_array_index.rs:+3:1: +3:2
return; // scope 0 at $DIR/large_array_index.rs:+3:2: +3:2 return; // scope 0 at $DIR/large_array_index.rs:+3:2: +3:2
} }

View file

@ -1,4 +1,6 @@
// unit-test: ConstProp
// ignore-wasm32 compiled with panic=abort by default // ignore-wasm32 compiled with panic=abort by default
// compile-flags: -Zmir-enable-passes=+NormalizeArrayLen
// EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR large_array_index.main.ConstProp.diff // EMIT_MIR large_array_index.main.ConstProp.diff

View file

@ -3,21 +3,26 @@
fn main() -> () { fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/reify_fn_ptr.rs:+0:11: +0:11 let mut _0: (); // return place in scope 0 at $DIR/reify_fn_ptr.rs:+0:11: +0:11
let mut _1: usize; // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 let mut _1: *const fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:41
let mut _2: fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 let mut _2: usize; // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26
let mut _3: fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17
scope 1 { scope 1 {
} }
bb0: { bb0: {
StorageLive(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 StorageLive(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:41
StorageLive(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 StorageLive(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26
_2 = main as fn() (Pointer(ReifyFnPointer)); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 StorageLive(_3); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17
_3 = main as fn() (Pointer(ReifyFnPointer)); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17
// mir::Constant // mir::Constant
// + span: $DIR/reify_fn_ptr.rs:4:13: 4:17 // + span: $DIR/reify_fn_ptr.rs:5:13: 5:17
// + literal: Const { ty: fn() {main}, val: Value(<ZST>) } // + literal: Const { ty: fn() {main}, val: Value(<ZST>) }
_1 = move _2 as usize (PointerExposeAddress); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 _2 = move _3 as usize (PointerExposeAddress); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26
StorageDead(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:25: +1:26 StorageDead(_3); // scope 0 at $DIR/reify_fn_ptr.rs:+1:25: +1:26
StorageDead(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:40: +1:41 _1 = move _2 as *const fn() (PointerFromExposedAddress); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:41
StorageDead(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:40: +1:41
StorageDead(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:41: +1:42
_0 = const (); // scope 0 at $DIR/reify_fn_ptr.rs:+0:11: +2:2
return; // scope 0 at $DIR/reify_fn_ptr.rs:+2:2: +2:2 return; // scope 0 at $DIR/reify_fn_ptr.rs:+2:2: +2:2
} }
} }

View file

@ -1,3 +1,4 @@
// unit-test: ConstProp
// EMIT_MIR reify_fn_ptr.main.ConstProp.diff // EMIT_MIR reify_fn_ptr.main.ConstProp.diff
fn main() { fn main() {

View file

@ -20,11 +20,12 @@
_3 = [const 42_u32; 8]; // scope 0 at $DIR/repeat.rs:+1:18: +1:25 _3 = [const 42_u32; 8]; // scope 0 at $DIR/repeat.rs:+1:18: +1:25
StorageLive(_4); // scope 0 at $DIR/repeat.rs:+1:26: +1:27 StorageLive(_4); // scope 0 at $DIR/repeat.rs:+1:26: +1:27
_4 = const 2_usize; // scope 0 at $DIR/repeat.rs:+1:26: +1:27 _4 = const 2_usize; // scope 0 at $DIR/repeat.rs:+1:26: +1:27
_5 = const 8_usize; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 - _5 = Len(_3); // scope 0 at $DIR/repeat.rs:+1:18: +1:28
- _6 = Lt(_4, _5); // scope 0 at $DIR/repeat.rs:+1:18: +1:28 - _6 = Lt(_4, _5); // scope 0 at $DIR/repeat.rs:+1:18: +1:28
- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 - assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
+ _5 = const 8_usize; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
+ _6 = const true; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 + _6 = const true; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 + assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
} }
bb1: { bb1: {
@ -35,6 +36,7 @@
StorageDead(_2); // scope 0 at $DIR/repeat.rs:+1:31: +1:32 StorageDead(_2); // scope 0 at $DIR/repeat.rs:+1:31: +1:32
StorageDead(_4); // scope 0 at $DIR/repeat.rs:+1:32: +1:33 StorageDead(_4); // scope 0 at $DIR/repeat.rs:+1:32: +1:33
StorageDead(_3); // scope 0 at $DIR/repeat.rs:+1:32: +1:33 StorageDead(_3); // scope 0 at $DIR/repeat.rs:+1:32: +1:33
_0 = const (); // scope 0 at $DIR/repeat.rs:+0:11: +2:2
StorageDead(_1); // scope 0 at $DIR/repeat.rs:+2:1: +2:2 StorageDead(_1); // scope 0 at $DIR/repeat.rs:+2:1: +2:2
return; // scope 0 at $DIR/repeat.rs:+2:2: +2:2 return; // scope 0 at $DIR/repeat.rs:+2:2: +2:2
} }

View file

@ -20,11 +20,12 @@
_3 = [const 42_u32; 8]; // scope 0 at $DIR/repeat.rs:+1:18: +1:25 _3 = [const 42_u32; 8]; // scope 0 at $DIR/repeat.rs:+1:18: +1:25
StorageLive(_4); // scope 0 at $DIR/repeat.rs:+1:26: +1:27 StorageLive(_4); // scope 0 at $DIR/repeat.rs:+1:26: +1:27
_4 = const 2_usize; // scope 0 at $DIR/repeat.rs:+1:26: +1:27 _4 = const 2_usize; // scope 0 at $DIR/repeat.rs:+1:26: +1:27
_5 = const 8_usize; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 - _5 = Len(_3); // scope 0 at $DIR/repeat.rs:+1:18: +1:28
- _6 = Lt(_4, _5); // scope 0 at $DIR/repeat.rs:+1:18: +1:28 - _6 = Lt(_4, _5); // scope 0 at $DIR/repeat.rs:+1:18: +1:28
- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 - assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
+ _5 = const 8_usize; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
+ _6 = const true; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 + _6 = const true; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 + assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
} }
bb1: { bb1: {
@ -35,6 +36,7 @@
StorageDead(_2); // scope 0 at $DIR/repeat.rs:+1:31: +1:32 StorageDead(_2); // scope 0 at $DIR/repeat.rs:+1:31: +1:32
StorageDead(_4); // scope 0 at $DIR/repeat.rs:+1:32: +1:33 StorageDead(_4); // scope 0 at $DIR/repeat.rs:+1:32: +1:33
StorageDead(_3); // scope 0 at $DIR/repeat.rs:+1:32: +1:33 StorageDead(_3); // scope 0 at $DIR/repeat.rs:+1:32: +1:33
_0 = const (); // scope 0 at $DIR/repeat.rs:+0:11: +2:2
StorageDead(_1); // scope 0 at $DIR/repeat.rs:+2:1: +2:2 StorageDead(_1); // scope 0 at $DIR/repeat.rs:+2:1: +2:2
return; // scope 0 at $DIR/repeat.rs:+2:2: +2:2 return; // scope 0 at $DIR/repeat.rs:+2:2: +2:2
} }

View file

@ -1,7 +1,8 @@
// unit-test: ConstProp
// ignore-wasm32 compiled with panic=abort by default // ignore-wasm32 compiled with panic=abort by default
// compile-flags: -O // compile-flags: -Zmir-enable-passes=+NormalizeArrayLen
// EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR repeat.main.ConstProp.diff // EMIT_MIR repeat.main.ConstProp.diff
fn main() { fn main() {
let x: u32 = [42; 8][2] + 0; let x: u32 = [42; 8][2] + 0;

View file

@ -2,8 +2,14 @@
fn add() -> u32 { fn add() -> u32 {
let mut _0: u32; // return place in scope 0 at $DIR/return_place.rs:+0:13: +0:16 let mut _0: u32; // return place in scope 0 at $DIR/return_place.rs:+0:13: +0:16
let mut _1: (u32, bool); // in scope 0 at $DIR/return_place.rs:+1:5: +1:10
bb0: { bb0: {
_1 = const (4_u32, false); // scope 0 at $DIR/return_place.rs:+1:5: +1:10
assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> bb1; // scope 0 at $DIR/return_place.rs:+1:5: +1:10
}
bb1: {
_0 = const 4_u32; // scope 0 at $DIR/return_place.rs:+1:5: +1:10 _0 = const 4_u32; // scope 0 at $DIR/return_place.rs:+1:5: +1:10
return; // scope 0 at $DIR/return_place.rs:+2:2: +2:2 return; // scope 0 at $DIR/return_place.rs:+2:2: +2:2
} }

View file

@ -1,3 +1,4 @@
// unit-test: ConstProp
// ignore-wasm32 compiled with panic=abort by default // ignore-wasm32 compiled with panic=abort by default
// compile-flags: -C overflow-checks=on // compile-flags: -C overflow-checks=on

View file

@ -11,15 +11,23 @@
} }
bb0: { bb0: {
StorageLive(_1); // scope 0 at $DIR/scalar_literal_propagation.rs:+1:9: +1:10
_1 = const 1_u32; // scope 0 at $DIR/scalar_literal_propagation.rs:+1:13: +1:14 _1 = const 1_u32; // scope 0 at $DIR/scalar_literal_propagation.rs:+1:13: +1:14
- _2 = consume(_1) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 StorageLive(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15
+ _2 = consume(const 1_u32) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 StorageLive(_3); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14
- _3 = _1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14
+ _3 = const 1_u32; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14
_2 = consume(move _3) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15
// mir::Constant // mir::Constant
// + span: $DIR/scalar_literal_propagation.rs:5:5: 5:12 // + span: $DIR/scalar_literal_propagation.rs:6:5: 6:12
// + literal: Const { ty: fn(u32) {consume}, val: Value(<ZST>) } // + literal: Const { ty: fn(u32) {consume}, val: Value(<ZST>) }
} }
bb1: { bb1: {
StorageDead(_3); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:14: +2:15
StorageDead(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:15: +2:16
_0 = const (); // scope 0 at $DIR/scalar_literal_propagation.rs:+0:11: +3:2
StorageDead(_1); // scope 0 at $DIR/scalar_literal_propagation.rs:+3:1: +3:2
return; // scope 0 at $DIR/scalar_literal_propagation.rs:+3:2: +3:2 return; // scope 0 at $DIR/scalar_literal_propagation.rs:+3:2: +3:2
} }
} }

View file

@ -1,3 +1,4 @@
// unit-test: ConstProp
// ignore-wasm32 compiled with panic=abort by default // ignore-wasm32 compiled with panic=abort by default
// EMIT_MIR scalar_literal_propagation.main.ConstProp.diff // EMIT_MIR scalar_literal_propagation.main.ConstProp.diff
fn main() { fn main() {

View file

@ -15,14 +15,14 @@
bb1: { bb1: {
_0 = foo(const -1_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+3:14: +3:21 _0 = foo(const -1_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+3:14: +3:21
// mir::Constant // mir::Constant
// + span: $DIR/switch_int.rs:10:14: 10:17 // + span: $DIR/switch_int.rs:12:14: 12:17
// + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) }
} }
bb2: { bb2: {
_0 = foo(const 0_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+2:14: +2:20 _0 = foo(const 0_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+2:14: +2:20
// mir::Constant // mir::Constant
// + span: $DIR/switch_int.rs:9:14: 9:17 // + span: $DIR/switch_int.rs:11:14: 11:17
// + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) }
} }

View file

@ -15,14 +15,14 @@
bb1: { bb1: {
_0 = foo(const -1_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+3:14: +3:21 _0 = foo(const -1_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+3:14: +3:21
// mir::Constant // mir::Constant
// + span: $DIR/switch_int.rs:10:14: 10:17 // + span: $DIR/switch_int.rs:12:14: 12:17
// + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) }
} }
bb2: { bb2: {
_0 = foo(const 0_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+2:14: +2:20 _0 = foo(const 0_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+2:14: +2:20
// mir::Constant // mir::Constant
// + span: $DIR/switch_int.rs:9:14: 9:17 // + span: $DIR/switch_int.rs:11:14: 11:17
// + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) }
} }

View file

@ -1,3 +1,5 @@
// unit-test: ConstProp
// compile-flags: -Zmir-enable-passes=+SimplifyConstCondition-after-const-prop
// ignore-wasm32 compiled with panic=abort by default // ignore-wasm32 compiled with panic=abort by default
#[inline(never)] #[inline(never)]
fn foo(_: i32) { } fn foo(_: i32) { }

View file

@ -11,15 +11,24 @@
} }
bb0: { bb0: {
StorageLive(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:9: +1:10
- _1 = (const 1_u32, const 2_u32); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19 - _1 = (const 1_u32, const 2_u32); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19
+ _1 = const (1_u32, 2_u32); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19 + _1 = const (1_u32, 2_u32); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19
_2 = consume(_1) -> bb1; // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15 StorageLive(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15
StorageLive(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14
- _3 = _1; // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14
+ _3 = const (1_u32, 2_u32); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14
_2 = consume(move _3) -> bb1; // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15
// mir::Constant // mir::Constant
// + span: $DIR/tuple_literal_propagation.rs:6:5: 6:12 // + span: $DIR/tuple_literal_propagation.rs:7:5: 7:12
// + literal: Const { ty: fn((u32, u32)) {consume}, val: Value(<ZST>) } // + literal: Const { ty: fn((u32, u32)) {consume}, val: Value(<ZST>) }
} }
bb1: { bb1: {
StorageDead(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:14: +3:15
StorageDead(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:15: +3:16
_0 = const (); // scope 0 at $DIR/tuple_literal_propagation.rs:+0:11: +4:2
StorageDead(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:+4:1: +4:2
return; // scope 0 at $DIR/tuple_literal_propagation.rs:+4:2: +4:2 return; // scope 0 at $DIR/tuple_literal_propagation.rs:+4:2: +4:2
} }
} }

View file

@ -1,3 +1,4 @@
// unit-test: ConstProp
// ignore-wasm32 compiled with panic=abort by default // ignore-wasm32 compiled with panic=abort by default
// EMIT_MIR tuple_literal_propagation.main.ConstProp.diff // EMIT_MIR tuple_literal_propagation.main.ConstProp.diff
fn main() { fn main() {

View file

@ -4,8 +4,13 @@
fn change_loop_body() -> () { fn change_loop_body() -> () {
let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:+0:27: +0:27 let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:+0:27: +0:27
let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:+1:9: +1:15 let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:+1:9: +1:15
let mut _2: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:+2:28: +2:32 let mut _2: (); // in scope 0 at $DIR/while_let_loops.rs:+0:1: +6:2
let mut _3: isize; // in scope 0 at $DIR/while_let_loops.rs:+2:15: +2:25 let mut _3: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:+2:28: +2:32
let mut _4: isize; // in scope 0 at $DIR/while_let_loops.rs:+2:15: +2:25
let mut _5: !; // in scope 0 at $DIR/while_let_loops.rs:+2:33: +5:6
let mut _6: !; // in scope 0 at $DIR/while_let_loops.rs:+2:5: +5:6
let _7: (); // in scope 0 at $DIR/while_let_loops.rs:+2:5: +5:6
let mut _8: !; // in scope 0 at $DIR/while_let_loops.rs:+2:5: +5:6
scope 1 { scope 1 {
debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:+1:9: +1:15 debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:+1:9: +1:15
scope 2 { scope 2 {
@ -15,29 +20,33 @@
bb0: { bb0: {
StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:+1:9: +1:15 StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:+1:9: +1:15
_1 = const 0_i32; // scope 0 at $DIR/while_let_loops.rs:+1:18: +1:19 _1 = const 0_i32; // scope 0 at $DIR/while_let_loops.rs:+1:18: +1:19
StorageLive(_2); // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 StorageLive(_3); // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32
_2 = Option::<u32>::None; // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 _3 = Option::<u32>::None; // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32
- _3 = discriminant(_2); // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 - _4 = discriminant(_3); // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25
- switchInt(move _3) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 - switchInt(move _4) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25
+ _3 = const 0_isize; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 + _4 = const 0_isize; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25
+ switchInt(const 0_isize) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 + switchInt(const 0_isize) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25
} }
bb1: { bb1: {
switchInt(((_2 as Some).0: u32)) -> [0: bb2, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 switchInt(((_3 as Some).0: u32)) -> [0: bb2, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25
} }
bb2: { bb2: {
_1 = const 1_i32; // scope 2 at $DIR/while_let_loops.rs:+3:9: +3:15 _1 = const 1_i32; // scope 2 at $DIR/while_let_loops.rs:+3:9: +3:15
_0 = const (); // scope 2 at $DIR/while_let_loops.rs:+4:9: +4:14
goto -> bb4; // scope 2 at $DIR/while_let_loops.rs:+4:9: +4:14 goto -> bb4; // scope 2 at $DIR/while_let_loops.rs:+4:9: +4:14
} }
bb3: { bb3: {
StorageLive(_7); // scope 1 at $DIR/while_let_loops.rs:+2:5: +5:6
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:+2:5: +5:6
StorageDead(_7); // scope 1 at $DIR/while_let_loops.rs:+5:5: +5:6
goto -> bb4; // scope 1 at no-location goto -> bb4; // scope 1 at no-location
} }
bb4: { bb4: {
StorageDead(_2); // scope 1 at $DIR/while_let_loops.rs:+5:5: +5:6 StorageDead(_3); // scope 1 at $DIR/while_let_loops.rs:+5:5: +5:6
StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:+6:1: +6:2 StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:+6:1: +6:2
return; // scope 0 at $DIR/while_let_loops.rs:+6:2: +6:2 return; // scope 0 at $DIR/while_let_loops.rs:+6:2: +6:2
} }

View file

@ -1,5 +1,5 @@
// unit-test: ConstProp
// EMIT_MIR while_let_loops.change_loop_body.ConstProp.diff // EMIT_MIR while_let_loops.change_loop_body.ConstProp.diff
// EMIT_MIR while_let_loops.change_loop_body.PreCodegen.after.mir
pub fn change_loop_body() { pub fn change_loop_body() {
let mut _x = 0; let mut _x = 0;

View file

@ -1,17 +0,0 @@
// 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:+0:27: +0:27
let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:+1:9: +1:15
scope 1 {
debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:+1:9: +1:15
scope 2 {
}
}
bb0: {
StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:+1:9: +1:15
StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:+6:1: +6:2
return; // scope 0 at $DIR/while_let_loops.rs:+6:2: +6:2
}
}