diff options
| author | Ana-Maria Mihalache <mihalacheana.maria@yahoo.com> | 2020-04-04 17:15:01 +0000 |
|---|---|---|
| committer | Ana-Maria Mihalache <mihalacheana.maria@yahoo.com> | 2020-04-07 17:49:14 +0000 |
| commit | 688a4ddd20742f94155ec47fa2c1a96e1e3d78d3 (patch) | |
| tree | 448f4434be52f28469efcdefd9bec5aa54243233 /src/test | |
| parent | ef88769e4fd74cea5cc4f0c03259d6ee8a119e0f (diff) | |
| download | rust-688a4ddd20742f94155ec47fa2c1a96e1e3d78d3.tar.gz rust-688a4ddd20742f94155ec47fa2c1a96e1e3d78d3.zip | |
--bless more mir-opt tests.
Diffstat (limited to 'src/test')
66 files changed, 2254 insertions, 1013 deletions
diff --git a/src/test/mir-opt/const_prop/aggregate.rs b/src/test/mir-opt/const_prop/aggregate.rs index d04dcc6a05c..928ed8265d3 100644 --- a/src/test/mir-opt/const_prop/aggregate.rs +++ b/src/test/mir-opt/const_prop/aggregate.rs @@ -1,25 +1,6 @@ // compile-flags: -O +// EMIT_MIR rustc.main.ConstProp.diff fn main() { let x = (0, 1, 2).1 + 0; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _3 = (const 0i32, const 1i32, const 2i32); -// _2 = (_3.1: i32); -// _1 = Add(move _2, const 0i32); -// ... -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _3 = (const 0i32, const 1i32, const 2i32); -// _2 = const 1i32; -// _1 = const 1i32; -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/aggregate/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/aggregate/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..d20019287b0 --- /dev/null +++ b/src/test/mir-opt/const_prop/aggregate/rustc.main.ConstProp.diff @@ -0,0 +1,62 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/aggregate.rs:4:11: 4:11 + let _1: i32; // in scope 0 at $DIR/aggregate.rs:5:9: 5:10 + let mut _2: i32; // in scope 0 at $DIR/aggregate.rs:5:13: 5:24 + let mut _3: (i32, i32, i32); // in scope 0 at $DIR/aggregate.rs:5:13: 5:22 + scope 1 { + debug x => _1; // in scope 1 at $DIR/aggregate.rs:5:9: 5:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/aggregate.rs:5:9: 5:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/aggregate.rs:5:13: 5:24 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/aggregate.rs:5:13: 5:22 + _3 = (const 0i32, const 1i32, const 2i32); // bb0[3]: 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)) } + // 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)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/aggregate.rs:5:20: 5:21 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } +- _2 = (_3.1: i32); // bb0[4]: scope 0 at $DIR/aggregate.rs:5:13: 5:24 +- _1 = Add(move _2, const 0i32); // bb0[5]: scope 0 at $DIR/aggregate.rs:5:13: 5:28 ++ _2 = const 1i32; // bb0[4]: scope 0 at $DIR/aggregate.rs:5:13: 5:24 + // ty::Const + // + ty: i32 +- // + val: Value(Scalar(0x00000000)) ++ // + val: Value(Scalar(0x00000001)) + // mir::Constant +- // + span: $DIR/aggregate.rs:5:27: 5:28 +- // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } ++ // + span: $DIR/aggregate.rs:5:13: 5:24 ++ // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } ++ _1 = const 1i32; // bb0[5]: scope 0 at $DIR/aggregate.rs:5:13: 5:28 ++ // ty::Const ++ // + ty: i32 ++ // + val: Value(Scalar(0x00000001)) ++ // mir::Constant ++ // + span: $DIR/aggregate.rs:5:13: 5:28 ++ // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + StorageDead(_2); // bb0[6]: scope 0 at $DIR/aggregate.rs:5:27: 5:28 + StorageDead(_3); // bb0[7]: scope 0 at $DIR/aggregate.rs:5:28: 5:29 + _0 = (); // bb0[8]: scope 0 at $DIR/aggregate.rs:4:11: 6:2 + StorageDead(_1); // bb0[9]: scope 0 at $DIR/aggregate.rs:6:1: 6:2 + return; // bb0[10]: scope 0 at $DIR/aggregate.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/array_index.rs b/src/test/mir-opt/const_prop/array_index.rs index 406585b5cab..011a25e978c 100644 --- a/src/test/mir-opt/const_prop/array_index.rs +++ b/src/test/mir-opt/const_prop/array_index.rs @@ -1,33 +1,5 @@ +// EMIT_MIR rustc.main.ConstProp.diff + fn main() { let x: u32 = [0, 1, 2, 3][2]; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _2 = [const 0u32, const 1u32, const 2u32, const 3u32]; -// ... -// _3 = const 2usize; -// _4 = const 4usize; -// _5 = Lt(_3, _4); -// assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1; -// } -// bb1: { -// _1 = _2[_3]; -// ... -// return; -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _5 = const true; -// assert(const true, "index out of bounds: the len is move _4 but the index is _3") -> bb1; -// } -// bb1: { -// _1 = const 2u32; -// ... -// return; -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/array_index/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/array_index/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..b34db8618b6 --- /dev/null +++ b/src/test/mir-opt/const_prop/array_index/rustc.main.ConstProp.diff @@ -0,0 +1,92 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/array_index.rs:3:11: 3:11 + let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/array_index.rs:4:9: 4:10 + let mut _2: [u32; 4]; // in scope 0 at $DIR/array_index.rs:4:18: 4:30 + let _3: usize; // in scope 0 at $DIR/array_index.rs:4:31: 4:32 + let mut _4: usize; // in scope 0 at $DIR/array_index.rs:4:18: 4:33 + let mut _5: bool; // in scope 0 at $DIR/array_index.rs:4:18: 4:33 + scope 1 { + debug x => _1; // in scope 1 at $DIR/array_index.rs:4:9: 4:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/array_index.rs:4:9: 4:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/array_index.rs:4:18: 4:30 + _2 = [const 0u32, const 1u32, const 2u32, const 3u32]; // bb0[2]: scope 0 at $DIR/array_index.rs:4:18: 4:30 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/array_index.rs:4:19: 4:20 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/array_index.rs:4:22: 4:23 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/array_index.rs:4:25: 4:26 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/array_index.rs:4:28: 4:29 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } + StorageLive(_3); // bb0[3]: scope 0 at $DIR/array_index.rs:4:31: 4:32 + _3 = const 2usize; // bb0[4]: scope 0 at $DIR/array_index.rs:4:31: 4:32 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000002)) + // mir::Constant + // + span: $DIR/array_index.rs:4:31: 4:32 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000002)) } + _4 = const 4usize; // bb0[5]: scope 0 at $DIR/array_index.rs:4:18: 4:33 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000004)) + // mir::Constant + // + span: $DIR/array_index.rs:4:18: 4:33 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000004)) } +- _5 = Lt(_3, _4); // bb0[6]: scope 0 at $DIR/array_index.rs:4:18: 4:33 +- assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[7]: scope 0 at $DIR/array_index.rs:4:18: 4:33 ++ _5 = const true; // bb0[6]: scope 0 at $DIR/array_index.rs:4:18: 4:33 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/array_index.rs:4:18: 4:33 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } ++ assert(const true, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[7]: scope 0 at $DIR/array_index.rs:4:18: 4:33 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/array_index.rs:4:18: 4:33 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + } + + bb1: { +- _1 = _2[_3]; // bb1[0]: scope 0 at $DIR/array_index.rs:4:18: 4:33 ++ _1 = const 2u32; // bb1[0]: scope 0 at $DIR/array_index.rs:4:18: 4:33 ++ // ty::Const ++ // + ty: u32 ++ // + val: Value(Scalar(0x00000002)) ++ // mir::Constant ++ // + span: $DIR/array_index.rs:4:18: 4:33 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageDead(_3); // bb1[1]: scope 0 at $DIR/array_index.rs:4:33: 4:34 + StorageDead(_2); // bb1[2]: scope 0 at $DIR/array_index.rs:4:33: 4:34 + _0 = (); // bb1[3]: scope 0 at $DIR/array_index.rs:3:11: 5:2 + StorageDead(_1); // bb1[4]: scope 0 at $DIR/array_index.rs:5:1: 5:2 + return; // bb1[5]: scope 0 at $DIR/array_index.rs:5:2: 5:2 + } + } + diff --git a/src/test/mir-opt/const_prop/boxes.rs b/src/test/mir-opt/const_prop/boxes.rs index cf134dadf27..d45804ebb6c 100644 --- a/src/test/mir-opt/const_prop/boxes.rs +++ b/src/test/mir-opt/const_prop/boxes.rs @@ -7,50 +7,7 @@ // Note: this test verifies that we, in fact, do not const prop `box` +// EMIT_MIR rustc.main.ConstProp.diff fn main() { let x = *(box 42) + 0; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _4 = Box(i32); -// (*_4) = const 42i32; -// _3 = move _4; -// ... -// _2 = (*_3); -// _1 = Add(move _2, const 0i32); -// ... -// drop(_3) -> [return: bb2, unwind: bb1]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { -// ... -// _0 = (); -// ... -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _4 = Box(i32); -// (*_4) = const 42i32; -// _3 = move _4; -// ... -// _2 = (*_3); -// _1 = Add(move _2, const 0i32); -// ... -// drop(_3) -> [return: bb2, unwind: bb1]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { -// ... -// _0 = (); -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/boxes/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/boxes/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..50ee2abecfe --- /dev/null +++ b/src/test/mir-opt/const_prop/boxes/rustc.main.ConstProp.diff @@ -0,0 +1,52 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/boxes.rs:11:11: 11:11 + let _1: i32; // in scope 0 at $DIR/boxes.rs:12:9: 12:10 + let mut _2: i32; // in scope 0 at $DIR/boxes.rs:12:13: 12:22 + let mut _3: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:12:14: 12:22 + let mut _4: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:12:14: 12:22 + scope 1 { + debug x => _1; // in scope 1 at $DIR/boxes.rs:12:9: 12:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/boxes.rs:12:9: 12:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/boxes.rs:12:13: 12:22 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/boxes.rs:12:14: 12:22 + StorageLive(_4); // bb0[3]: scope 0 at $DIR/boxes.rs:12:14: 12:22 + _4 = Box(i32); // bb0[4]: scope 0 at $DIR/boxes.rs:12:14: 12:22 + (*_4) = const 42i32; // bb0[5]: scope 0 at $DIR/boxes.rs:12:19: 12:21 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/boxes.rs:12:19: 12:21 + // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) } + _3 = move _4; // bb0[6]: scope 0 at $DIR/boxes.rs:12:14: 12:22 + StorageDead(_4); // bb0[7]: scope 0 at $DIR/boxes.rs:12:21: 12:22 + _2 = (*_3); // bb0[8]: scope 0 at $DIR/boxes.rs:12:13: 12:22 + _1 = Add(move _2, const 0i32); // bb0[9]: scope 0 at $DIR/boxes.rs:12:13: 12:26 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/boxes.rs:12:25: 12:26 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + StorageDead(_2); // bb0[10]: scope 0 at $DIR/boxes.rs:12:25: 12:26 + drop(_3) -> [return: bb2, unwind: bb1]; // bb0[11]: scope 0 at $DIR/boxes.rs:12:26: 12:27 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/boxes.rs:11:1: 13:2 + } + + bb2: { + StorageDead(_3); // bb2[0]: scope 0 at $DIR/boxes.rs:12:26: 12:27 + _0 = (); // bb2[1]: scope 0 at $DIR/boxes.rs:11:11: 13:2 + StorageDead(_1); // bb2[2]: scope 0 at $DIR/boxes.rs:13:1: 13:2 + return; // bb2[3]: scope 0 at $DIR/boxes.rs:13:2: 13:2 + } + } + diff --git a/src/test/mir-opt/const_prop/checked_add.rs b/src/test/mir-opt/const_prop/checked_add.rs index fe98cf24eec..439bd2df91f 100644 --- a/src/test/mir-opt/const_prop/checked_add.rs +++ b/src/test/mir-opt/const_prop/checked_add.rs @@ -1,21 +1,6 @@ // compile-flags: -C overflow-checks=on +// EMIT_MIR rustc.main.ConstProp.diff fn main() { let x: u32 = 1 + 1; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _2 = CheckedAdd(const 1u32, const 1u32); -// assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1; -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _2 = (const 2u32, const false); -// assert(!const false, "attempt to add with overflow") -> bb1; -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/checked_add/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/checked_add/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..0a0a4ff852f --- /dev/null +++ b/src/test/mir-opt/const_prop/checked_add/rustc.main.ConstProp.diff @@ -0,0 +1,59 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/checked_add.rs:4:11: 4:11 + let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/checked_add.rs:5:9: 5:10 + let mut _2: (u32, bool); // in scope 0 at $DIR/checked_add.rs:5:18: 5:23 + scope 1 { + debug x => _1; // in scope 1 at $DIR/checked_add.rs:5:9: 5:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/checked_add.rs:5:9: 5:10 +- _2 = CheckedAdd(const 1u32, const 1u32); // bb0[1]: scope 0 at $DIR/checked_add.rs:5:18: 5:23 ++ _2 = (const 2u32, const false); // bb0[1]: scope 0 at $DIR/checked_add.rs:5:18: 5:23 + // ty::Const + // + ty: u32 +- // + val: Value(Scalar(0x00000001)) ++ // + val: Value(Scalar(0x00000002)) + // mir::Constant +- // + span: $DIR/checked_add.rs:5:18: 5:19 +- // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } ++ // + span: $DIR/checked_add.rs:5:18: 5:23 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + // ty::Const +- // + ty: u32 +- // + val: Value(Scalar(0x00000001)) ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) + // mir::Constant +- // + span: $DIR/checked_add.rs:5:22: 5:23 +- // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } +- assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1; // bb0[2]: scope 0 at $DIR/checked_add.rs:5:18: 5:23 ++ // + span: $DIR/checked_add.rs:5:18: 5:23 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } ++ assert(!const false, "attempt to add with overflow") -> bb1; // bb0[2]: scope 0 at $DIR/checked_add.rs:5:18: 5:23 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) ++ // mir::Constant ++ // + span: $DIR/checked_add.rs:5:18: 5:23 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + } + + bb1: { +- _1 = move (_2.0: u32); // bb1[0]: scope 0 at $DIR/checked_add.rs:5:18: 5:23 ++ _1 = const 2u32; // bb1[0]: scope 0 at $DIR/checked_add.rs:5:18: 5:23 ++ // ty::Const ++ // + ty: u32 ++ // + val: Value(Scalar(0x00000002)) ++ // mir::Constant ++ // + span: $DIR/checked_add.rs:5:18: 5:23 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + _0 = (); // bb1[1]: scope 0 at $DIR/checked_add.rs:4:11: 6:2 + StorageDead(_1); // bb1[2]: scope 0 at $DIR/checked_add.rs:6:1: 6:2 + return; // bb1[3]: scope 0 at $DIR/checked_add.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs b/src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs index 3c8c0ff4493..c6c006c0809 100644 --- a/src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs +++ b/src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs @@ -1,31 +1,9 @@ #[inline(never)] fn read(_: usize) { } +// EMIT_MIR rustc.main.ConstProp.diff fn main() { const FOO: &i32 = &1; let x = FOO as *const i32 as usize; read(x); } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _2 = &raw const (*_3); -// _1 = move _2 as usize (Misc); -// ... -// _5 = _1; -// _4 = const read(move _5) -> bb1; -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _3 = const main::FOO; -// _2 = &raw const (*_3); -// _1 = move _2 as usize (Misc); -// ... -// _5 = _1; -// _4 = const read(move _5) -> bb1; -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/const_prop_fails_gracefully/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/const_prop_fails_gracefully/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..f4a5b64f0d9 --- /dev/null +++ b/src/test/mir-opt/const_prop/const_prop_fails_gracefully/rustc.main.ConstProp.diff @@ -0,0 +1,50 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/const_prop_fails_gracefully.rs:5:11: 5:11 + let _1: usize; // in scope 0 at $DIR/const_prop_fails_gracefully.rs:7:9: 7:10 + let mut _2: *const i32; // in scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:30 + let _3: &i32; // in scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16 + let _4: (); // in scope 0 at $DIR/const_prop_fails_gracefully.rs:8:5: 8:12 + let mut _5: usize; // in scope 0 at $DIR/const_prop_fails_gracefully.rs:8:10: 8:11 + scope 1 { + debug x => _1; // in scope 1 at $DIR/const_prop_fails_gracefully.rs:7:9: 7:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:9: 7:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:30 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16 + _3 = const main::FOO; // bb0[3]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16 + // ty::Const + // + ty: &i32 + // + val: Unevaluated(DefId(0:5 ~ const_prop_fails_gracefully[317d]::main[0]::FOO[0]), [], None) + // mir::Constant + // + span: $DIR/const_prop_fails_gracefully.rs:7:13: 7:16 + // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:5 ~ const_prop_fails_gracefully[317d]::main[0]::FOO[0]), [], None) } + _2 = &raw const (*_3); // bb0[4]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16 + _1 = move _2 as usize (Misc); // bb0[5]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:39 + StorageDead(_2); // bb0[6]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:38: 7:39 + StorageDead(_3); // bb0[7]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:39: 7:40 + StorageLive(_4); // bb0[8]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:5: 8:12 + StorageLive(_5); // bb0[9]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:10: 8:11 + _5 = _1; // bb0[10]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:10: 8:11 + _4 = const read(move _5) -> bb1; // bb0[11]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:5: 8:12 + // ty::Const + // + ty: fn(usize) {read} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/const_prop_fails_gracefully.rs:8:5: 8:9 + // + literal: Const { ty: fn(usize) {read}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageDead(_5); // bb1[0]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:11: 8:12 + StorageDead(_4); // bb1[1]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:12: 8:13 + _0 = (); // bb1[2]: scope 0 at $DIR/const_prop_fails_gracefully.rs:5:11: 9:2 + StorageDead(_1); // bb1[3]: scope 0 at $DIR/const_prop_fails_gracefully.rs:9:1: 9:2 + return; // bb1[4]: scope 0 at $DIR/const_prop_fails_gracefully.rs:9:2: 9:2 + } + } + diff --git a/src/test/mir-opt/const_prop/control-flow-simplification.rs b/src/test/mir-opt/const_prop/control-flow-simplification.rs index 0e9f33b15e2..1071590dd9e 100644 --- a/src/test/mir-opt/const_prop/control-flow-simplification.rs +++ b/src/test/mir-opt/const_prop/control-flow-simplification.rs @@ -6,6 +6,8 @@ trait NeedsDrop:Sized{ impl<This> NeedsDrop for This{} +// EMIT_MIR rustc.hello.ConstProp.diff +// EMIT_MIR rustc.hello.PreCodegen.before.mir fn hello<T>(){ if <bool>::NEEDS { panic!() @@ -16,49 +18,3 @@ pub fn main() { hello::<()>(); hello::<Vec<()>>(); } - -// END RUST SOURCE -// START rustc.hello.ConstProp.before.mir -// let mut _0: (); -// let mut _1: bool; -// let mut _2: !; -// bb0: { -// StorageLive(_1); -// _1 = const <bool as NeedsDrop>::NEEDS; -// switchInt(_1) -> [false: bb1, otherwise: bb2]; -// } -// bb1: { -// _0 = (); -// StorageDead(_1); -// return; -// } -// bb2: { -// StorageLive(_2); -// const std::rt::begin_panic::<&str>(const "explicit panic"); -// } -// END rustc.hello.ConstProp.before.mir -// START rustc.hello.ConstProp.after.mir -// let mut _0: (); -// let mut _1: bool; -// let mut _2: !; -// bb0: { -// StorageLive(_1); -// _1 = const false; -// switchInt(const false) -> [false: bb1, otherwise: bb2]; -// } -// bb1: { -// _0 = (); -// StorageDead(_1); -// return; -// } -// bb2: { -// StorageLive(_2); -// const std::rt::begin_panic::<&str>(const "explicit panic"); -// } -// END rustc.hello.ConstProp.after.mir -// START rustc.hello.PreCodegen.before.mir -// let mut _0: (); -// bb0: { -// return; -// } -// END rustc.hello.PreCodegen.before.mir diff --git a/src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.ConstProp.diff b/src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.ConstProp.diff new file mode 100644 index 00000000000..55465421688 --- /dev/null +++ b/src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.ConstProp.diff @@ -0,0 +1,54 @@ +- // MIR for `hello` before ConstProp ++ // MIR for `hello` after ConstProp + + fn hello() -> () { + let mut _0: (); // return place in scope 0 at $DIR/control-flow-simplification.rs:11:14: 11:14 + let mut _1: bool; // in scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21 + let mut _2: !; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL: 13:52 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21 +- _1 = const <bool as NeedsDrop>::NEEDS; // bb0[1]: scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21 ++ _1 = const false; // bb0[1]: scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21 + // ty::Const + // + ty: bool +- // + val: Unevaluated(DefId(0:4 ~ control_flow_simplification[317d]::NeedsDrop[0]::NEEDS[0]), [bool], None) ++ // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/control-flow-simplification.rs:12:8: 12:21 +- // + literal: Const { ty: bool, val: Unevaluated(DefId(0:4 ~ control_flow_simplification[317d]::NeedsDrop[0]::NEEDS[0]), [bool], None) } +- switchInt(_1) -> [false: bb1, otherwise: bb2]; // bb0[2]: scope 0 at $DIR/control-flow-simplification.rs:12:5: 14:6 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } ++ switchInt(const false) -> [false: bb1, otherwise: bb2]; // bb0[2]: scope 0 at $DIR/control-flow-simplification.rs:12:5: 14:6 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) ++ // mir::Constant ++ // + span: $DIR/control-flow-simplification.rs:12:5: 14:6 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + } + + bb1: { + _0 = (); // bb1[0]: scope 0 at $DIR/control-flow-simplification.rs:12:5: 14:6 + StorageDead(_1); // bb1[1]: scope 0 at $DIR/control-flow-simplification.rs:15:1: 15:2 + return; // bb1[2]: scope 0 at $DIR/control-flow-simplification.rs:15:2: 15:2 + } + + bb2: { + StorageLive(_2); // bb2[0]: scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL: 13:52 + const std::rt::begin_panic::<&str>(const "explicit panic"); // bb2[1]: scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL: 13:52 + // ty::Const + // + ty: fn(&str) -> ! {std::rt::begin_panic::<&str>} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $SRC_DIR/libstd/macros.rs:LL:COL: 13:46 + // + literal: Const { ty: fn(&str) -> ! {std::rt::begin_panic::<&str>}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: &str + // + val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) + // mir::Constant + // + span: $SRC_DIR/libstd/macros.rs:LL:COL: 12:45 + // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) } + } + } + diff --git a/src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.PreCodegen.before.mir b/src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.PreCodegen.before.mir new file mode 100644 index 00000000000..53296f8714b --- /dev/null +++ b/src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.PreCodegen.before.mir @@ -0,0 +1,9 @@ +// MIR for `hello` before PreCodegen + +fn hello() -> () { + let mut _0: (); // return place in scope 0 at $DIR/control-flow-simplification.rs:11:14: 11:14 + + bb0: { + return; // bb0[0]: scope 0 at $DIR/control-flow-simplification.rs:15:2: 15:2 + } +} diff --git a/src/test/mir-opt/const_prop/discriminant.rs b/src/test/mir-opt/const_prop/discriminant.rs index 636aa1af653..2117589fce2 100644 --- a/src/test/mir-opt/const_prop/discriminant.rs +++ b/src/test/mir-opt/const_prop/discriminant.rs @@ -1,53 +1,6 @@ // compile-flags: -O +// EMIT_MIR rustc.main.ConstProp.diff fn main() { let x = (if let Some(true) = Some(true) { 42 } else { 10 }) + 0; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _3 = std::option::Option::<bool>::Some(const true,); -// _4 = discriminant(_3); -// switchInt(move _4) -> [1isize: bb2, otherwise: bb1]; -// } -// bb1: { -// _2 = const 10i32; -// goto -> bb4; -// } -// bb2: { -// switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; -// } -// bb3: { -// _2 = const 42i32; -// goto -> bb4; -// } -// bb4: { -// _1 = Add(move _2, const 0i32); -// ... -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _3 = const {transmute(0x01): std::option::Option<bool>}; -// _4 = const 1isize; -// switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1]; -// } -// bb1: { -// _2 = const 10i32; -// goto -> bb4; -// } -// bb2: { -// switchInt(const true) -> [false: bb1, otherwise: bb3]; -// } -// bb3: { -// _2 = const 42i32; -// goto -> bb4; -// } -// bb4: { -// _1 = Add(move _2, const 0i32); -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/discriminant/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/discriminant/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..152a3e5e391 --- /dev/null +++ b/src/test/mir-opt/const_prop/discriminant/rustc.main.ConstProp.diff @@ -0,0 +1,95 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/discriminant.rs:4:11: 4:11 + let _1: i32; // in scope 0 at $DIR/discriminant.rs:5:9: 5:10 + let mut _2: i32; // in scope 0 at $DIR/discriminant.rs:5:13: 5:64 + let mut _3: std::option::Option<bool>; // in scope 0 at $DIR/discriminant.rs:5:34: 5:44 + let mut _4: isize; // in scope 0 at $DIR/discriminant.rs:5:21: 5:31 + scope 1 { + debug x => _1; // in scope 1 at $DIR/discriminant.rs:5:9: 5:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/discriminant.rs:5:9: 5:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/discriminant.rs:5:13: 5:64 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/discriminant.rs:5:34: 5:44 +- _3 = std::option::Option::<bool>::Some(const true,); // bb0[3]: scope 0 at $DIR/discriminant.rs:5:34: 5:44 ++ _3 = const {transmute(0x01): std::option::Option<bool>}; // bb0[3]: scope 0 at $DIR/discriminant.rs:5:34: 5:44 + // ty::Const +- // + ty: bool ++ // + ty: std::option::Option<bool> + // + val: Value(Scalar(0x01)) + // mir::Constant +- // + span: $DIR/discriminant.rs:5:39: 5:43 +- // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } +- _4 = discriminant(_3); // bb0[4]: scope 0 at $DIR/discriminant.rs:5:21: 5:31 +- switchInt(move _4) -> [1isize: bb2, otherwise: bb1]; // bb0[5]: scope 0 at $DIR/discriminant.rs:5:21: 5:31 ++ // + span: $DIR/discriminant.rs:5:34: 5:44 ++ // + literal: Const { ty: std::option::Option<bool>, val: Value(Scalar(0x01)) } ++ _4 = const 1isize; // bb0[4]: scope 0 at $DIR/discriminant.rs:5:21: 5:31 ++ // ty::Const ++ // + ty: isize ++ // + val: Value(Scalar(0x0000000000000001)) ++ // mir::Constant ++ // + span: $DIR/discriminant.rs:5:21: 5:31 ++ // + literal: Const { ty: isize, val: Value(Scalar(0x0000000000000001)) } ++ switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1]; // bb0[5]: scope 0 at $DIR/discriminant.rs:5:21: 5:31 ++ // ty::Const ++ // + ty: isize ++ // + val: Value(Scalar(0x0000000000000001)) ++ // mir::Constant ++ // + span: $DIR/discriminant.rs:5:21: 5:31 ++ // + literal: Const { ty: isize, val: Value(Scalar(0x0000000000000001)) } + } + + bb1: { + _2 = const 10i32; // bb1[0]: scope 0 at $DIR/discriminant.rs:5:59: 5:61 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x0000000a)) + // mir::Constant + // + span: $DIR/discriminant.rs:5:59: 5:61 + // + literal: Const { ty: i32, val: Value(Scalar(0x0000000a)) } + goto -> bb4; // bb1[1]: scope 0 at $DIR/discriminant.rs:5:13: 5:64 + } + + bb2: { +- switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // bb2[0]: scope 0 at $DIR/discriminant.rs:5:26: 5:30 ++ switchInt(const true) -> [false: bb1, otherwise: bb3]; // bb2[0]: scope 0 at $DIR/discriminant.rs:5:26: 5:30 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/discriminant.rs:5:26: 5:30 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + } + + bb3: { + _2 = const 42i32; // bb3[0]: scope 0 at $DIR/discriminant.rs:5:47: 5:49 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/discriminant.rs:5:47: 5:49 + // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) } + goto -> bb4; // bb3[1]: scope 0 at $DIR/discriminant.rs:5:13: 5:64 + } + + bb4: { + _1 = Add(move _2, const 0i32); // bb4[0]: scope 0 at $DIR/discriminant.rs:5:13: 5:68 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/discriminant.rs:5:67: 5:68 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + StorageDead(_2); // bb4[1]: scope 0 at $DIR/discriminant.rs:5:67: 5:68 + StorageDead(_3); // bb4[2]: scope 0 at $DIR/discriminant.rs:5:68: 5:69 + _0 = (); // bb4[3]: scope 0 at $DIR/discriminant.rs:4:11: 6:2 + StorageDead(_1); // bb4[4]: scope 0 at $DIR/discriminant.rs:6:1: 6:2 + return; // bb4[5]: scope 0 at $DIR/discriminant.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/indirect.rs b/src/test/mir-opt/const_prop/indirect.rs index b4ee18ed1b5..961e4447d8b 100644 --- a/src/test/mir-opt/const_prop/indirect.rs +++ b/src/test/mir-opt/const_prop/indirect.rs @@ -1,23 +1,6 @@ // compile-flags: -C overflow-checks=on +// EMIT_MIR rustc.main.ConstProp.diff fn main() { let x = (2u32 as u8) + 1; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _2 = const 2u32 as u8 (Misc); -// _3 = CheckedAdd(move _2, const 1u8); -// assert(!move (_3.1: bool), "attempt to add with overflow") -> bb1; -//} -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _2 = const 2u8; -// _3 = (const 3u8, const false); -// assert(!const false, "attempt to add with overflow") -> bb1; -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/indirect/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/indirect/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..ca3e3bb5d2d --- /dev/null +++ b/src/test/mir-opt/const_prop/indirect/rustc.main.ConstProp.diff @@ -0,0 +1,70 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/indirect.rs:4:11: 4:11 + let _1: u8; // in scope 0 at $DIR/indirect.rs:5:9: 5:10 + let mut _2: u8; // in scope 0 at $DIR/indirect.rs:5:13: 5:25 + let mut _3: (u8, bool); // in scope 0 at $DIR/indirect.rs:5:13: 5:29 + scope 1 { + debug x => _1; // in scope 1 at $DIR/indirect.rs:5:9: 5:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/indirect.rs:5:9: 5:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/indirect.rs:5:13: 5:25 +- _2 = const 2u32 as u8 (Misc); // bb0[2]: scope 0 at $DIR/indirect.rs:5:13: 5:25 ++ _2 = const 2u8; // bb0[2]: scope 0 at $DIR/indirect.rs:5:13: 5:25 + // ty::Const +- // + ty: u32 +- // + val: Value(Scalar(0x00000002)) ++ // + ty: u8 ++ // + val: Value(Scalar(0x02)) + // mir::Constant +- // + span: $DIR/indirect.rs:5:14: 5:18 +- // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } +- _3 = CheckedAdd(move _2, const 1u8); // bb0[3]: scope 0 at $DIR/indirect.rs:5:13: 5:29 ++ // + span: $DIR/indirect.rs:5:13: 5:25 ++ // + literal: Const { ty: u8, val: Value(Scalar(0x02)) } ++ _3 = (const 3u8, const false); // bb0[3]: scope 0 at $DIR/indirect.rs:5:13: 5:29 + // ty::Const + // + ty: u8 +- // + val: Value(Scalar(0x01)) ++ // + val: Value(Scalar(0x03)) + // mir::Constant +- // + span: $DIR/indirect.rs:5:28: 5:29 +- // + literal: Const { ty: u8, val: Value(Scalar(0x01)) } +- assert(!move (_3.1: bool), "attempt to add with overflow") -> bb1; // bb0[4]: scope 0 at $DIR/indirect.rs:5:13: 5:29 ++ // + span: $DIR/indirect.rs:5:13: 5:29 ++ // + literal: Const { ty: u8, val: Value(Scalar(0x03)) } ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) ++ // mir::Constant ++ // + span: $DIR/indirect.rs:5:13: 5:29 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } ++ assert(!const false, "attempt to add with overflow") -> bb1; // bb0[4]: scope 0 at $DIR/indirect.rs:5:13: 5:29 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) ++ // mir::Constant ++ // + span: $DIR/indirect.rs:5:13: 5:29 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + } + + bb1: { +- _1 = move (_3.0: u8); // bb1[0]: scope 0 at $DIR/indirect.rs:5:13: 5:29 ++ _1 = const 3u8; // bb1[0]: scope 0 at $DIR/indirect.rs:5:13: 5:29 ++ // ty::Const ++ // + ty: u8 ++ // + val: Value(Scalar(0x03)) ++ // mir::Constant ++ // + span: $DIR/indirect.rs:5:13: 5:29 ++ // + literal: Const { ty: u8, val: Value(Scalar(0x03)) } + StorageDead(_2); // bb1[1]: scope 0 at $DIR/indirect.rs:5:28: 5:29 + _0 = (); // bb1[2]: scope 0 at $DIR/indirect.rs:4:11: 6:2 + StorageDead(_1); // bb1[3]: scope 0 at $DIR/indirect.rs:6:1: 6:2 + return; // bb1[4]: scope 0 at $DIR/indirect.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/issue-66971.rs b/src/test/mir-opt/const_prop/issue-66971.rs index f332bb89509..50a1405b77b 100644 --- a/src/test/mir-opt/const_prop/issue-66971.rs +++ b/src/test/mir-opt/const_prop/issue-66971.rs @@ -11,28 +11,7 @@ fn encode(this: ((), u8, u8)) { assert!(this.2 == 0); } +// EMIT_MIR rustc.main.ConstProp.diff fn main() { encode(((), 0, 0)); } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _3 = (); -// _2 = (move _3, const 0u8, const 0u8); -// ... -// _1 = const encode(move _2) -> bb1; -// ... -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _3 = const (); -// _2 = (move _3, const 0u8, const 0u8); -// ... -// _1 = const encode(move _2) -> bb1; -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/issue-66971/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/issue-66971/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..d3ebaa0a632 --- /dev/null +++ b/src/test/mir-opt/const_prop/issue-66971/rustc.main.ConstProp.diff @@ -0,0 +1,52 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue-66971.rs:15:11: 15:11 + let _1: (); // in scope 0 at $DIR/issue-66971.rs:16:5: 16:23 + let mut _2: ((), u8, u8); // in scope 0 at $DIR/issue-66971.rs:16:12: 16:22 + let mut _3: (); // in scope 0 at $DIR/issue-66971.rs:16:13: 16:15 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/issue-66971.rs:16:5: 16:23 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/issue-66971.rs:16:12: 16:22 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/issue-66971.rs:16:13: 16:15 +- _3 = (); // bb0[3]: scope 0 at $DIR/issue-66971.rs:16:13: 16:15 ++ _3 = const (); // bb0[3]: scope 0 at $DIR/issue-66971.rs:16:13: 16:15 ++ // ty::Const ++ // + ty: () ++ // + val: Value(Scalar(<ZST>)) ++ // mir::Constant ++ // + span: $DIR/issue-66971.rs:16:13: 16:15 ++ // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) } + _2 = (move _3, const 0u8, const 0u8); // bb0[4]: 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)) } + // ty::Const + // + ty: u8 + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-66971.rs:16:20: 16:21 + // + literal: Const { ty: u8, val: Value(Scalar(0x00)) } + StorageDead(_3); // bb0[5]: scope 0 at $DIR/issue-66971.rs:16:21: 16:22 + _1 = const encode(move _2) -> bb1; // bb0[6]: scope 0 at $DIR/issue-66971.rs:16:5: 16:23 + // ty::Const + // + ty: fn(((), u8, u8)) {encode} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/issue-66971.rs:16:5: 16:11 + // + literal: Const { ty: fn(((), u8, u8)) {encode}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageDead(_2); // bb1[0]: scope 0 at $DIR/issue-66971.rs:16:22: 16:23 + StorageDead(_1); // bb1[1]: scope 0 at $DIR/issue-66971.rs:16:23: 16:24 + _0 = (); // bb1[2]: scope 0 at $DIR/issue-66971.rs:15:11: 17:2 + return; // bb1[3]: scope 0 at $DIR/issue-66971.rs:17:2: 17:2 + } + } + diff --git a/src/test/mir-opt/const_prop/issue-67019.rs b/src/test/mir-opt/const_prop/issue-67019.rs index c6d753a1209..3c832eb1344 100644 --- a/src/test/mir-opt/const_prop/issue-67019.rs +++ b/src/test/mir-opt/const_prop/issue-67019.rs @@ -6,29 +6,7 @@ fn test(this: ((u8, u8),)) { assert!((this.0).0 == 1); } +// EMIT_MIR rustc.main.ConstProp.diff fn main() { test(((1, 2),)); } - -// Important bit is parameter passing so we only check that below -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _3 = (const 1u8, const 2u8); -// _2 = (move _3,); -// ... -// _1 = const test(move _2) -> bb1; -// ... -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _3 = (const 1u8, const 2u8); -// _2 = (move _3,); -// ... -// _1 = const test(move _2) -> bb1; -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/issue-67019/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/issue-67019/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..96a20edd91a --- /dev/null +++ b/src/test/mir-opt/const_prop/issue-67019/rustc.main.ConstProp.diff @@ -0,0 +1,47 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue-67019.rs:10:11: 10:11 + let _1: (); // in scope 0 at $DIR/issue-67019.rs:11:5: 11:20 + let mut _2: ((u8, u8),); // in scope 0 at $DIR/issue-67019.rs:11:10: 11:19 + let mut _3: (u8, u8); // in scope 0 at $DIR/issue-67019.rs:11:11: 11:17 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/issue-67019.rs:11:5: 11:20 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/issue-67019.rs:11:10: 11:19 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/issue-67019.rs:11:11: 11:17 + _3 = (const 1u8, const 2u8); // bb0[3]: 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 + // + literal: Const { ty: u8, val: Value(Scalar(0x01)) } + // 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 + // + literal: Const { ty: u8, val: Value(Scalar(0x02)) } + _2 = (move _3,); // bb0[4]: scope 0 at $DIR/issue-67019.rs:11:10: 11:19 + StorageDead(_3); // bb0[5]: scope 0 at $DIR/issue-67019.rs:11:18: 11:19 + _1 = const test(move _2) -> bb1; // bb0[6]: scope 0 at $DIR/issue-67019.rs:11:5: 11:20 + // ty::Const + // + ty: fn(((u8, u8),)) {test} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/issue-67019.rs:11:5: 11:9 + // + literal: Const { ty: fn(((u8, u8),)) {test}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageDead(_2); // bb1[0]: scope 0 at $DIR/issue-67019.rs:11:19: 11:20 + StorageDead(_1); // bb1[1]: scope 0 at $DIR/issue-67019.rs:11:20: 11:21 + _0 = (); // bb1[2]: scope 0 at $DIR/issue-67019.rs:10:11: 12:2 + return; // bb1[3]: scope 0 at $DIR/issue-67019.rs:12:2: 12:2 + } + } + diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable.rs b/src/test/mir-opt/const_prop/optimizes_into_variable.rs index 93a53db9093..9ecc1eadceb 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable.rs +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.rs @@ -5,145 +5,10 @@ struct Point { y: u32, } +// EMIT_MIR rustc.main.ConstProp.diff +// EMIT_MIR rustc.main.SimplifyLocals.after.mir fn main() { let x = 2 + 2; let y = [0, 1, 2, 3, 4, 5][3]; let z = (Point { x: 12, y: 42}).y; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// let mut _0: (); -// let _1: i32; -// let mut _2: (i32, bool); -// let mut _4: [i32; 6]; -// let _5: usize; -// let mut _6: usize; -// let mut _7: bool; -// let mut _9: Point; -// scope 1 { -// debug x => _1; -// let _3: i32; -// scope 2 { -// debug y => _3; -// let _8: u32; -// scope 3 { -// debug z => _8; -// } -// } -// } -// bb0: { -// StorageLive(_1); -// _2 = CheckedAdd(const 2i32, const 2i32); -// assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1; -// } -// bb1: { -// _1 = move (_2.0: i32); -// StorageLive(_3); -// StorageLive(_4); -// _4 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; -// StorageLive(_5); -// _5 = const 3usize; -// _6 = const 6usize; -// _7 = Lt(_5, _6); -// assert(move _7, "index out of bounds: the len is move _6 but the index is _5") -> bb2; -// } -// bb2: { -// _3 = _4[_5]; -// StorageDead(_5); -// StorageDead(_4); -// StorageLive(_8); -// StorageLive(_9); -// _9 = Point { x: const 12u32, y: const 42u32 }; -// _8 = (_9.1: u32); -// StorageDead(_9); -// _0 = (); -// StorageDead(_8); -// StorageDead(_3); -// StorageDead(_1); -// return; -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// let mut _0: (); -// let _1: i32; -// let mut _2: (i32, bool); -// let mut _4: [i32; 6]; -// let _5: usize; -// let mut _6: usize; -// let mut _7: bool; -// let mut _9: Point; -// scope 1 { -// debug x => _1; -// let _3: i32; -// scope 2 { -// debug y => _3; -// let _8: u32; -// scope 3 { -// debug z => _8; -// } -// } -// } -// bb0: { -// StorageLive(_1); -// _2 = (const 4i32, const false); -// assert(!const false, "attempt to add with overflow") -> bb1; -// } -// bb1: { -// _1 = const 4i32; -// StorageLive(_3); -// StorageLive(_4); -// _4 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; -// StorageLive(_5); -// _5 = const 3usize; -// _6 = const 6usize; -// _7 = const true; -// assert(const true, "index out of bounds: the len is move _6 but the index is _5") -> bb2; -// } -// bb2: { -// _3 = const 3i32; -// StorageDead(_5); -// StorageDead(_4); -// StorageLive(_8); -// StorageLive(_9); -// _9 = Point { x: const 12u32, y: const 42u32 }; -// _8 = const 42u32; -// StorageDead(_9); -// _0 = (); -// StorageDead(_8); -// StorageDead(_3); -// StorageDead(_1); -// return; -// } -// END rustc.main.ConstProp.after.mir -// START rustc.main.SimplifyLocals.after.mir -// let mut _0: (); -// let _1: i32; -// let mut _3: [i32; 6]; -// scope 1 { -// debug x => _1; -// let _2: i32; -// scope 2 { -// debug y => _2; -// let _4: u32; -// scope 3 { -// debug z => _4; -// } -// } -// } -// bb0: { -// StorageLive(_1); -// _1 = const 4i32; -// StorageLive(_2); -// StorageLive(_3); -// _3 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; -// _2 = const 3i32; -// StorageDead(_3); -// StorageLive(_4); -// _4 = const 42u32; -// StorageDead(_4); -// StorageDead(_2); -// StorageDead(_1); -// return; -// } -// END rustc.main.SimplifyLocals.after.mir diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/optimizes_into_variable/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..5bce2ecee34 --- /dev/null +++ b/src/test/mir-opt/const_prop/optimizes_into_variable/rustc.main.ConstProp.diff @@ -0,0 +1,181 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:10:11: 10:11 + let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:11:9: 11:10 + let mut _2: (i32, bool); // in scope 0 at $DIR/optimizes_into_variable.rs:11:13: 11:18 + let mut _4: [i32; 6]; // in scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:31 + let _5: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:12:32: 12:33 + let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:34 + let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:34 + let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:36 + scope 1 { + debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:11:9: 11:10 + let _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10 + scope 2 { + debug y => _3; // in scope 2 at $DIR/optimizes_into_variable.rs:12:9: 12:10 + let _8: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + scope 3 { + debug z => _8; // in scope 3 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + } + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/optimizes_into_variable.rs:11:9: 11:10 +- _2 = CheckedAdd(const 2i32, const 2i32); // bb0[1]: scope 0 at $DIR/optimizes_into_variable.rs:11:13: 11:18 ++ _2 = (const 4i32, const false); // bb0[1]: scope 0 at $DIR/optimizes_into_variable.rs:11:13: 11:18 + // ty::Const + // + ty: i32 +- // + val: Value(Scalar(0x00000002)) ++ // + val: Value(Scalar(0x00000004)) + // mir::Constant +- // + span: $DIR/optimizes_into_variable.rs:11:13: 11:14 +- // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } ++ // + span: $DIR/optimizes_into_variable.rs:11:13: 11:18 ++ // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + // ty::Const +- // + ty: i32 +- // + val: Value(Scalar(0x00000002)) ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) + // mir::Constant +- // + span: $DIR/optimizes_into_variable.rs:11:17: 11:18 +- // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } +- assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1; // bb0[2]: scope 0 at $DIR/optimizes_into_variable.rs:11:13: 11:18 ++ // + span: $DIR/optimizes_into_variable.rs:11:13: 11:18 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } ++ assert(!const false, "attempt to add with overflow") -> bb1; // bb0[2]: scope 0 at $DIR/optimizes_into_variable.rs:11:13: 11:18 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:11:13: 11:18 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + } + + bb1: { +- _1 = move (_2.0: i32); // bb1[0]: scope 0 at $DIR/optimizes_into_variable.rs:11:13: 11:18 ++ _1 = const 4i32; // bb1[0]: scope 0 at $DIR/optimizes_into_variable.rs:11:13: 11:18 ++ // ty::Const ++ // + ty: i32 ++ // + val: Value(Scalar(0x00000004)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:11:13: 11:18 ++ // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + StorageLive(_3); // bb1[1]: scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10 + StorageLive(_4); // bb1[2]: scope 1 at $DIR/optimizes_into_variable.rs:12:13: 12:31 + _4 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; // bb1[3]: scope 1 at $DIR/optimizes_into_variable.rs:12:13: 12:31 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:14: 12:15 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:17: 12:18 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:20: 12:21 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:23: 12:24 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000004)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:26: 12:27 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000005)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:29: 12:30 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) } + StorageLive(_5); // bb1[4]: scope 1 at $DIR/optimizes_into_variable.rs:12:32: 12:33 + _5 = const 3usize; // bb1[5]: scope 1 at $DIR/optimizes_into_variable.rs:12:32: 12:33 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000003)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:32: 12:33 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000003)) } + _6 = const 6usize; // bb1[6]: scope 1 at $DIR/optimizes_into_variable.rs:12:13: 12:34 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000006)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:13: 12:34 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000006)) } +- _7 = Lt(_5, _6); // bb1[7]: scope 1 at $DIR/optimizes_into_variable.rs:12:13: 12:34 +- assert(move _7, "index out of bounds: the len is move _6 but the index is _5") -> bb2; // bb1[8]: scope 1 at $DIR/optimizes_into_variable.rs:12:13: 12:34 ++ _7 = const true; // bb1[7]: scope 1 at $DIR/optimizes_into_variable.rs:12:13: 12:34 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:12:13: 12:34 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } ++ assert(const true, "index out of bounds: the len is move _6 but the index is _5") -> bb2; // bb1[8]: scope 1 at $DIR/optimizes_into_variable.rs:12:13: 12:34 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:12:13: 12:34 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + } + + bb2: { +- _3 = _4[_5]; // bb2[0]: scope 1 at $DIR/optimizes_into_variable.rs:12:13: 12:34 ++ _3 = const 3i32; // bb2[0]: scope 1 at $DIR/optimizes_into_variable.rs:12:13: 12:34 ++ // ty::Const ++ // + ty: i32 ++ // + val: Value(Scalar(0x00000003)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:12:13: 12:34 ++ // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + StorageDead(_5); // bb2[1]: scope 1 at $DIR/optimizes_into_variable.rs:12:34: 12:35 + StorageDead(_4); // bb2[2]: scope 1 at $DIR/optimizes_into_variable.rs:12:34: 12:35 + StorageLive(_8); // bb2[3]: scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + StorageLive(_9); // bb2[4]: scope 2 at $DIR/optimizes_into_variable.rs:13:13: 13:36 + _9 = Point { x: const 12u32, y: const 42u32 }; // bb2[5]: scope 2 at $DIR/optimizes_into_variable.rs:13:13: 13:36 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000000c)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:25: 13:27 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000000c)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:32: 13:34 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } +- _8 = (_9.1: u32); // bb2[6]: scope 2 at $DIR/optimizes_into_variable.rs:13:13: 13:38 ++ _8 = const 42u32; // bb2[6]: scope 2 at $DIR/optimizes_into_variable.rs:13:13: 13:38 ++ // ty::Const ++ // + ty: u32 ++ // + val: Value(Scalar(0x0000002a)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:13:13: 13:38 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } + StorageDead(_9); // bb2[7]: scope 2 at $DIR/optimizes_into_variable.rs:13:38: 13:39 + _0 = (); // bb2[8]: scope 0 at $DIR/optimizes_into_variable.rs:10:11: 14:2 + StorageDead(_8); // bb2[9]: scope 2 at $DIR/optimizes_into_variable.rs:14:1: 14:2 + StorageDead(_3); // bb2[10]: scope 1 at $DIR/optimizes_into_variable.rs:14:1: 14:2 + StorageDead(_1); // bb2[11]: scope 0 at $DIR/optimizes_into_variable.rs:14:1: 14:2 + return; // bb2[12]: scope 0 at $DIR/optimizes_into_variable.rs:14:2: 14:2 + } + } + diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable/rustc.main.SimplifyLocals.after.mir b/src/test/mir-opt/const_prop/optimizes_into_variable/rustc.main.SimplifyLocals.after.mir new file mode 100644 index 00000000000..8cd40cd535c --- /dev/null +++ b/src/test/mir-opt/const_prop/optimizes_into_variable/rustc.main.SimplifyLocals.after.mir @@ -0,0 +1,88 @@ +// MIR for `main` after SimplifyLocals + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:10:11: 10:11 + let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:11:9: 11:10 + let mut _3: [i32; 6]; // in scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:31 + scope 1 { + debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:11:9: 11:10 + let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10 + scope 2 { + debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:12:9: 12:10 + let _4: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + scope 3 { + debug z => _4; // in scope 3 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + } + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/optimizes_into_variable.rs:11:9: 11:10 + _1 = const 4i32; // bb0[1]: scope 0 at $DIR/optimizes_into_variable.rs:11:13: 11:18 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000004)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:11:13: 11:18 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + StorageLive(_2); // bb0[2]: scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10 + StorageLive(_3); // bb0[3]: scope 1 at $DIR/optimizes_into_variable.rs:12:13: 12:31 + _3 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; // bb0[4]: scope 1 at $DIR/optimizes_into_variable.rs:12:13: 12:31 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:14: 12:15 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:17: 12:18 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:20: 12:21 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:23: 12:24 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000004)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:26: 12:27 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000005)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:29: 12:30 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) } + _2 = const 3i32; // bb0[5]: scope 1 at $DIR/optimizes_into_variable.rs:12:13: 12:34 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:13: 12:34 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + StorageDead(_3); // bb0[6]: scope 1 at $DIR/optimizes_into_variable.rs:12:34: 12:35 + StorageLive(_4); // bb0[7]: scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + _4 = const 42u32; // bb0[8]: scope 2 at $DIR/optimizes_into_variable.rs:13:13: 13:38 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:13: 13:38 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } + StorageDead(_4); // bb0[9]: scope 2 at $DIR/optimizes_into_variable.rs:14:1: 14:2 + StorageDead(_2); // bb0[10]: scope 1 at $DIR/optimizes_into_variable.rs:14:1: 14:2 + StorageDead(_1); // bb0[11]: scope 0 at $DIR/optimizes_into_variable.rs:14:1: 14:2 + return; // bb0[12]: scope 0 at $DIR/optimizes_into_variable.rs:14:2: 14:2 + } +} diff --git a/src/test/mir-opt/const_prop/read_immutable_static.rs b/src/test/mir-opt/const_prop/read_immutable_static.rs index d307cebd715..9635f7050a6 100644 --- a/src/test/mir-opt/const_prop/read_immutable_static.rs +++ b/src/test/mir-opt/const_prop/read_immutable_static.rs @@ -2,30 +2,7 @@ static FOO: u8 = 2; +// EMIT_MIR rustc.main.ConstProp.diff fn main() { let x = FOO + FOO; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _3 = const {alloc0+0: &u8}; -// _2 = (*_3); -// ... -// _5 = const {alloc0+0: &u8}; -// _4 = (*_5); -// _1 = Add(move _2, move _4); -// ... -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _2 = const 2u8; -// ... -// _4 = const 2u8; -// _1 = const 4u8; -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/read_immutable_static/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/read_immutable_static/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..6183b22a95f --- /dev/null +++ b/src/test/mir-opt/const_prop/read_immutable_static/rustc.main.ConstProp.diff @@ -0,0 +1,72 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/read_immutable_static.rs:6:11: 6:11 + let _1: u8; // in scope 0 at $DIR/read_immutable_static.rs:7:9: 7:10 + let mut _2: u8; // in scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 + let mut _3: &u8; // in scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 + let mut _4: u8; // in scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 + let mut _5: &u8; // in scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 + scope 1 { + debug x => _1; // in scope 1 at $DIR/read_immutable_static.rs:7:9: 7:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/read_immutable_static.rs:7:9: 7:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 + _3 = const {alloc0+0: &u8}; // bb0[3]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 + // ty::Const + // + ty: &u8 + // + val: Value(Scalar(alloc0+0)) + // mir::Constant + // + span: $DIR/read_immutable_static.rs:7:13: 7:16 + // + literal: Const { ty: &u8, val: Value(Scalar(alloc0+0)) } +- _2 = (*_3); // bb0[4]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 ++ _2 = const 2u8; // bb0[4]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 ++ // ty::Const ++ // + ty: u8 ++ // + val: Value(Scalar(0x02)) ++ // mir::Constant ++ // + span: $DIR/read_immutable_static.rs:7:13: 7:16 ++ // + literal: Const { ty: u8, val: Value(Scalar(0x02)) } + StorageLive(_4); // bb0[5]: scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 + StorageLive(_5); // bb0[6]: scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 + _5 = const {alloc0+0: &u8}; // bb0[7]: scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 + // ty::Const + // + ty: &u8 + // + val: Value(Scalar(alloc0+0)) + // mir::Constant + // + span: $DIR/read_immutable_static.rs:7:19: 7:22 + // + literal: Const { ty: &u8, val: Value(Scalar(alloc0+0)) } +- _4 = (*_5); // bb0[8]: scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 +- _1 = Add(move _2, move _4); // bb0[9]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:22 ++ _4 = const 2u8; // bb0[8]: scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 ++ // ty::Const ++ // + ty: u8 ++ // + val: Value(Scalar(0x02)) ++ // mir::Constant ++ // + span: $DIR/read_immutable_static.rs:7:19: 7:22 ++ // + literal: Const { ty: u8, val: Value(Scalar(0x02)) } ++ _1 = const 4u8; // bb0[9]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:22 ++ // ty::Const ++ // + ty: u8 ++ // + val: Value(Scalar(0x04)) ++ // mir::Constant ++ // + span: $DIR/read_immutable_static.rs:7:13: 7:22 ++ // + literal: Const { ty: u8, val: Value(Scalar(0x04)) } + StorageDead(_4); // bb0[10]: scope 0 at $DIR/read_immutable_static.rs:7:21: 7:22 + StorageDead(_2); // bb0[11]: scope 0 at $DIR/read_immutable_static.rs:7:21: 7:22 + StorageDead(_5); // bb0[12]: scope 0 at $DIR/read_immutable_static.rs:7:22: 7:23 + StorageDead(_3); // bb0[13]: scope 0 at $DIR/read_immutable_static.rs:7:22: 7:23 + _0 = (); // bb0[14]: scope 0 at $DIR/read_immutable_static.rs:6:11: 8:2 + StorageDead(_1); // bb0[15]: scope 0 at $DIR/read_immutable_static.rs:8:1: 8:2 + return; // bb0[16]: scope 0 at $DIR/read_immutable_static.rs:8:2: 8:2 + } + } + + alloc0 (static: FOO, size: 1, align: 1) { + 02 │ . + } + diff --git a/src/test/mir-opt/const_prop/ref_deref.rs b/src/test/mir-opt/const_prop/ref_deref.rs index 8b48296a5d9..fc33e0e1f3b 100644 --- a/src/test/mir-opt/const_prop/ref_deref.rs +++ b/src/test/mir-opt/const_prop/ref_deref.rs @@ -1,41 +1,6 @@ +// EMIT_MIR rustc.main.PromoteTemps.diff +// EMIT_MIR rustc.main.ConstProp.diff + fn main() { *(&4); } - -// END RUST SOURCE -// START rustc.main.PromoteTemps.before.mir -// bb0: { -// ... -// _3 = const 4i32; -// _2 = &_3; -// _1 = (*_2); -// ... -//} -// END rustc.main.PromoteTemps.before.mir -// START rustc.main.PromoteTemps.after.mir -// bb0: { -// ... -// _4 = const main::promoted[0]; -// _2 = &(*_4); -// _1 = (*_2); -// ... -//} -// END rustc.main.PromoteTemps.after.mir -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _4 = const main::promoted[0]; -// _2 = _4; -// _1 = (*_2); -// ... -//} -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _4 = const main::promoted[0]; -// _2 = _4; -// _1 = const 4i32; -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/ref_deref/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/ref_deref/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..0f8563daba5 --- /dev/null +++ b/src/test/mir-opt/const_prop/ref_deref/rustc.main.ConstProp.diff @@ -0,0 +1,36 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/ref_deref.rs:4:11: 4:11 + let _1: i32; // in scope 0 at $DIR/ref_deref.rs:5:5: 5:10 + let mut _2: &i32; // in scope 0 at $DIR/ref_deref.rs:5:6: 5:10 + let _3: i32; // in scope 0 at $DIR/ref_deref.rs:5:8: 5:9 + let mut _4: &i32; // in scope 0 at $DIR/ref_deref.rs:5:6: 5:10 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10 + _4 = const main::promoted[0]; // bb0[2]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10 + // ty::Const + // + ty: &i32 + // + val: Unevaluated(DefId(0:3 ~ ref_deref[317d]::main[0]), [], Some(promoted[0])) + // mir::Constant + // + span: $DIR/ref_deref.rs:5:6: 5:10 + // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:3 ~ ref_deref[317d]::main[0]), [], Some(promoted[0])) } + _2 = _4; // bb0[3]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10 +- _1 = (*_2); // bb0[4]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10 ++ _1 = const 4i32; // bb0[4]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10 ++ // ty::Const ++ // + ty: i32 ++ // + val: Value(Scalar(0x00000004)) ++ // mir::Constant ++ // + span: $DIR/ref_deref.rs:5:5: 5:10 ++ // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + StorageDead(_2); // bb0[5]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11 + StorageDead(_1); // bb0[6]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11 + _0 = (); // bb0[7]: scope 0 at $DIR/ref_deref.rs:4:11: 6:2 + return; // bb0[8]: scope 0 at $DIR/ref_deref.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/ref_deref/rustc.main.PromoteTemps.diff b/src/test/mir-opt/const_prop/ref_deref/rustc.main.PromoteTemps.diff new file mode 100644 index 00000000000..ea1baa40f7e --- /dev/null +++ b/src/test/mir-opt/const_prop/ref_deref/rustc.main.PromoteTemps.diff @@ -0,0 +1,42 @@ +- // MIR for `main` before PromoteTemps ++ // MIR for `main` after PromoteTemps + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/ref_deref.rs:4:11: 4:11 + let _1: i32; // in scope 0 at $DIR/ref_deref.rs:5:5: 5:10 + let mut _2: &i32; // in scope 0 at $DIR/ref_deref.rs:5:6: 5:10 + let _3: i32; // in scope 0 at $DIR/ref_deref.rs:5:8: 5:9 ++ let mut _4: &i32; // in scope 0 at $DIR/ref_deref.rs:5:6: 5:10 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10 +- StorageLive(_3); // bb0[2]: scope 0 at $DIR/ref_deref.rs:5:8: 5:9 +- _3 = const 4i32; // bb0[3]: scope 0 at $DIR/ref_deref.rs:5:8: 5:9 ++ _4 = const main::promoted[0]; // bb0[2]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10 + // ty::Const +- // + ty: i32 +- // + val: Value(Scalar(0x00000004)) ++ // + ty: &i32 ++ // + val: Unevaluated(DefId(0:3 ~ ref_deref[317d]::main[0]), [], Some(promoted[0])) + // mir::Constant +- // + span: $DIR/ref_deref.rs:5:8: 5:9 +- // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } +- _2 = &_3; // bb0[4]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10 +- _1 = (*_2); // bb0[5]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10 +- StorageDead(_3); // bb0[6]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11 +- StorageDead(_2); // bb0[7]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11 +- StorageDead(_1); // bb0[8]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11 +- _0 = (); // bb0[9]: scope 0 at $DIR/ref_deref.rs:4:11: 6:2 +- return; // bb0[10]: scope 0 at $DIR/ref_deref.rs:6:2: 6:2 ++ // + span: $DIR/ref_deref.rs:5:6: 5:10 ++ // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:3 ~ ref_deref[317d]::main[0]), [], Some(promoted[0])) } ++ _2 = &(*_4); // bb0[3]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10 ++ _1 = (*_2); // bb0[4]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10 ++ StorageDead(_2); // bb0[5]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11 ++ StorageDead(_1); // bb0[6]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11 ++ _0 = (); // bb0[7]: scope 0 at $DIR/ref_deref.rs:4:11: 6:2 ++ return; // bb0[8]: scope 0 at $DIR/ref_deref.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/ref_deref_project.rs b/src/test/mir-opt/const_prop/ref_deref_project.rs index ca539fb7462..0322e300643 100644 --- a/src/test/mir-opt/const_prop/ref_deref_project.rs +++ b/src/test/mir-opt/const_prop/ref_deref_project.rs @@ -1,41 +1,6 @@ +// EMIT_MIR rustc.main.PromoteTemps.diff +// EMIT_MIR rustc.main.ConstProp.diff + fn main() { *(&(4, 5).1); // This does not currently propagate (#67862) } - -// END RUST SOURCE -// START rustc.main.PromoteTemps.before.mir -// bb0: { -// ... -// _3 = (const 4i32, const 5i32); -// _2 = &(_3.1: i32); -// _1 = (*_2); -// ... -//} -// END rustc.main.PromoteTemps.before.mir -// START rustc.main.PromoteTemps.after.mir -// bb0: { -// ... -// _4 = const main::promoted[0]; -// _2 = &((*_4).1: i32); -// _1 = (*_2); -// ... -//} -// END rustc.main.PromoteTemps.after.mir -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _4 = const main::promoted[0]; -// _2 = &((*_4).1: i32); -// _1 = (*_2); -// ... -//} -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _4 = const main::promoted[0]; -// _2 = &((*_4).1: i32); -// _1 = (*_2); -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/ref_deref_project/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/ref_deref_project/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..c4b3d6b6c27 --- /dev/null +++ b/src/test/mir-opt/const_prop/ref_deref_project/rustc.main.ConstProp.diff @@ -0,0 +1,29 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/ref_deref_project.rs:4:11: 4:11 + let _1: i32; // in scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17 + let mut _2: &i32; // in scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 + let _3: (i32, i32); // in scope 0 at $DIR/ref_deref_project.rs:5:8: 5:14 + let mut _4: &(i32, i32); // in scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 + _4 = const main::promoted[0]; // bb0[2]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 + // ty::Const + // + ty: &(i32, i32) + // + val: Unevaluated(DefId(0:3 ~ ref_deref_project[317d]::main[0]), [], Some(promoted[0])) + // mir::Constant + // + span: $DIR/ref_deref_project.rs:5:6: 5:17 + // + literal: Const { ty: &(i32, i32), val: Unevaluated(DefId(0:3 ~ ref_deref_project[317d]::main[0]), [], Some(promoted[0])) } + _2 = &((*_4).1: i32); // bb0[3]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 + _1 = (*_2); // bb0[4]: scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17 + StorageDead(_2); // bb0[5]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 + StorageDead(_1); // bb0[6]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 + _0 = (); // bb0[7]: scope 0 at $DIR/ref_deref_project.rs:4:11: 6:2 + return; // bb0[8]: scope 0 at $DIR/ref_deref_project.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/ref_deref_project/rustc.main.PromoteTemps.diff b/src/test/mir-opt/const_prop/ref_deref_project/rustc.main.PromoteTemps.diff new file mode 100644 index 00000000000..852436e13b6 --- /dev/null +++ b/src/test/mir-opt/const_prop/ref_deref_project/rustc.main.PromoteTemps.diff @@ -0,0 +1,48 @@ +- // MIR for `main` before PromoteTemps ++ // MIR for `main` after PromoteTemps + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/ref_deref_project.rs:4:11: 4:11 + let _1: i32; // in scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17 + let mut _2: &i32; // in scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 + let _3: (i32, i32); // in scope 0 at $DIR/ref_deref_project.rs:5:8: 5:14 ++ let mut _4: &(i32, i32); // in scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 +- StorageLive(_3); // bb0[2]: scope 0 at $DIR/ref_deref_project.rs:5:8: 5:14 +- _3 = (const 4i32, const 5i32); // bb0[3]: scope 0 at $DIR/ref_deref_project.rs:5:8: 5:14 ++ _4 = const main::promoted[0]; // bb0[2]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 + // ty::Const +- // + ty: i32 +- // + val: Value(Scalar(0x00000004)) ++ // + ty: &(i32, i32) ++ // + val: Unevaluated(DefId(0:3 ~ ref_deref_project[317d]::main[0]), [], Some(promoted[0])) + // mir::Constant +- // + span: $DIR/ref_deref_project.rs:5:9: 5:10 +- // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } +- // ty::Const +- // + ty: i32 +- // + val: Value(Scalar(0x00000005)) +- // mir::Constant +- // + span: $DIR/ref_deref_project.rs:5:12: 5:13 +- // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) } +- _2 = &(_3.1: i32); // bb0[4]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 +- _1 = (*_2); // bb0[5]: scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17 +- StorageDead(_3); // bb0[6]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 +- StorageDead(_2); // bb0[7]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 +- StorageDead(_1); // bb0[8]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 +- _0 = (); // bb0[9]: scope 0 at $DIR/ref_deref_project.rs:4:11: 6:2 +- return; // bb0[10]: scope 0 at $DIR/ref_deref_project.rs:6:2: 6:2 ++ // + span: $DIR/ref_deref_project.rs:5:6: 5:17 ++ // + literal: Const { ty: &(i32, i32), val: Unevaluated(DefId(0:3 ~ ref_deref_project[317d]::main[0]), [], Some(promoted[0])) } ++ _2 = &((*_4).1: i32); // bb0[3]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 ++ _1 = (*_2); // bb0[4]: scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17 ++ StorageDead(_2); // bb0[5]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 ++ StorageDead(_1); // bb0[6]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 ++ _0 = (); // bb0[7]: scope 0 at $DIR/ref_deref_project.rs:4:11: 6:2 ++ return; // bb0[8]: scope 0 at $DIR/ref_deref_project.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/reify_fn_ptr.rs b/src/test/mir-opt/const_prop/reify_fn_ptr.rs index 4d6fe905b0c..834eb0cb1e9 100644 --- a/src/test/mir-opt/const_prop/reify_fn_ptr.rs +++ b/src/test/mir-opt/const_prop/reify_fn_ptr.rs @@ -1,25 +1,5 @@ +// EMIT_MIR rustc.main.ConstProp.diff + fn main() { let _ = main as usize as *const fn(); } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _3 = const main as fn() (Pointer(ReifyFnPointer)); -// _2 = move _3 as usize (Misc); -// ... -// _1 = move _2 as *const fn() (Misc); -// ... -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _3 = const main as fn() (Pointer(ReifyFnPointer)); -// _2 = move _3 as usize (Misc); -// ... -// _1 = move _2 as *const fn() (Misc); -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/reify_fn_ptr/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/reify_fn_ptr/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..7a41a8ad74e --- /dev/null +++ b/src/test/mir-opt/const_prop/reify_fn_ptr/rustc.main.ConstProp.diff @@ -0,0 +1,32 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/reify_fn_ptr.rs:3:11: 3:11 + let mut _1: *const fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:41 + let mut _2: usize; // in scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:26 + let mut _3: fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:17 + scope 1 { + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:41 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:26 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:17 + _3 = const main as fn() (Pointer(ReifyFnPointer)); // bb0[3]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:17 + // ty::Const + // + ty: fn() {main} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/reify_fn_ptr.rs:4:13: 4:17 + // + literal: Const { ty: fn() {main}, val: Value(Scalar(<ZST>)) } + _2 = move _3 as usize (Misc); // bb0[4]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:26 + StorageDead(_3); // bb0[5]: scope 0 at $DIR/reify_fn_ptr.rs:4:25: 4:26 + _1 = move _2 as *const fn() (Misc); // bb0[6]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:41 + StorageDead(_2); // bb0[7]: scope 0 at $DIR/reify_fn_ptr.rs:4:40: 4:41 + StorageDead(_1); // bb0[8]: scope 0 at $DIR/reify_fn_ptr.rs:4:41: 4:42 + _0 = (); // bb0[9]: scope 0 at $DIR/reify_fn_ptr.rs:3:11: 5:2 + return; // bb0[10]: scope 0 at $DIR/reify_fn_ptr.rs:5:2: 5:2 + } + } + diff --git a/src/test/mir-opt/const_prop/repeat.rs b/src/test/mir-opt/const_prop/repeat.rs index 48c06290cec..31d03fa326c 100644 --- a/src/test/mir-opt/const_prop/repeat.rs +++ b/src/test/mir-opt/const_prop/repeat.rs @@ -1,37 +1,6 @@ // compile-flags: -O +// EMIT_MIR rustc.main.ConstProp.diff fn main() { let x: u32 = [42; 8][2] + 0; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _3 = [const 42u32; 8]; -// ... -// _4 = const 2usize; -// _5 = const 8usize; -// _6 = Lt(_4, _5); -// assert(move _6, "index out of bounds: the len is move _5 but the index is _4") -> bb1; -// } -// bb1: { -// _2 = _3[_4]; -// _1 = Add(move _2, const 0u32); -// ... -// return; -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _6 = const true; -// assert(const true, "index out of bounds: the len is move _5 but the index is _4") -> bb1; -// } -// bb1: { -// _2 = const 42u32; -// _1 = const 42u32; -// ... -// return; -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/repeat/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/repeat/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..16eb2c807a7 --- /dev/null +++ b/src/test/mir-opt/const_prop/repeat/rustc.main.ConstProp.diff @@ -0,0 +1,88 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/repeat.rs:4:11: 4:11 + let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/repeat.rs:5:9: 5:10 + let mut _2: u32; // in scope 0 at $DIR/repeat.rs:5:18: 5:28 + let mut _3: [u32; 8]; // in scope 0 at $DIR/repeat.rs:5:18: 5:25 + let _4: usize; // in scope 0 at $DIR/repeat.rs:5:26: 5:27 + let mut _5: usize; // in scope 0 at $DIR/repeat.rs:5:18: 5:28 + let mut _6: bool; // in scope 0 at $DIR/repeat.rs:5:18: 5:28 + scope 1 { + debug x => _1; // in scope 1 at $DIR/repeat.rs:5:9: 5:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/repeat.rs:5:9: 5:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/repeat.rs:5:18: 5:28 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/repeat.rs:5:18: 5:25 + _3 = [const 42u32; 8]; // bb0[3]: scope 0 at $DIR/repeat.rs:5:18: 5:25 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/repeat.rs:5:19: 5:21 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } + StorageLive(_4); // bb0[4]: scope 0 at $DIR/repeat.rs:5:26: 5:27 + _4 = const 2usize; // bb0[5]: scope 0 at $DIR/repeat.rs:5:26: 5:27 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000002)) + // mir::Constant + // + span: $DIR/repeat.rs:5:26: 5:27 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000002)) } + _5 = const 8usize; // bb0[6]: scope 0 at $DIR/repeat.rs:5:18: 5:28 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000008)) + // mir::Constant + // + span: $DIR/repeat.rs:5:18: 5:28 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000008)) } +- _6 = Lt(_4, _5); // bb0[7]: scope 0 at $DIR/repeat.rs:5:18: 5:28 +- assert(move _6, "index out of bounds: the len is move _5 but the index is _4") -> bb1; // bb0[8]: scope 0 at $DIR/repeat.rs:5:18: 5:28 ++ _6 = const true; // bb0[7]: scope 0 at $DIR/repeat.rs:5:18: 5:28 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/repeat.rs:5:18: 5:28 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } ++ assert(const true, "index out of bounds: the len is move _5 but the index is _4") -> bb1; // bb0[8]: scope 0 at $DIR/repeat.rs:5:18: 5:28 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/repeat.rs:5:18: 5:28 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + } + + bb1: { +- _2 = _3[_4]; // bb1[0]: scope 0 at $DIR/repeat.rs:5:18: 5:28 +- _1 = Add(move _2, const 0u32); // bb1[1]: scope 0 at $DIR/repeat.rs:5:18: 5:32 ++ _2 = const 42u32; // bb1[0]: scope 0 at $DIR/repeat.rs:5:18: 5:28 + // ty::Const + // + ty: u32 +- // + val: Value(Scalar(0x00000000)) ++ // + val: Value(Scalar(0x0000002a)) + // mir::Constant +- // + span: $DIR/repeat.rs:5:31: 5:32 +- // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } ++ // + span: $DIR/repeat.rs:5:18: 5:28 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } ++ _1 = const 42u32; // bb1[1]: scope 0 at $DIR/repeat.rs:5:18: 5:32 ++ // ty::Const ++ // + ty: u32 ++ // + val: Value(Scalar(0x0000002a)) ++ // mir::Constant ++ // + span: $DIR/repeat.rs:5:18: 5:32 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } + StorageDead(_2); // bb1[2]: scope 0 at $DIR/repeat.rs:5:31: 5:32 + StorageDead(_4); // bb1[3]: scope 0 at $DIR/repeat.rs:5:32: 5:33 + StorageDead(_3); // bb1[4]: scope 0 at $DIR/repeat.rs:5:32: 5:33 + _0 = (); // bb1[5]: scope 0 at $DIR/repeat.rs:4:11: 6:2 + StorageDead(_1); // bb1[6]: scope 0 at $DIR/repeat.rs:6:1: 6:2 + return; // bb1[7]: scope 0 at $DIR/repeat.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/return_place.rs b/src/test/mir-opt/const_prop/return_place.rs index ea7c1e7ccd0..8d5b63b9afd 100644 --- a/src/test/mir-opt/const_prop/return_place.rs +++ b/src/test/mir-opt/const_prop/return_place.rs @@ -1,5 +1,7 @@ // compile-flags: -C overflow-checks=on +// EMIT_MIR rustc.add.ConstProp.diff +// EMIT_MIR rustc.add.PreCodegen.before.mir fn add() -> u32 { 2 + 2 } @@ -7,42 +9,3 @@ fn add() -> u32 { fn main() { add(); } - -// END RUST SOURCE -// START rustc.add.ConstProp.before.mir -// fn add() -> u32 { -// let mut _0: u32; -// let mut _1: (u32, bool); -// bb0: { -// _1 = CheckedAdd(const 2u32, const 2u32); -// assert(!move (_1.1: bool), "attempt to add with overflow") -> bb1; -// } -// bb1: { -// _0 = move (_1.0: u32); -// return; -// } -// } -// END rustc.add.ConstProp.before.mir -// START rustc.add.ConstProp.after.mir -// fn add() -> u32 { -// let mut _0: u32; -// let mut _1: (u32, bool); -// bb0: { -// _1 = (const 4u32, const false); -// assert(!const false, "attempt to add with overflow") -> bb1; -// } -// bb1: { -// _0 = const 4u32; -// return; -// } -// } -// END rustc.add.ConstProp.after.mir -// START rustc.add.PreCodegen.before.mir -// fn add() -> u32 { -// let mut _0: u32; -// bb0: { -// _0 = const 4u32; -// return; -// } -// } -// END rustc.add.PreCodegen.before.mir diff --git a/src/test/mir-opt/const_prop/return_place/rustc.add.ConstProp.diff b/src/test/mir-opt/const_prop/return_place/rustc.add.ConstProp.diff new file mode 100644 index 00000000000..3453c424a36 --- /dev/null +++ b/src/test/mir-opt/const_prop/return_place/rustc.add.ConstProp.diff @@ -0,0 +1,52 @@ +- // MIR for `add` before ConstProp ++ // MIR for `add` after ConstProp + + fn add() -> u32 { + let mut _0: u32; // return place in scope 0 at $DIR/return_place.rs:5:13: 5:16 + let mut _1: (u32, bool); // in scope 0 at $DIR/return_place.rs:6:5: 6:10 + + bb0: { +- _1 = CheckedAdd(const 2u32, const 2u32); // bb0[0]: scope 0 at $DIR/return_place.rs:6:5: 6:10 ++ _1 = (const 4u32, const false); // bb0[0]: scope 0 at $DIR/return_place.rs:6:5: 6:10 + // ty::Const + // + ty: u32 +- // + val: Value(Scalar(0x00000002)) ++ // + val: Value(Scalar(0x00000004)) + // mir::Constant +- // + span: $DIR/return_place.rs:6:5: 6:6 +- // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } ++ // + span: $DIR/return_place.rs:6:5: 6:10 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x00000004)) } + // ty::Const +- // + ty: u32 +- // + val: Value(Scalar(0x00000002)) ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) + // mir::Constant +- // + span: $DIR/return_place.rs:6:9: 6:10 +- // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } +- assert(!move (_1.1: bool), "attempt to add with overflow") -> bb1; // bb0[1]: scope 0 at $DIR/return_place.rs:6:5: 6:10 ++ // + span: $DIR/return_place.rs:6:5: 6:10 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } ++ assert(!const false, "attempt to add with overflow") -> bb1; // bb0[1]: scope 0 at $DIR/return_place.rs:6:5: 6:10 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) ++ // mir::Constant ++ // + span: $DIR/return_place.rs:6:5: 6:10 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + } + + bb1: { +- _0 = move (_1.0: u32); // bb1[0]: scope 0 at $DIR/return_place.rs:6:5: 6:10 ++ _0 = const 4u32; // bb1[0]: scope 0 at $DIR/return_place.rs:6:5: 6:10 ++ // ty::Const ++ // + ty: u32 ++ // + val: Value(Scalar(0x00000004)) ++ // mir::Constant ++ // + span: $DIR/return_place.rs:6:5: 6:10 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x00000004)) } + return; // bb1[1]: scope 0 at $DIR/return_place.rs:7:2: 7:2 + } + } + diff --git a/src/test/mir-opt/const_prop/return_place/rustc.add.PreCodegen.before.mir b/src/test/mir-opt/const_prop/return_place/rustc.add.PreCodegen.before.mir new file mode 100644 index 00000000000..9af6be771ed --- /dev/null +++ b/src/test/mir-opt/const_prop/return_place/rustc.add.PreCodegen.before.mir @@ -0,0 +1,16 @@ +// MIR for `add` before PreCodegen + +fn add() -> u32 { + let mut _0: u32; // return place in scope 0 at $DIR/return_place.rs:5:13: 5:16 + + bb0: { + _0 = const 4u32; // bb0[0]: scope 0 at $DIR/return_place.rs:6:5: 6:10 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000004)) + // mir::Constant + // + span: $DIR/return_place.rs:6:5: 6:10 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000004)) } + return; // bb0[1]: scope 0 at $DIR/return_place.rs:7:2: 7:2 + } +} diff --git a/src/test/mir-opt/const_prop/slice_len.rs b/src/test/mir-opt/const_prop/slice_len.rs index 43813e43d36..20c106add57 100644 --- a/src/test/mir-opt/const_prop/slice_len.rs +++ b/src/test/mir-opt/const_prop/slice_len.rs @@ -1,43 +1,5 @@ +// EMIT_MIR rustc.main.ConstProp.diff + fn main() { (&[1u32, 2, 3] as &[u32])[1]; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _9 = const main::promoted[0]; -// _4 = _9; -// _3 = _4; -// _2 = move _3 as &[u32] (Pointer(Unsize)); -// ... -// _6 = const 1usize; -// _7 = Len((*_2)); -// _8 = Lt(_6, _7); -// assert(move _8, "index out of bounds: the len is move _7 but the index is _6") -> bb1; -// } -// bb1: { -// _1 = (*_2)[_6]; -// ... -// return; -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _9 = const main::promoted[0]; -// _4 = _9; -// _3 = _4; -// _2 = move _3 as &[u32] (Pointer(Unsize)); -// ... -// _6 = const 1usize; -// _7 = const 3usize; -// _8 = const true; -// assert(const true, "index out of bounds: the len is move _7 but the index is _6") -> bb1; -// } -// bb1: { -// _1 = const 2u32; -// ... -// return; -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/slice_len/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/slice_len/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..8946c271d6e --- /dev/null +++ b/src/test/mir-opt/const_prop/slice_len/rustc.main.ConstProp.diff @@ -0,0 +1,83 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/slice_len.rs:3:11: 3:11 + let _1: u32; // in scope 0 at $DIR/slice_len.rs:4:5: 4:33 + let mut _2: &[u32]; // in scope 0 at $DIR/slice_len.rs:4:5: 4:30 + let mut _3: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:4:6: 4:19 + let _4: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:4:6: 4:19 + let _5: [u32; 3]; // in scope 0 at $DIR/slice_len.rs:4:7: 4:19 + let _6: usize; // in scope 0 at $DIR/slice_len.rs:4:31: 4:32 + let mut _7: usize; // in scope 0 at $DIR/slice_len.rs:4:5: 4:33 + let mut _8: bool; // in scope 0 at $DIR/slice_len.rs:4:5: 4:33 + let mut _9: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:4:6: 4:19 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/slice_len.rs:4:5: 4:33 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/slice_len.rs:4:5: 4:30 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/slice_len.rs:4:6: 4:19 + StorageLive(_4); // bb0[3]: scope 0 at $DIR/slice_len.rs:4:6: 4:19 + _9 = const main::promoted[0]; // bb0[4]: scope 0 at $DIR/slice_len.rs:4:6: 4:19 + // ty::Const + // + ty: &[u32; 3] + // + val: Unevaluated(DefId(0:3 ~ slice_len[317d]::main[0]), [], Some(promoted[0])) + // mir::Constant + // + span: $DIR/slice_len.rs:4:6: 4:19 + // + literal: Const { ty: &[u32; 3], val: Unevaluated(DefId(0:3 ~ slice_len[317d]::main[0]), [], Some(promoted[0])) } + _4 = _9; // bb0[5]: scope 0 at $DIR/slice_len.rs:4:6: 4:19 + _3 = _4; // bb0[6]: scope 0 at $DIR/slice_len.rs:4:6: 4:19 + _2 = move _3 as &[u32] (Pointer(Unsize)); // bb0[7]: scope 0 at $DIR/slice_len.rs:4:6: 4:19 + StorageDead(_3); // bb0[8]: scope 0 at $DIR/slice_len.rs:4:18: 4:19 + StorageLive(_6); // bb0[9]: scope 0 at $DIR/slice_len.rs:4:31: 4:32 + _6 = const 1usize; // bb0[10]: scope 0 at $DIR/slice_len.rs:4:31: 4:32 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000001)) + // mir::Constant + // + span: $DIR/slice_len.rs:4:31: 4:32 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) } +- _7 = Len((*_2)); // bb0[11]: scope 0 at $DIR/slice_len.rs:4:5: 4:33 +- _8 = Lt(_6, _7); // bb0[12]: scope 0 at $DIR/slice_len.rs:4:5: 4:33 +- assert(move _8, "index out of bounds: the len is move _7 but the index is _6") -> bb1; // bb0[13]: scope 0 at $DIR/slice_len.rs:4:5: 4:33 ++ _7 = const 3usize; // bb0[11]: scope 0 at $DIR/slice_len.rs:4:5: 4:33 ++ // ty::Const ++ // + ty: usize ++ // + val: Value(Scalar(0x0000000000000003)) ++ // mir::Constant ++ // + span: $DIR/slice_len.rs:4:5: 4:33 ++ // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000003)) } ++ _8 = const true; // bb0[12]: scope 0 at $DIR/slice_len.rs:4:5: 4:33 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/slice_len.rs:4:5: 4:33 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } ++ assert(const true, "index out of bounds: the len is move _7 but the index is _6") -> bb1; // bb0[13]: scope 0 at $DIR/slice_len.rs:4:5: 4:33 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/slice_len.rs:4:5: 4:33 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + } + + bb1: { +- _1 = (*_2)[_6]; // bb1[0]: scope 0 at $DIR/slice_len.rs:4:5: 4:33 ++ _1 = const 2u32; // bb1[0]: scope 0 at $DIR/slice_len.rs:4:5: 4:33 ++ // ty::Const ++ // + ty: u32 ++ // + val: Value(Scalar(0x00000002)) ++ // mir::Constant ++ // + span: $DIR/slice_len.rs:4:5: 4:33 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageDead(_6); // bb1[1]: scope 0 at $DIR/slice_len.rs:4:33: 4:34 + StorageDead(_4); // bb1[2]: scope 0 at $DIR/slice_len.rs:4:33: 4:34 + StorageDead(_2); // bb1[3]: scope 0 at $DIR/slice_len.rs:4:33: 4:34 + StorageDead(_1); // bb1[4]: scope 0 at $DIR/slice_len.rs:4:33: 4:34 + _0 = (); // bb1[5]: scope 0 at $DIR/slice_len.rs:3:11: 5:2 + return; // bb1[6]: scope 0 at $DIR/slice_len.rs:5:2: 5:2 + } + } + diff --git a/src/test/mir-opt/const_prop/switch_int.rs b/src/test/mir-opt/const_prop/switch_int.rs index 904d303d87e..46e6efb8180 100644 --- a/src/test/mir-opt/const_prop/switch_int.rs +++ b/src/test/mir-opt/const_prop/switch_int.rs @@ -1,38 +1,11 @@ #[inline(never)] fn foo(_: i32) { } +// EMIT_MIR rustc.main.ConstProp.diff +// EMIT_MIR rustc.main.SimplifyBranches-after-const-prop.diff fn main() { match 1 { 1 => foo(0), _ => foo(-1), } } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _1 = const 1i32; -// switchInt(_1) -> [1i32: bb2, otherwise: bb1]; -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// switchInt(const 1i32) -> [1i32: bb2, otherwise: bb1]; -// } -// END rustc.main.ConstProp.after.mir -// START rustc.main.SimplifyBranches-after-const-prop.before.mir -// bb0: { -// ... -// _1 = const 1i32; -// switchInt(const 1i32) -> [1i32: bb2, otherwise: bb1]; -// } -// END rustc.main.SimplifyBranches-after-const-prop.before.mir -// START rustc.main.SimplifyBranches-after-const-prop.after.mir -// bb0: { -// ... -// _1 = const 1i32; -// goto -> bb2; -// } -// END rustc.main.SimplifyBranches-after-const-prop.after.mir diff --git a/src/test/mir-opt/const_prop/switch_int/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/switch_int/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..92b14309bf2 --- /dev/null +++ b/src/test/mir-opt/const_prop/switch_int/rustc.main.ConstProp.diff @@ -0,0 +1,64 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/switch_int.rs:6:11: 6:11 + let mut _1: i32; // in scope 0 at $DIR/switch_int.rs:7:11: 7:12 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/switch_int.rs:7:11: 7:12 + _1 = const 1i32; // bb0[1]: scope 0 at $DIR/switch_int.rs:7:11: 7:12 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/switch_int.rs:7:11: 7:12 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } +- switchInt(_1) -> [1i32: bb2, otherwise: bb1]; // bb0[2]: scope 0 at $DIR/switch_int.rs:8:9: 8:10 ++ switchInt(const 1i32) -> [1i32: bb2, otherwise: bb1]; // bb0[2]: scope 0 at $DIR/switch_int.rs:8:9: 8:10 ++ // ty::Const ++ // + ty: i32 ++ // + val: Value(Scalar(0x00000001)) ++ // mir::Constant ++ // + span: $DIR/switch_int.rs:8:9: 8:10 ++ // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + } + + bb1: { + _0 = const foo(const -1i32) -> bb3; // bb1[0]: scope 0 at $DIR/switch_int.rs:9:14: 9:21 + // ty::Const + // + ty: fn(i32) {foo} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/switch_int.rs:9:14: 9:17 + // + literal: Const { ty: fn(i32) {foo}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0xffffffff)) + // mir::Constant + // + span: $DIR/switch_int.rs:9:18: 9:20 + // + literal: Const { ty: i32, val: Value(Scalar(0xffffffff)) } + } + + bb2: { + _0 = const foo(const 0i32) -> bb3; // bb2[0]: scope 0 at $DIR/switch_int.rs:8:14: 8:20 + // ty::Const + // + ty: fn(i32) {foo} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/switch_int.rs:8:14: 8:17 + // + literal: Const { ty: fn(i32) {foo}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/switch_int.rs:8:18: 8:19 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + } + + bb3: { + StorageDead(_1); // bb3[0]: scope 0 at $DIR/switch_int.rs:11:1: 11:2 + return; // bb3[1]: scope 0 at $DIR/switch_int.rs:11:2: 11:2 + } + } + diff --git a/src/test/mir-opt/const_prop/switch_int/rustc.main.SimplifyBranches-after-const-prop.diff b/src/test/mir-opt/const_prop/switch_int/rustc.main.SimplifyBranches-after-const-prop.diff new file mode 100644 index 00000000000..e1805cc5731 --- /dev/null +++ b/src/test/mir-opt/const_prop/switch_int/rustc.main.SimplifyBranches-after-const-prop.diff @@ -0,0 +1,64 @@ +- // MIR for `main` before SimplifyBranches-after-const-prop ++ // MIR for `main` after SimplifyBranches-after-const-prop + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/switch_int.rs:6:11: 6:11 + let mut _1: i32; // in scope 0 at $DIR/switch_int.rs:7:11: 7:12 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/switch_int.rs:7:11: 7:12 + _1 = const 1i32; // bb0[1]: scope 0 at $DIR/switch_int.rs:7:11: 7:12 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/switch_int.rs:7:11: 7:12 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } +- switchInt(const 1i32) -> [1i32: bb2, otherwise: bb1]; // bb0[2]: scope 0 at $DIR/switch_int.rs:8:9: 8:10 +- // ty::Const +- // + ty: i32 +- // + val: Value(Scalar(0x00000001)) +- // mir::Constant +- // + span: $DIR/switch_int.rs:8:9: 8:10 +- // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } ++ goto -> bb2; // bb0[2]: scope 0 at $DIR/switch_int.rs:8:9: 8:10 + } + + bb1: { + _0 = const foo(const -1i32) -> bb3; // bb1[0]: scope 0 at $DIR/switch_int.rs:9:14: 9:21 + // ty::Const + // + ty: fn(i32) {foo} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/switch_int.rs:9:14: 9:17 + // + literal: Const { ty: fn(i32) {foo}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0xffffffff)) + // mir::Constant + // + span: $DIR/switch_int.rs:9:18: 9:20 + // + literal: Const { ty: i32, val: Value(Scalar(0xffffffff)) } + } + + bb2: { + _0 = const foo(const 0i32) -> bb3; // bb2[0]: scope 0 at $DIR/switch_int.rs:8:14: 8:20 + // ty::Const + // + ty: fn(i32) {foo} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/switch_int.rs:8:14: 8:17 + // + literal: Const { ty: fn(i32) {foo}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/switch_int.rs:8:18: 8:19 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + } + + bb3: { + StorageDead(_1); // bb3[0]: scope 0 at $DIR/switch_int.rs:11:1: 11:2 + return; // bb3[1]: scope 0 at $DIR/switch_int.rs:11:2: 11:2 + } + } + diff --git a/src/test/mir-opt/inline/inline-any-operand.rs b/src/test/mir-opt/inline/inline-any-operand.rs index b5455003719..2edde12d72e 100644 --- a/src/test/mir-opt/inline/inline-any-operand.rs +++ b/src/test/mir-opt/inline/inline-any-operand.rs @@ -6,6 +6,7 @@ fn main() { println!("{}", bar()); } +// EMIT_MIR rustc.bar.Inline.after.mir fn bar() -> bool { let f = foo; f(1, -1) @@ -15,15 +16,3 @@ fn bar() -> bool { fn foo(x: i32, y: i32) -> bool { x == y } - -// END RUST SOURCE -// START rustc.bar.Inline.after.mir -// ... -// bb0: { -// ... -// _0 = Eq(move _3, move _4); -// ... -// return; -// } -// ... -// END rustc.bar.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-any-operand/rustc.bar.Inline.after.mir b/src/test/mir-opt/inline/inline-any-operand/rustc.bar.Inline.after.mir new file mode 100644 index 00000000000..058d9e70d26 --- /dev/null +++ b/src/test/mir-opt/inline/inline-any-operand/rustc.bar.Inline.after.mir @@ -0,0 +1,47 @@ +// MIR for `bar` after Inline + +fn bar() -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/inline-any-operand.rs:10:13: 10:17 + let _1: fn(i32, i32) -> bool {foo}; // in scope 0 at $DIR/inline-any-operand.rs:11:9: 11:10 + let mut _2: fn(i32, i32) -> bool {foo}; // in scope 0 at $DIR/inline-any-operand.rs:12:5: 12:6 + let mut _3: i32; // in scope 0 at $DIR/inline-any-operand.rs:12:5: 12:13 + let mut _4: i32; // in scope 0 at $DIR/inline-any-operand.rs:12:5: 12:13 + scope 1 { + debug f => _1; // in scope 1 at $DIR/inline-any-operand.rs:11:9: 11:10 + scope 2 { + debug x => _3; // in scope 2 at $DIR/inline-any-operand.rs:16:8: 16:9 + debug y => _4; // in scope 2 at $DIR/inline-any-operand.rs:16:16: 16:17 + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/inline-any-operand.rs:11:9: 11:10 + _1 = const foo; // bb0[1]: scope 0 at $DIR/inline-any-operand.rs:11:13: 11:16 + // ty::Const + // + ty: fn(i32, i32) -> bool {foo} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/inline-any-operand.rs:11:13: 11:16 + // + literal: Const { ty: fn(i32, i32) -> bool {foo}, val: Value(Scalar(<ZST>)) } + StorageLive(_2); // bb0[2]: scope 1 at $DIR/inline-any-operand.rs:12:5: 12:6 + _2 = _1; // bb0[3]: scope 1 at $DIR/inline-any-operand.rs:12:5: 12:6 + _3 = const 1i32; // bb0[4]: scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/inline-any-operand.rs:12:7: 12:8 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + _4 = const -1i32; // bb0[5]: scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0xffffffff)) + // mir::Constant + // + span: $DIR/inline-any-operand.rs:12:10: 12:12 + // + literal: Const { ty: i32, val: Value(Scalar(0xffffffff)) } + _0 = Eq(move _3, move _4); // bb0[6]: scope 2 at $DIR/inline-any-operand.rs:17:5: 17:11 + StorageDead(_2); // bb0[7]: scope 1 at $DIR/inline-any-operand.rs:12:12: 12:13 + StorageDead(_1); // bb0[8]: scope 0 at $DIR/inline-any-operand.rs:13:1: 13:2 + return; // bb0[9]: scope 0 at $DIR/inline-any-operand.rs:13:2: 13:2 + } +} diff --git a/src/test/mir-opt/inline/inline-closure-borrows-arg.rs b/src/test/mir-opt/inline/inline-closure-borrows-arg.rs index 768f4953228..a82a91945d8 100644 --- a/src/test/mir-opt/inline/inline-closure-borrows-arg.rs +++ b/src/test/mir-opt/inline/inline-closure-borrows-arg.rs @@ -7,6 +7,7 @@ fn main() { println!("{}", foo(0, &14)); } +// EMIT_MIR rustc.foo.Inline.after.mir fn foo<T: Copy>(_t: T, q: &i32) -> i32 { let x = |r: &i32, _s: &i32| { let variable = &*r; @@ -14,46 +15,3 @@ fn foo<T: Copy>(_t: T, q: &i32) -> i32 { }; x(q, q) } - -// END RUST SOURCE -// START rustc.foo.Inline.after.mir -// fn foo(_1: T, _2: &i32) -> i32{ -// debug _t => _1; -// debug q => _2; -// let mut _0: i32; -// let _3: [closure@foo<T>::{{closure}}#0]; -// let mut _4: &[closure@foo<T>::{{closure}}#0]; -// let mut _5: (&i32, &i32); -// let mut _6: &i32; -// let mut _7: &i32; -// let mut _8: &i32; -// let mut _9: &i32; -// scope 1 { -// debug x => _3; -// scope 2 { -// debug r => _8; -// debug _s => _9; -// } -// } -// scope 3 { -// debug variable => _8; -// } -// bb0: { -// ... -// _3 = [closure@foo::<T>::{{closure}}#0]; -// ... -// _4 = &_3; -// ... -// _6 = &(*_2); -// ... -// _7 = &(*_2); -// _5 = (move _6, move _7); -// _8 = move (_5.0: &i32); -// _9 = move (_5.1: &i32); -// ... -// _0 = (*_8); -// ... -// return; -// } -// } -// END rustc.foo.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-closure-borrows-arg/rustc.foo.Inline.after.mir b/src/test/mir-opt/inline/inline-closure-borrows-arg/rustc.foo.Inline.after.mir new file mode 100644 index 00000000000..a8e846d1181 --- /dev/null +++ b/src/test/mir-opt/inline/inline-closure-borrows-arg/rustc.foo.Inline.after.mir @@ -0,0 +1,54 @@ +// MIR for `foo` after Inline + +fn foo(_1: T, _2: &i32) -> i32 { + debug _t => _1; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:11:17: 11:19 + debug q => _2; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:11:24: 11:25 + let mut _0: i32; // return place in scope 0 at $DIR/inline-closure-borrows-arg.rs:11:36: 11:39 + let _3: [closure@foo<T>::{{closure}}#0]; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:12:9: 12:10 + let mut _4: &[closure@foo<T>::{{closure}}#0]; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6 + let mut _5: (&i32, &i32); // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + let mut _6: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:7: 16:8 + let mut _7: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11 + let mut _8: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + let mut _9: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + scope 1 { + debug x => _3; // in scope 1 at $DIR/inline-closure-borrows-arg.rs:12:9: 12:10 + scope 2 { + debug r => _8; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:12:14: 12:15 + debug _s => _9; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:12:23: 12:25 + } + } + scope 3 { + debug variable => _8; // in scope 3 at $DIR/inline-closure-borrows-arg.rs:13:13: 13:21 + } + + bb0: { + StorageLive(_3); // bb0[0]: scope 0 at $DIR/inline-closure-borrows-arg.rs:12:9: 12:10 + _3 = [closure@foo::<T>::{{closure}}#0]; // bb0[1]: 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); // bb0[2]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6 + _4 = &_3; // bb0[3]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6 + StorageLive(_5); // bb0[4]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + StorageLive(_6); // bb0[5]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:7: 16:8 + _6 = &(*_2); // bb0[6]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:7: 16:8 + StorageLive(_7); // bb0[7]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11 + _7 = &(*_2); // bb0[8]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11 + _5 = (move _6, move _7); // bb0[9]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + _8 = move (_5.0: &i32); // bb0[10]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + _9 = move (_5.1: &i32); // bb0[11]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + _0 = (*_8); // bb0[12]: scope 3 at $DIR/inline-closure-borrows-arg.rs:14:9: 14:18 + StorageDead(_7); // bb0[13]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12 + StorageDead(_6); // bb0[14]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12 + StorageDead(_5); // bb0[15]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12 + StorageDead(_4); // bb0[16]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12 + StorageDead(_3); // bb0[17]: scope 0 at $DIR/inline-closure-borrows-arg.rs:17:1: 17:2 + return; // bb0[18]: scope 0 at $DIR/inline-closure-borrows-arg.rs:17:2: 17:2 + } +} diff --git a/src/test/mir-opt/inline/inline-closure-captures.rs b/src/test/mir-opt/inline/inline-closure-captures.rs index e000a418d90..4a0aad9b0e6 100644 --- a/src/test/mir-opt/inline/inline-closure-captures.rs +++ b/src/test/mir-opt/inline/inline-closure-captures.rs @@ -6,55 +6,8 @@ fn main() { println!("{:?}", foo(0, 14)); } +// EMIT_MIR rustc.foo.Inline.after.mir fn foo<T: Copy>(t: T, q: i32) -> (i32, T) { let x = |_q| (q, t); x(q) } - -// END RUST SOURCE -// START rustc.foo.Inline.after.mir -// fn foo(_1: T, _2: i32) -> (i32, T){ -// debug t => _1; -// debug q => _2; -// let mut _0: (i32, T); -// let _3: [closure@foo<T>::{{closure}}#0 q:&i32, t:&T]; -// let mut _4: &i32; -// let mut _5: &T; -// let mut _6: &[closure@foo<T>::{{closure}}#0 q:&i32, t:&T]; -// let mut _7: (i32,); -// let mut _8: i32; -// let mut _11: i32; -// scope 1 { -// debug x => _3; -// scope 2 { -// debug _q => _11; -// debug q => (*((*_6).0: &i32)); -// debug t => (*((*_6).1: &T)); -// let mut _9: i32; -// let mut _10: T; -// } -// } -// bb0: { -// ... -// _4 = &_2; -// ... -// _5 = &_1; -// _3 = [closure@foo::<T>::{{closure}}#0] { q: move _4, t: move _5 }; -// ... -// _6 = &_3; -// ... -// ... -// _8 = _2; -// _7 = (move _8,); -// _11 = move (_7.0: i32); -// ... -// _9 = (*((*_6).0: &i32)); -// ... -// _10 = (*((*_6).1: &T)); -// (_0.0: i32) = move _9; -// (_0.1: T) = move _10; -// ... -// return; -// } -// } -// END rustc.foo.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-closure-captures/rustc.foo.Inline.after.mir b/src/test/mir-opt/inline/inline-closure-captures/rustc.foo.Inline.after.mir new file mode 100644 index 00000000000..8f7c5615662 --- /dev/null +++ b/src/test/mir-opt/inline/inline-closure-captures/rustc.foo.Inline.after.mir @@ -0,0 +1,63 @@ +// MIR for `foo` after Inline + +fn foo(_1: T, _2: i32) -> (i32, T) { + debug t => _1; // in scope 0 at $DIR/inline-closure-captures.rs:10:17: 10:18 + debug q => _2; // in scope 0 at $DIR/inline-closure-captures.rs:10:23: 10:24 + let mut _0: (i32, T); // return place in scope 0 at $DIR/inline-closure-captures.rs:10:34: 10:42 + let _3: [closure@foo<T>::{{closure}}#0 q:&i32, t:&T]; // in scope 0 at $DIR/inline-closure-captures.rs:11:9: 11:10 + let mut _4: &i32; // in scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + let mut _5: &T; // in scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + let mut _6: &[closure@foo<T>::{{closure}}#0 q:&i32, t:&T]; // in scope 0 at $DIR/inline-closure-captures.rs:12:5: 12:6 + let mut _7: (i32,); // in scope 0 at $DIR/inline-closure-captures.rs:12:5: 12:9 + let mut _8: i32; // in scope 0 at $DIR/inline-closure-captures.rs:12:7: 12:8 + let mut _11: i32; // in scope 0 at $DIR/inline-closure-captures.rs:12:5: 12:9 + scope 1 { + debug x => _3; // in scope 1 at $DIR/inline-closure-captures.rs:11:9: 11:10 + scope 2 { + debug _q => _11; // in scope 2 at $DIR/inline-closure-captures.rs:11:14: 11:16 + debug q => (*((*_6).0: &i32)); // in scope 2 at $DIR/inline-closure-captures.rs:10:23: 10:24 + debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline-closure-captures.rs:10:17: 10:18 + let mut _9: i32; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + let mut _10: T; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + } + } + + bb0: { + StorageLive(_3); // bb0[0]: scope 0 at $DIR/inline-closure-captures.rs:11:9: 11:10 + StorageLive(_4); // bb0[1]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + _4 = &_2; // bb0[2]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + StorageLive(_5); // bb0[3]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + _5 = &_1; // bb0[4]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + _3 = [closure@foo::<T>::{{closure}}#0] { q: move _4, t: move _5 }; // bb0[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), + // ] + StorageDead(_5); // bb0[6]: scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24 + StorageDead(_4); // bb0[7]: scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24 + StorageLive(_6); // bb0[8]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:6 + _6 = &_3; // bb0[9]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:6 + StorageLive(_7); // bb0[10]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 + StorageLive(_8); // bb0[11]: scope 1 at $DIR/inline-closure-captures.rs:12:7: 12:8 + _8 = _2; // bb0[12]: scope 1 at $DIR/inline-closure-captures.rs:12:7: 12:8 + _7 = (move _8,); // bb0[13]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 + _11 = move (_7.0: i32); // bb0[14]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 + StorageLive(_9); // bb0[15]: scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20 + _9 = (*((*_6).0: &i32)); // bb0[16]: scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20 + StorageLive(_10); // bb0[17]: scope 2 at $DIR/inline-closure-captures.rs:11:22: 11:23 + _10 = (*((*_6).1: &T)); // bb0[18]: scope 2 at $DIR/inline-closure-captures.rs:11:22: 11:23 + (_0.0: i32) = move _9; // bb0[19]: scope 2 at $DIR/inline-closure-captures.rs:11:18: 11:24 + (_0.1: T) = move _10; // bb0[20]: scope 2 at $DIR/inline-closure-captures.rs:11:18: 11:24 + StorageDead(_10); // bb0[21]: scope 2 at $DIR/inline-closure-captures.rs:11:23: 11:24 + StorageDead(_9); // bb0[22]: scope 2 at $DIR/inline-closure-captures.rs:11:23: 11:24 + StorageDead(_8); // bb0[23]: scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9 + StorageDead(_7); // bb0[24]: scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9 + StorageDead(_6); // bb0[25]: scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9 + StorageDead(_3); // bb0[26]: scope 0 at $DIR/inline-closure-captures.rs:13:1: 13:2 + return; // bb0[27]: scope 0 at $DIR/inline-closure-captures.rs:13:2: 13:2 + } +} diff --git a/src/test/mir-opt/inline/inline-closure.rs b/src/test/mir-opt/inline/inline-closure.rs index bd36e77818e..77e424a2bb3 100644 --- a/src/test/mir-opt/inline/inline-closure.rs +++ b/src/test/mir-opt/inline/inline-closure.rs @@ -6,45 +6,8 @@ fn main() { println!("{}", foo(0, 14)); } +// EMIT_MIR rustc.foo.Inline.after.mir fn foo<T: Copy>(_t: T, q: i32) -> i32 { let x = |_t, _q| _t; x(q, q) } - -// END RUST SOURCE -// START rustc.foo.Inline.after.mir -// fn foo(_1: T, _2: i32) -> i32{ -// debug _t => _1; -// debug q => _2; -// let mut _0: i32; -// let _3: [closure@foo<T>::{{closure}}#0]; -// let mut _4: &[closure@foo<T>::{{closure}}#0]; -// let mut _5: (i32, i32); -// let mut _6: i32; -// let mut _7: i32; -// let mut _8: i32; -// let mut _9: i32; -// scope 1 { -// debug x => _3; -// scope 2 { -// debug _t => _8; -// debug _q => _9; -// } -// } -// bb0: { -// ... -// _3 = [closure@foo::<T>::{{closure}}#0]; -// ... -// _4 = &_3; -// ... -// _6 = _2; -// ... -// _7 = _2; -// _5 = (move _6, move _7); -// _8 = move (_5.0: i32); -// _9 = move (_5.1: i32); -// _0 = _8; -// ... -// return; -// } -// END rustc.foo.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-closure/rustc.foo.Inline.after.mir b/src/test/mir-opt/inline/inline-closure/rustc.foo.Inline.after.mir new file mode 100644 index 00000000000..e31032e8c69 --- /dev/null +++ b/src/test/mir-opt/inline/inline-closure/rustc.foo.Inline.after.mir @@ -0,0 +1,51 @@ +// MIR for `foo` after Inline + +fn foo(_1: T, _2: i32) -> i32 { + debug _t => _1; // in scope 0 at $DIR/inline-closure.rs:10:17: 10:19 + debug q => _2; // in scope 0 at $DIR/inline-closure.rs:10:24: 10:25 + let mut _0: i32; // return place in scope 0 at $DIR/inline-closure.rs:10:35: 10:38 + let _3: [closure@foo<T>::{{closure}}#0]; // in scope 0 at $DIR/inline-closure.rs:11:9: 11:10 + let mut _4: &[closure@foo<T>::{{closure}}#0]; // in scope 0 at $DIR/inline-closure.rs:12:5: 12:6 + let mut _5: (i32, i32); // in scope 0 at $DIR/inline-closure.rs:12:5: 12:12 + let mut _6: i32; // in scope 0 at $DIR/inline-closure.rs:12:7: 12:8 + let mut _7: i32; // in scope 0 at $DIR/inline-closure.rs:12:10: 12:11 + let mut _8: i32; // in scope 0 at $DIR/inline-closure.rs:12:5: 12:12 + let mut _9: i32; // in scope 0 at $DIR/inline-closure.rs:12:5: 12:12 + scope 1 { + debug x => _3; // in scope 1 at $DIR/inline-closure.rs:11:9: 11:10 + scope 2 { + debug _t => _8; // in scope 2 at $DIR/inline-closure.rs:11:14: 11:16 + debug _q => _9; // in scope 2 at $DIR/inline-closure.rs:11:18: 11:20 + } + } + + bb0: { + StorageLive(_3); // bb0[0]: scope 0 at $DIR/inline-closure.rs:11:9: 11:10 + _3 = [closure@foo::<T>::{{closure}}#0]; // bb0[1]: 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); // bb0[2]: scope 1 at $DIR/inline-closure.rs:12:5: 12:6 + _4 = &_3; // bb0[3]: scope 1 at $DIR/inline-closure.rs:12:5: 12:6 + StorageLive(_5); // bb0[4]: scope 1 at $DIR/inline-closure.rs:12:5: 12:12 + StorageLive(_6); // bb0[5]: scope 1 at $DIR/inline-closure.rs:12:7: 12:8 + _6 = _2; // bb0[6]: scope 1 at $DIR/inline-closure.rs:12:7: 12:8 + StorageLive(_7); // bb0[7]: scope 1 at $DIR/inline-closure.rs:12:10: 12:11 + _7 = _2; // bb0[8]: scope 1 at $DIR/inline-closure.rs:12:10: 12:11 + _5 = (move _6, move _7); // bb0[9]: scope 1 at $DIR/inline-closure.rs:12:5: 12:12 + _8 = move (_5.0: i32); // bb0[10]: scope 1 at $DIR/inline-closure.rs:12:5: 12:12 + _9 = move (_5.1: i32); // bb0[11]: scope 1 at $DIR/inline-closure.rs:12:5: 12:12 + _0 = _8; // bb0[12]: scope 2 at $DIR/inline-closure.rs:11:22: 11:24 + StorageDead(_7); // bb0[13]: scope 1 at $DIR/inline-closure.rs:12:11: 12:12 + StorageDead(_6); // bb0[14]: scope 1 at $DIR/inline-closure.rs:12:11: 12:12 + StorageDead(_5); // bb0[15]: scope 1 at $DIR/inline-closure.rs:12:11: 12:12 + StorageDead(_4); // bb0[16]: scope 1 at $DIR/inline-closure.rs:12:11: 12:12 + StorageDead(_3); // bb0[17]: scope 0 at $DIR/inline-closure.rs:13:1: 13:2 + return; // bb0[18]: scope 0 at $DIR/inline-closure.rs:13:2: 13:2 + } +} diff --git a/src/test/mir-opt/inline/inline-into-box-place.rs b/src/test/mir-opt/inline/inline-into-box-place.rs index fcb7b4c4fe6..d36d93cd01c 100644 --- a/src/test/mir-opt/inline/inline-into-box-place.rs +++ b/src/test/mir-opt/inline/inline-into-box-place.rs @@ -1,73 +1,9 @@ -// ignore-tidy-linelength // ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -Z mir-opt-level=3 // only-64bit FIXME: the mir representation of RawVec depends on ptr size #![feature(box_syntax)] +// EMIT_MIR rustc.main.Inline.diff fn main() { let _x: Box<Vec<u32>> = box Vec::new(); } - -// END RUST SOURCE -// START rustc.main.Inline.before.mir -// let mut _0: (); -// let _1: std::boxed::Box<std::vec::Vec<u32>> as UserTypeProjection { base: UserType(0), projs: [] }; -// let mut _2: std::boxed::Box<std::vec::Vec<u32>>; -// let mut _3: (); -// scope 1 { -// debug _x => _1; -// } -// bb0: { -// StorageLive(_1); -// StorageLive(_2); -// _2 = Box(std::vec::Vec<u32>); -// (*_2) = const std::vec::Vec::<u32>::new() -> [return: bb2, unwind: bb4]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { -// _1 = move _2; -// StorageDead(_2); -// _0 = (); -// drop(_1) -> [return: bb3, unwind: bb1]; -// } -// bb3: { -// StorageDead(_1); -// return; -// } -// bb4 (cleanup): { -// _3 = const alloc::alloc::box_free::<std::vec::Vec<u32>>(move (_2.0: std::ptr::Unique<std::vec::Vec<u32>>)) -> bb1; -// } -// END rustc.main.Inline.before.mir -// START rustc.main.Inline.after.mir -// let mut _0: (); -// let _1: std::boxed::Box<std::vec::Vec<u32>> as UserTypeProjection { base: UserType(0), projs: [] }; -// let mut _2: std::boxed::Box<std::vec::Vec<u32>>; -// let mut _3: (); -// let mut _4: &mut std::vec::Vec<u32>; -// scope 1 { -// debug _x => _1; -// } -// scope 2 { -// } -// bb0: { -// StorageLive(_1); -// StorageLive(_2); -// _2 = Box(std::vec::Vec<u32>); -// _4 = &mut (*_2); -// ((*_4).0: alloc::raw_vec::RawVec<u32>) = const ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }: alloc::raw_vec::RawVec::<u32>; -// ((*_4).1: usize) = const 0usize; -// _1 = move _2; -// StorageDead(_2); -// _0 = (); -// drop(_1) -> [return: bb2, unwind: bb1]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { -// StorageDead(_1); -// return; -// } -// END rustc.main.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-into-box-place/rustc.main.Inline.diff b/src/test/mir-opt/inline/inline-into-box-place/rustc.main.Inline.diff new file mode 100644 index 00000000000..a0db20cbb74 --- /dev/null +++ b/src/test/mir-opt/inline/inline-into-box-place/rustc.main.Inline.diff @@ -0,0 +1,76 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/inline-into-box-place.rs:7:11: 7:11 + let _1: std::boxed::Box<std::vec::Vec<u32>> as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/inline-into-box-place.rs:8:9: 8:11 + let mut _2: std::boxed::Box<std::vec::Vec<u32>>; // in scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 + let mut _3: (); // in scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 ++ let mut _4: &mut std::vec::Vec<u32>; // in scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 + scope 1 { + debug _x => _1; // in scope 1 at $DIR/inline-into-box-place.rs:8:9: 8:11 + } ++ scope 2 { ++ } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/inline-into-box-place.rs:8:9: 8:11 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 + _2 = Box(std::vec::Vec<u32>); // bb0[2]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 +- (*_2) = const std::vec::Vec::<u32>::new() -> [return: bb2, unwind: bb4]; // bb0[3]: scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 ++ _4 = &mut (*_2); // bb0[3]: scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 ++ ((*_4).0: alloc::raw_vec::RawVec<u32>) = const ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }: alloc::raw_vec::RawVec::<u32>; // bb0[4]: scope 2 at $SRC_DIR/liballoc/vec.rs:LL:COL + // ty::Const +- // + ty: fn() -> std::vec::Vec<u32> {std::vec::Vec::<u32>::new} +- // + val: Value(Scalar(<ZST>)) ++ // + ty: alloc::raw_vec::RawVec<u32> ++ // + val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) + // mir::Constant +- // + span: $DIR/inline-into-box-place.rs:8:33: 8:41 +- // + user_ty: UserType(1) +- // + literal: Const { ty: fn() -> std::vec::Vec<u32> {std::vec::Vec::<u32>::new}, val: Value(Scalar(<ZST>)) } ++ // + span: $SRC_DIR/liballoc/vec.rs:LL:COL ++ // + user_ty: UserType(0) ++ // + literal: Const { ty: alloc::raw_vec::RawVec<u32>, val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) } ++ ((*_4).1: usize) = const 0usize; // bb0[5]: scope 2 at $SRC_DIR/liballoc/vec.rs:LL:COL ++ // ty::Const ++ // + ty: usize ++ // + val: Value(Scalar(0x0000000000000000)) ++ // mir::Constant ++ // + span: $SRC_DIR/liballoc/vec.rs:LL:COL ++ // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) } ++ _1 = move _2; // bb0[6]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 ++ StorageDead(_2); // bb0[7]: scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 ++ _0 = (); // bb0[8]: scope 0 at $DIR/inline-into-box-place.rs:7:11: 9:2 ++ drop(_1) -> [return: bb2, unwind: bb1]; // bb0[9]: scope 0 at $DIR/inline-into-box-place.rs:9:1: 9:2 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/inline-into-box-place.rs:7:1: 9:2 + } + + bb2: { +- _1 = move _2; // bb2[0]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 +- StorageDead(_2); // bb2[1]: scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 +- _0 = (); // bb2[2]: scope 0 at $DIR/inline-into-box-place.rs:7:11: 9:2 +- drop(_1) -> [return: bb3, unwind: bb1]; // bb2[3]: scope 0 at $DIR/inline-into-box-place.rs:9:1: 9:2 +- } +- +- bb3: { +- StorageDead(_1); // bb3[0]: scope 0 at $DIR/inline-into-box-place.rs:9:1: 9:2 +- return; // bb3[1]: scope 0 at $DIR/inline-into-box-place.rs:9:2: 9:2 +- } +- +- bb4 (cleanup): { +- _3 = const alloc::alloc::box_free::<std::vec::Vec<u32>>(move (_2.0: std::ptr::Unique<std::vec::Vec<u32>>)) -> bb1; // bb4[0]: scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 +- // ty::Const +- // + ty: unsafe fn(std::ptr::Unique<std::vec::Vec<u32>>) {alloc::alloc::box_free::<std::vec::Vec<u32>>} +- // + val: Value(Scalar(<ZST>)) +- // mir::Constant +- // + span: $DIR/inline-into-box-place.rs:8:42: 8:43 +- // + literal: Const { ty: unsafe fn(std::ptr::Unique<std::vec::Vec<u32>>) {alloc::alloc::box_free::<std::vec::Vec<u32>>}, val: Value(Scalar(<ZST>)) } ++ StorageDead(_1); // bb2[0]: scope 0 at $DIR/inline-into-box-place.rs:9:1: 9:2 ++ return; // bb2[1]: scope 0 at $DIR/inline-into-box-place.rs:9:2: 9:2 + } + } + diff --git a/src/test/mir-opt/inline/inline-retag.rs b/src/test/mir-opt/inline/inline-retag.rs index 7b78fc339f2..d7e425ec658 100644 --- a/src/test/mir-opt/inline/inline-retag.rs +++ b/src/test/mir-opt/inline/inline-retag.rs @@ -6,6 +6,7 @@ fn main() { println!("{}", bar()); } +// EMIT_MIR rustc.bar.Inline.after.mir fn bar() -> bool { let f = foo; f(&1, &-1) @@ -15,23 +16,3 @@ fn bar() -> bool { fn foo(x: &i32, y: &i32) -> bool { *x == *y } - -// END RUST SOURCE -// START rustc.bar.Inline.after.mir -// ... -// bb0: { -// ... -// Retag(_3); -// ... -// Retag(_3); -// Retag(_6); -// StorageLive(_11); -// _11 = (*_3); -// StorageLive(_12); -// _12 = (*_6); -// _0 = Eq(move _11, move _12); -// ... -// return; -// } -// ... -// END rustc.bar.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-retag/rustc.bar.Inline.after.mir b/src/test/mir-opt/inline/inline-retag/rustc.bar.Inline.after.mir new file mode 100644 index 00000000000..ae2226bd183 --- /dev/null +++ b/src/test/mir-opt/inline/inline-retag/rustc.bar.Inline.after.mir @@ -0,0 +1,81 @@ +// MIR for `bar` after Inline + +fn bar() -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/inline-retag.rs:10:13: 10:17 + let _1: for<'r, 's> fn(&'r i32, &'s i32) -> bool {foo}; // in scope 0 at $DIR/inline-retag.rs:11:9: 11:10 + let mut _2: for<'r, 's> fn(&'r i32, &'s i32) -> bool {foo}; // in scope 0 at $DIR/inline-retag.rs:12:5: 12:6 + let mut _3: &i32; // in scope 0 at $DIR/inline-retag.rs:12:7: 12:9 + let _4: &i32; // in scope 0 at $DIR/inline-retag.rs:12:7: 12:9 + let _5: i32; // in scope 0 at $DIR/inline-retag.rs:12:8: 12:9 + let mut _6: &i32; // in scope 0 at $DIR/inline-retag.rs:12:11: 12:14 + let _7: &i32; // in scope 0 at $DIR/inline-retag.rs:12:11: 12:14 + let _8: i32; // in scope 0 at $DIR/inline-retag.rs:12:12: 12:14 + scope 1 { + debug f => _1; // in scope 1 at $DIR/inline-retag.rs:11:9: 11:10 + let mut _9: &i32; // in scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + let mut _10: &i32; // in scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + scope 2 { + debug x => _3; // in scope 2 at $DIR/inline-retag.rs:16:8: 16:9 + debug y => _6; // in scope 2 at $DIR/inline-retag.rs:16:17: 16:18 + let mut _11: i32; // in scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + let mut _12: i32; // in scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/inline-retag.rs:11:9: 11:10 + _1 = const foo; // bb0[1]: scope 0 at $DIR/inline-retag.rs:11:13: 11:16 + // ty::Const + // + ty: for<'r, 's> fn(&'r i32, &'s i32) -> bool {foo} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/inline-retag.rs:11:13: 11:16 + // + literal: Const { ty: for<'r, 's> fn(&'r i32, &'s i32) -> bool {foo}, val: Value(Scalar(<ZST>)) } + StorageLive(_2); // bb0[2]: scope 1 at $DIR/inline-retag.rs:12:5: 12:6 + _2 = _1; // bb0[3]: scope 1 at $DIR/inline-retag.rs:12:5: 12:6 + StorageLive(_3); // bb0[4]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + StorageLive(_4); // bb0[5]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + _10 = const bar::promoted[1]; // bb0[6]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + // ty::Const + // + ty: &i32 + // + val: Unevaluated(DefId(0:4 ~ inline_retag[317d]::bar[0]), [], Some(promoted[1])) + // mir::Constant + // + span: $DIR/inline-retag.rs:12:7: 12:9 + // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:4 ~ inline_retag[317d]::bar[0]), [], Some(promoted[1])) } + Retag(_10); // bb0[7]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + _4 = &(*_10); // bb0[8]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + Retag(_4); // bb0[9]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + _3 = &(*_4); // bb0[10]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + Retag(_3); // bb0[11]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + StorageLive(_6); // bb0[12]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + StorageLive(_7); // bb0[13]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + _9 = const bar::promoted[0]; // bb0[14]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + // ty::Const + // + ty: &i32 + // + val: Unevaluated(DefId(0:4 ~ inline_retag[317d]::bar[0]), [], Some(promoted[0])) + // mir::Constant + // + span: $DIR/inline-retag.rs:12:11: 12:14 + // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:4 ~ inline_retag[317d]::bar[0]), [], Some(promoted[0])) } + Retag(_9); // bb0[15]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + _7 = &(*_9); // bb0[16]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + Retag(_7); // bb0[17]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + _6 = &(*_7); // bb0[18]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + Retag(_6); // bb0[19]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + Retag(_3); // bb0[20]: scope 2 at $DIR/inline-retag.rs:16:1: 18:2 + Retag(_6); // bb0[21]: scope 2 at $DIR/inline-retag.rs:16:1: 18:2 + StorageLive(_11); // bb0[22]: scope 2 at $DIR/inline-retag.rs:17:5: 17:7 + _11 = (*_3); // bb0[23]: scope 2 at $DIR/inline-retag.rs:17:5: 17:7 + StorageLive(_12); // bb0[24]: scope 2 at $DIR/inline-retag.rs:17:11: 17:13 + _12 = (*_6); // bb0[25]: scope 2 at $DIR/inline-retag.rs:17:11: 17:13 + _0 = Eq(move _11, move _12); // bb0[26]: scope 2 at $DIR/inline-retag.rs:17:5: 17:13 + StorageDead(_12); // bb0[27]: scope 2 at $DIR/inline-retag.rs:17:12: 17:13 + StorageDead(_11); // bb0[28]: scope 2 at $DIR/inline-retag.rs:17:12: 17:13 + StorageDead(_6); // bb0[29]: scope 1 at $DIR/inline-retag.rs:12:14: 12:15 + StorageDead(_3); // bb0[30]: scope 1 at $DIR/inline-retag.rs:12:14: 12:15 + StorageDead(_2); // bb0[31]: scope 1 at $DIR/inline-retag.rs:12:14: 12:15 + StorageDead(_1); // bb0[32]: scope 0 at $DIR/inline-retag.rs:13:1: 13:2 + StorageDead(_7); // bb0[33]: scope 0 at $DIR/inline-retag.rs:13:1: 13:2 + StorageDead(_4); // bb0[34]: scope 0 at $DIR/inline-retag.rs:13:1: 13:2 + return; // bb0[35]: scope 0 at $DIR/inline-retag.rs:13:2: 13:2 + } +} diff --git a/src/test/mir-opt/inline/inline-specialization.rs b/src/test/mir-opt/inline/inline-specialization.rs index 9591019bb4f..fcdaca460a9 100644 --- a/src/test/mir-opt/inline/inline-specialization.rs +++ b/src/test/mir-opt/inline/inline-specialization.rs @@ -1,5 +1,6 @@ #![feature(specialization)] +// EMIT_MIR rustc.main.Inline.diff fn main() { let x = <Vec::<()> as Foo>::bar(); } @@ -12,37 +13,3 @@ impl<T> Foo for Vec<T> { #[inline(always)] default fn bar() -> u32 { 123 } } - -// END RUST SOURCE -// START rustc.main.Inline.before.mir -// let mut _0: (); -// let _1: u32; -// scope 1 { -// debug x => _1; -// } -// bb0: { -// StorageLive(_1); -// _1 = const <std::vec::Vec<()> as Foo>::bar() -> bb1; -// } -// bb1: { -// _0 = (); -// StorageDead(_1); -// return; -// } -// END rustc.main.Inline.before.mir -// START rustc.main.Inline.after.mir -// let mut _0: (); -// let _1: u32; -// scope 1 { -// debug x => _1; -// } -// scope 2 { -// } -// bb0: { -// StorageLive(_1); -// _1 = const 123u32; -// _0 = (); -// StorageDead(_1); -// return; -// } -// END rustc.main.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-specialization/rustc.main.Inline.diff b/src/test/mir-opt/inline/inline-specialization/rustc.main.Inline.diff new file mode 100644 index 00000000000..98d03b19977 --- /dev/null +++ b/src/test/mir-opt/inline/inline-specialization/rustc.main.Inline.diff @@ -0,0 +1,38 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/inline-specialization.rs:4:11: 4:11 + let _1: u32; // in scope 0 at $DIR/inline-specialization.rs:5:9: 5:10 + scope 1 { + debug x => _1; // in scope 1 at $DIR/inline-specialization.rs:5:9: 5:10 + } ++ scope 2 { ++ } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/inline-specialization.rs:5:9: 5:10 +- _1 = const <std::vec::Vec<()> as Foo>::bar() -> bb1; // bb0[1]: scope 0 at $DIR/inline-specialization.rs:5:13: 5:38 ++ _1 = const 123u32; // bb0[1]: scope 2 at $DIR/inline-specialization.rs:14:31: 14:34 + // ty::Const +- // + ty: fn() -> u32 {<std::vec::Vec<()> as Foo>::bar} +- // + val: Value(Scalar(<ZST>)) ++ // + ty: u32 ++ // + val: Value(Scalar(0x0000007b)) + // mir::Constant +- // + span: $DIR/inline-specialization.rs:5:13: 5:36 +- // + literal: Const { ty: fn() -> u32 {<std::vec::Vec<()> as Foo>::bar}, val: Value(Scalar(<ZST>)) } +- } +- +- bb1: { +- _0 = (); // bb1[0]: scope 0 at $DIR/inline-specialization.rs:4:11: 6:2 +- StorageDead(_1); // bb1[1]: scope 0 at $DIR/inline-specialization.rs:6:1: 6:2 +- return; // bb1[2]: scope 0 at $DIR/inline-specialization.rs:6:2: 6:2 ++ // + span: $DIR/inline-specialization.rs:14:31: 14:34 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x0000007b)) } ++ _0 = (); // bb0[2]: scope 0 at $DIR/inline-specialization.rs:4:11: 6:2 ++ StorageDead(_1); // bb0[3]: scope 0 at $DIR/inline-specialization.rs:6:1: 6:2 ++ return; // bb0[4]: scope 0 at $DIR/inline-specialization.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/inline/inline-trait-method.rs b/src/test/mir-opt/inline/inline-trait-method.rs index a2c5fb920cd..cb3db9b5592 100644 --- a/src/test/mir-opt/inline/inline-trait-method.rs +++ b/src/test/mir-opt/inline/inline-trait-method.rs @@ -4,6 +4,7 @@ fn main() { println!("{}", test(&())); } +// EMIT_MIR rustc.test.Inline.after.mir fn test(x: &dyn X) -> u32 { x.y() } @@ -19,13 +20,3 @@ impl X for () { 2 } } - -// END RUST SOURCE -// START rustc.test.Inline.after.mir -// ... -// bb0: { -// ... -// _0 = const <dyn X as X>::y(move _2) -> bb1; -// } -// ... -// END rustc.test.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-trait-method/rustc.test.Inline.after.mir b/src/test/mir-opt/inline/inline-trait-method/rustc.test.Inline.after.mir new file mode 100644 index 00000000000..488303e09ef --- /dev/null +++ b/src/test/mir-opt/inline/inline-trait-method/rustc.test.Inline.after.mir @@ -0,0 +1,24 @@ +// MIR for `test` after Inline + +fn test(_1: &dyn X) -> u32 { + debug x => _1; // in scope 0 at $DIR/inline-trait-method.rs:8:9: 8:10 + let mut _0: u32; // return place in scope 0 at $DIR/inline-trait-method.rs:8:23: 8:26 + let mut _2: &dyn X; // in scope 0 at $DIR/inline-trait-method.rs:9:5: 9:6 + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/inline-trait-method.rs:9:5: 9:6 + _2 = &(*_1); // bb0[1]: scope 0 at $DIR/inline-trait-method.rs:9:5: 9:6 + _0 = const <dyn X as X>::y(move _2) -> bb1; // bb0[2]: scope 0 at $DIR/inline-trait-method.rs:9:5: 9:10 + // ty::Const + // + ty: for<'r> fn(&'r dyn X) -> u32 {<dyn X as X>::y} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/inline-trait-method.rs:9:7: 9:8 + // + literal: Const { ty: for<'r> fn(&'r dyn X) -> u32 {<dyn X as X>::y}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageDead(_2); // bb1[0]: scope 0 at $DIR/inline-trait-method.rs:9:9: 9:10 + return; // bb1[1]: scope 0 at $DIR/inline-trait-method.rs:10:2: 10:2 + } +} diff --git a/src/test/mir-opt/inline/inline-trait-method_2.rs b/src/test/mir-opt/inline/inline-trait-method_2.rs index 4ad4311113a..e37f091c5cd 100644 --- a/src/test/mir-opt/inline/inline-trait-method_2.rs +++ b/src/test/mir-opt/inline/inline-trait-method_2.rs @@ -1,5 +1,6 @@ // compile-flags: -Z span_free_formats -Z mir-opt-level=3 +// EMIT_MIR rustc.test2.Inline.after.mir fn test2(x: &dyn X) -> bool { test(x) } @@ -24,13 +25,3 @@ impl X for () { fn main() { println!("Should be true: {}", test2(&())); } - -// END RUST SOURCE -// START rustc.test2.Inline.after.mir -// ... -// bb0: { -// ... -// _0 = const <dyn X as X>::y(move _2) -> bb1; -// } -// ... -// END rustc.test2.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-trait-method_2/rustc.test2.Inline.after.mir b/src/test/mir-opt/inline/inline-trait-method_2/rustc.test2.Inline.after.mir new file mode 100644 index 00000000000..aca47198aa9 --- /dev/null +++ b/src/test/mir-opt/inline/inline-trait-method_2/rustc.test2.Inline.after.mir @@ -0,0 +1,31 @@ +// MIR for `test2` after Inline + +fn test2(_1: &dyn X) -> bool { + debug x => _1; // in scope 0 at $DIR/inline-trait-method_2.rs:4:10: 4:11 + let mut _0: bool; // return place in scope 0 at $DIR/inline-trait-method_2.rs:4:24: 4:28 + let mut _2: &dyn X; // in scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + let mut _3: &dyn X; // in scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + scope 1 { + debug x => _2; // in scope 1 at $DIR/inline-trait-method_2.rs:9:9: 9:10 + } + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + StorageLive(_3); // bb0[1]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + _3 = &(*_1); // bb0[2]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + _2 = move _3 as &dyn X (Pointer(Unsize)); // bb0[3]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + StorageDead(_3); // bb0[4]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + _0 = const <dyn X as X>::y(move _2) -> bb1; // bb0[5]: scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:10 + // ty::Const + // + ty: for<'r> fn(&'r dyn X) -> bool {<dyn X as X>::y} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/inline-trait-method_2.rs:10:7: 10:8 + // + literal: Const { ty: for<'r> fn(&'r dyn X) -> bool {<dyn X as X>::y}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageDead(_2); // bb1[0]: scope 0 at $DIR/inline-trait-method_2.rs:5:11: 5:12 + return; // bb1[1]: scope 0 at $DIR/inline-trait-method_2.rs:6:2: 6:2 + } +} diff --git a/src/test/mir-opt/nll/named-lifetimes-basic.rs b/src/test/mir-opt/nll/named-lifetimes-basic.rs index 2a6c2db03be..073ccf7e6c6 100644 --- a/src/test/mir-opt/nll/named-lifetimes-basic.rs +++ b/src/test/mir-opt/nll/named-lifetimes-basic.rs @@ -8,31 +8,8 @@ #![allow(warnings)] +// EMIT_MIR rustc.use_x.nll.0.mir fn use_x<'a, 'b: 'a, 'c>(w: &'a mut i32, x: &'b u32, y: &'a u32, z: &'c u32) -> bool { true } fn main() { } - -// END RUST SOURCE -// START rustc.use_x.nll.0.mir -// | Free Region Mapping -// | '_#0r | Global | ['_#2r, '_#1r, '_#0r, '_#4r, '_#3r] -// | '_#1r | External | ['_#1r, '_#4r] -// | '_#2r | External | ['_#2r, '_#1r, '_#4r] -// | '_#3r | Local | ['_#4r, '_#3r] -// | '_#4r | Local | ['_#4r] -// | -// | Inferred Region Values -// | '_#0r | U0 | {bb0[0..=1], '_#0r, '_#1r, '_#2r, '_#3r, '_#4r} -// | '_#1r | U0 | {bb0[0..=1], '_#1r} -// | '_#2r | U0 | {bb0[0..=1], '_#2r} -// | '_#3r | U0 | {bb0[0..=1], '_#3r} -// | '_#4r | U0 | {bb0[0..=1], '_#4r} -// | '_#5r | U0 | {bb0[0..=1], '_#1r} -// | '_#6r | U0 | {bb0[0..=1], '_#2r} -// | '_#7r | U0 | {bb0[0..=1], '_#1r} -// | '_#8r | U0 | {bb0[0..=1], '_#3r} -// | -// ... -// fn use_x(_1: &'_#5r mut i32, _2: &'_#6r u32, _3: &'_#7r u32, _4: &'_#8r u32) -> bool { -// END rustc.use_x.nll.0.mir diff --git a/src/test/mir-opt/nll/named-lifetimes-basic/rustc.use_x.nll.0.mir b/src/test/mir-opt/nll/named-lifetimes-basic/rustc.use_x.nll.0.mir new file mode 100644 index 00000000000..a486af608ef --- /dev/null +++ b/src/test/mir-opt/nll/named-lifetimes-basic/rustc.use_x.nll.0.mir @@ -0,0 +1,53 @@ +// MIR for `use_x` 0 nll + +| Free Region Mapping +| '_#0r | Global | ['_#2r, '_#1r, '_#0r, '_#4r, '_#3r] +| '_#1r | External | ['_#1r, '_#4r] +| '_#2r | External | ['_#2r, '_#1r, '_#4r] +| '_#3r | Local | ['_#4r, '_#3r] +| '_#4r | Local | ['_#4r] +| +| Inferred Region Values +| '_#0r | U0 | {bb0[0..=1], '_#0r, '_#1r, '_#2r, '_#3r, '_#4r} +| '_#1r | U0 | {bb0[0..=1], '_#1r} +| '_#2r | U0 | {bb0[0..=1], '_#2r} +| '_#3r | U0 | {bb0[0..=1], '_#3r} +| '_#4r | U0 | {bb0[0..=1], '_#4r} +| '_#5r | U0 | {bb0[0..=1], '_#1r} +| '_#6r | U0 | {bb0[0..=1], '_#2r} +| '_#7r | U0 | {bb0[0..=1], '_#1r} +| '_#8r | U0 | {bb0[0..=1], '_#3r} +| +| Inference Constraints +| '_#0r live at {bb0[0..=1]} +| '_#1r live at {bb0[0..=1]} +| '_#2r live at {bb0[0..=1]} +| '_#3r live at {bb0[0..=1]} +| '_#4r live at {bb0[0..=1]} +| '_#1r: '_#5r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:26: 12:27) +| '_#1r: '_#7r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:54: 12:55) +| '_#2r: '_#6r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:42: 12:43) +| '_#3r: '_#8r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:66: 12:67) +| '_#5r: '_#1r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:26: 12:27) +| '_#6r: '_#2r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:42: 12:43) +| '_#7r: '_#1r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:54: 12:55) +| '_#8r: '_#3r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:66: 12:67) +| +fn use_x(_1: &'_#5r mut i32, _2: &'_#6r u32, _3: &'_#7r u32, _4: &'_#8r u32) -> bool { + debug w => _1; // in scope 0 at $DIR/named-lifetimes-basic.rs:12:26: 12:27 + debug x => _2; // in scope 0 at $DIR/named-lifetimes-basic.rs:12:42: 12:43 + debug y => _3; // in scope 0 at $DIR/named-lifetimes-basic.rs:12:54: 12:55 + debug z => _4; // in scope 0 at $DIR/named-lifetimes-basic.rs:12:66: 12:67 + let mut _0: bool; // return place in scope 0 at $DIR/named-lifetimes-basic.rs:12:81: 12:85 + + bb0: { + _0 = const Const(Value(Scalar(0x01)): bool); // bb0[0]: scope 0 at $DIR/named-lifetimes-basic.rs:12:88: 12:92 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/named-lifetimes-basic.rs:12:88: 12:92 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + return; // bb0[1]: scope 0 at $DIR/named-lifetimes-basic.rs:12:94: 12:94 + } +} diff --git a/src/test/mir-opt/nll/region-subtyping-basic.rs b/src/test/mir-opt/nll/region-subtyping-basic.rs index 16e357fc162..4d8fbbfeec2 100644 --- a/src/test/mir-opt/nll/region-subtyping-basic.rs +++ b/src/test/mir-opt/nll/region-subtyping-basic.rs @@ -9,6 +9,7 @@ fn use_x(_: usize) -> bool { true } +// EMIT_MIR rustc.main.nll.0.mir fn main() { let mut v = [1, 2, 3]; let p = &v[0]; @@ -19,23 +20,3 @@ fn main() { use_x(22); } } - -// END RUST SOURCE -// START rustc.main.nll.0.mir -// | '_#2r | U0 | {bb2[0..=8], bb3[0], bb5[0..=2]} -// | '_#3r | U0 | {bb2[1..=8], bb3[0], bb5[0..=2]} -// | '_#4r | U0 | {bb2[4..=8], bb3[0], bb5[0..=2]} -// END rustc.main.nll.0.mir -// START rustc.main.nll.0.mir -// let _2: &'_#3r usize; -// ... -// debug p => _2; -// ... -// let _6: &'_#4r usize; -// ... -// debug q => _6; -// ... -// _2 = &'_#2r _1[_3]; -// ... -// _6 = _2; -// END rustc.main.nll.0.mir diff --git a/src/test/mir-opt/nll/region-subtyping-basic/rustc.main.nll.0.mir b/src/test/mir-opt/nll/region-subtyping-basic/rustc.main.nll.0.mir new file mode 100644 index 00000000000..b97cbd8ef5c --- /dev/null +++ b/src/test/mir-opt/nll/region-subtyping-basic/rustc.main.nll.0.mir @@ -0,0 +1,158 @@ +// MIR for `main` 0 nll + +| Free Region Mapping +| '_#0r | Global | ['_#0r, '_#1r] +| '_#1r | Local | ['_#1r] +| +| Inferred Region Values +| '_#0r | U0 | {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5], '_#0r, '_#1r} +| '_#1r | U0 | {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5], '_#1r} +| '_#2r | U0 | {bb2[0..=8], bb3[0], bb5[0..=2]} +| '_#3r | U0 | {bb2[1..=8], bb3[0], bb5[0..=2]} +| '_#4r | U0 | {bb2[4..=8], bb3[0], bb5[0..=2]} +| +| Inference Constraints +| '_#0r live at {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5]} +| '_#1r live at {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5]} +| '_#2r live at {bb2[0]} +| '_#3r live at {bb2[1..=3]} +| '_#4r live at {bb2[4..=8], bb3[0], bb5[0..=2]} +| '_#2r: '_#3r due to Assignment at Single(bb2[0]) +| '_#3r: '_#4r due to Assignment at Single(bb2[3]) +| +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/region-subtyping-basic.rs:13:11: 13:11 + let mut _1: [usize; Const { ty: usize, val: Value(Scalar(0x0000000000000003)) }]; // in scope 0 at $DIR/region-subtyping-basic.rs:14:9: 14:14 + let _3: usize; // in scope 0 at $DIR/region-subtyping-basic.rs:15:16: 15:17 + let mut _4: usize; // in scope 0 at $DIR/region-subtyping-basic.rs:15:14: 15:18 + let mut _5: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:15:14: 15:18 + let mut _7: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:17:8: 17:12 + let _8: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:18:9: 18:18 + let mut _9: usize; // in scope 0 at $DIR/region-subtyping-basic.rs:18:15: 18:17 + let _10: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:20:9: 20:18 + scope 1 { + debug v => _1; // in scope 1 at $DIR/region-subtyping-basic.rs:14:9: 14:14 + let _2: &'_#3r usize; // in scope 1 at $DIR/region-subtyping-basic.rs:15:9: 15:10 + scope 2 { + debug p => _2; // in scope 2 at $DIR/region-subtyping-basic.rs:15:9: 15:10 + let _6: &'_#4r usize; // in scope 2 at $DIR/region-subtyping-basic.rs:16:9: 16:10 + scope 3 { + debug q => _6; // in scope 3 at $DIR/region-subtyping-basic.rs:16:9: 16:10 + } + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/region-subtyping-basic.rs:14:9: 14:14 + _1 = [const Const(Value(Scalar(0x0000000000000001)): usize), const Const(Value(Scalar(0x0000000000000002)): usize), const Const(Value(Scalar(0x0000000000000003)): usize)]; // bb0[1]: scope 0 at $DIR/region-subtyping-basic.rs:14:17: 14:26 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000001)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:14:18: 14:19 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) } + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000002)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:14:21: 14:22 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000002)) } + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000003)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:14:24: 14:25 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000003)) } + FakeRead(ForLet, _1); // bb0[2]: scope 0 at $DIR/region-subtyping-basic.rs:14:9: 14:14 + StorageLive(_2); // bb0[3]: scope 1 at $DIR/region-subtyping-basic.rs:15:9: 15:10 + StorageLive(_3); // bb0[4]: scope 1 at $DIR/region-subtyping-basic.rs:15:16: 15:17 + _3 = const Const(Value(Scalar(0x0000000000000000)): usize); // bb0[5]: scope 1 at $DIR/region-subtyping-basic.rs:15:16: 15:17 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000000)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:15:16: 15:17 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) } + _4 = Len(_1); // bb0[6]: scope 1 at $DIR/region-subtyping-basic.rs:15:14: 15:18 + _5 = Lt(_3, _4); // bb0[7]: scope 1 at $DIR/region-subtyping-basic.rs:15:14: 15:18 + assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> [success: bb2, unwind: bb1]; // bb0[8]: scope 1 at $DIR/region-subtyping-basic.rs:15:14: 15:18 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/region-subtyping-basic.rs:13:1: 22:2 + } + + bb2: { + _2 = &'_#2r _1[_3]; // bb2[0]: scope 1 at $DIR/region-subtyping-basic.rs:15:13: 15:18 + FakeRead(ForLet, _2); // bb2[1]: scope 1 at $DIR/region-subtyping-basic.rs:15:9: 15:10 + StorageLive(_6); // bb2[2]: scope 2 at $DIR/region-subtyping-basic.rs:16:9: 16:10 + _6 = _2; // bb2[3]: scope 2 at $DIR/region-subtyping-basic.rs:16:13: 16:14 + FakeRead(ForLet, _6); // bb2[4]: scope 2 at $DIR/region-subtyping-basic.rs:16:9: 16:10 + StorageLive(_7); // bb2[5]: scope 3 at $DIR/region-subtyping-basic.rs:17:8: 17:12 + _7 = const Const(Value(Scalar(0x01)): bool); // bb2[6]: scope 3 at $DIR/region-subtyping-basic.rs:17:8: 17:12 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:17:8: 17:12 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + FakeRead(ForMatchedPlace, _7); // bb2[7]: scope 3 at $DIR/region-subtyping-basic.rs:17:8: 17:12 + switchInt(_7) -> [Const(Value(Scalar(0x00)): bool): bb4, otherwise: bb3]; // bb2[8]: scope 3 at $DIR/region-subtyping-basic.rs:17:5: 21:6 + } + + bb3: { + falseEdges -> [real: bb5, imaginary: bb4]; // bb3[0]: scope 3 at $DIR/region-subtyping-basic.rs:17:5: 21:6 + } + + bb4: { + StorageLive(_10); // bb4[0]: scope 3 at $DIR/region-subtyping-basic.rs:20:9: 20:18 + _10 = const Const(Value(Scalar(<ZST>)): fn(usize) -> bool {use_x})(const Const(Value(Scalar(0x0000000000000016)): usize)) -> [return: bb7, unwind: bb1]; // bb4[1]: scope 3 at $DIR/region-subtyping-basic.rs:20:9: 20:18 + // ty::Const + // + ty: fn(usize) -> bool {use_x} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:20:9: 20:14 + // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000016)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:20:15: 20:17 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000016)) } + } + + bb5: { + StorageLive(_8); // bb5[0]: scope 3 at $DIR/region-subtyping-basic.rs:18:9: 18:18 + StorageLive(_9); // bb5[1]: scope 3 at $DIR/region-subtyping-basic.rs:18:15: 18:17 + _9 = (*_6); // bb5[2]: scope 3 at $DIR/region-subtyping-basic.rs:18:15: 18:17 + _8 = const Const(Value(Scalar(<ZST>)): fn(usize) -> bool {use_x})(move _9) -> [return: bb6, unwind: bb1]; // bb5[3]: scope 3 at $DIR/region-subtyping-basic.rs:18:9: 18:18 + // ty::Const + // + ty: fn(usize) -> bool {use_x} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:18:9: 18:14 + // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value(Scalar(<ZST>)) } + } + + bb6: { + StorageDead(_9); // bb6[0]: scope 3 at $DIR/region-subtyping-basic.rs:18:17: 18:18 + StorageDead(_8); // bb6[1]: scope 3 at $DIR/region-subtyping-basic.rs:18:18: 18:19 + _0 = (); // bb6[2]: scope 3 at $DIR/region-subtyping-basic.rs:17:13: 19:6 + goto -> bb8; // bb6[3]: scope 3 at $DIR/region-subtyping-basic.rs:17:5: 21:6 + } + + bb7: { + StorageDead(_10); // bb7[0]: scope 3 at $DIR/region-subtyping-basic.rs:20:18: 20:19 + _0 = (); // bb7[1]: scope 3 at $DIR/region-subtyping-basic.rs:19:12: 21:6 + goto -> bb8; // bb7[2]: scope 3 at $DIR/region-subtyping-basic.rs:17:5: 21:6 + } + + bb8: { + StorageDead(_6); // bb8[0]: scope 2 at $DIR/region-subtyping-basic.rs:22:1: 22:2 + StorageDead(_3); // bb8[1]: scope 1 at $DIR/region-subtyping-basic.rs:22:1: 22:2 + StorageDead(_2); // bb8[2]: scope 1 at $DIR/region-subtyping-basic.rs:22:1: 22:2 + StorageDead(_1); // bb8[3]: scope 0 at $DIR/region-subtyping-basic.rs:22:1: 22:2 + StorageDead(_7); // bb8[4]: scope 0 at $DIR/region-subtyping-basic.rs:22:1: 22:2 + return; // bb8[5]: scope 0 at $DIR/region-subtyping-basic.rs:22:2: 22:2 + } +} |
