summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/dataflow-const-prop
diff options
context:
space:
mode:
Diffstat (limited to 'tests/mir-opt/dataflow-const-prop')
-rw-r--r--tests/mir-opt/dataflow-const-prop/array_index.main.DataflowConstProp.32bit.panic-abort.diff39
-rw-r--r--tests/mir-opt/dataflow-const-prop/array_index.main.DataflowConstProp.32bit.panic-unwind.diff39
-rw-r--r--tests/mir-opt/dataflow-const-prop/array_index.main.DataflowConstProp.64bit.panic-abort.diff39
-rw-r--r--tests/mir-opt/dataflow-const-prop/array_index.main.DataflowConstProp.64bit.panic-unwind.diff39
-rw-r--r--tests/mir-opt/dataflow-const-prop/array_index.rs9
-rw-r--r--tests/mir-opt/dataflow-const-prop/boolean_identities.rs11
-rw-r--r--tests/mir-opt/dataflow-const-prop/boolean_identities.test.DataflowConstProp.diff33
-rw-r--r--tests/mir-opt/dataflow-const-prop/cast.main.DataflowConstProp.diff48
-rw-r--r--tests/mir-opt/dataflow-const-prop/cast.rs1
-rw-r--r--tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.diff80
-rw-r--r--tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-abort.diff88
-rw-r--r--tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-unwind.diff88
-rw-r--r--tests/mir-opt/dataflow-const-prop/checked.rs3
-rw-r--r--tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-abort.diff119
-rw-r--r--tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff123
-rw-r--r--tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-abort.diff119
-rw-r--r--tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff123
-rw-r--r--tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff111
-rw-r--r--tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff115
-rw-r--r--tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff111
-rw-r--r--tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff115
-rw-r--r--tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs18
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.32bit.diff63
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.64bit.diff63
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.32bit.diff82
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.64bit.diff82
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.diff82
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.32bit.diff26
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.64bit.diff26
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.diff26
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.rs23
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.32bit.diff68
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.64bit.diff68
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.diff63
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff131
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff131
-rw-r--r--tests/mir-opt/dataflow-const-prop/if.main.DataflowConstProp.diff152
-rw-r--r--tests/mir-opt/dataflow-const-prop/if.rs1
-rw-r--r--tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff39
-rw-r--r--tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff45
-rw-r--r--tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff45
-rw-r--r--tests/mir-opt/dataflow-const-prop/inherit_overflow.rs3
-rw-r--r--tests/mir-opt/dataflow-const-prop/issue_81605.f.DataflowConstProp.diff34
-rw-r--r--tests/mir-opt/dataflow-const-prop/issue_81605.rs1
-rw-r--r--tests/mir-opt/dataflow-const-prop/large_array_index.main.DataflowConstProp.32bit.panic-abort.diff39
-rw-r--r--tests/mir-opt/dataflow-const-prop/large_array_index.main.DataflowConstProp.32bit.panic-unwind.diff39
-rw-r--r--tests/mir-opt/dataflow-const-prop/large_array_index.main.DataflowConstProp.64bit.panic-abort.diff39
-rw-r--r--tests/mir-opt/dataflow-const-prop/large_array_index.main.DataflowConstProp.64bit.panic-unwind.diff39
-rw-r--r--tests/mir-opt/dataflow-const-prop/large_array_index.rs10
-rw-r--r--tests/mir-opt/dataflow-const-prop/mult_by_zero.rs11
-rw-r--r--tests/mir-opt/dataflow-const-prop/mult_by_zero.test.DataflowConstProp.diff18
-rw-r--r--tests/mir-opt/dataflow-const-prop/offset_of.concrete.DataflowConstProp.panic-abort.diff76
-rw-r--r--tests/mir-opt/dataflow-const-prop/offset_of.concrete.DataflowConstProp.panic-unwind.diff76
-rw-r--r--tests/mir-opt/dataflow-const-prop/offset_of.generic.DataflowConstProp.panic-abort.diff72
-rw-r--r--tests/mir-opt/dataflow-const-prop/offset_of.generic.DataflowConstProp.panic-unwind.diff72
-rw-r--r--tests/mir-opt/dataflow-const-prop/offset_of.rs50
-rw-r--r--tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff55
-rw-r--r--tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.panic-abort.diff49
-rw-r--r--tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.panic-unwind.diff49
-rw-r--r--tests/mir-opt/dataflow-const-prop/ref_without_sb.rs3
-rw-r--r--tests/mir-opt/dataflow-const-prop/repeat.main.DataflowConstProp.32bit.panic-abort.diff43
-rw-r--r--tests/mir-opt/dataflow-const-prop/repeat.main.DataflowConstProp.32bit.panic-unwind.diff43
-rw-r--r--tests/mir-opt/dataflow-const-prop/repeat.main.DataflowConstProp.64bit.panic-abort.diff43
-rw-r--r--tests/mir-opt/dataflow-const-prop/repeat.main.DataflowConstProp.64bit.panic-unwind.diff43
-rw-r--r--tests/mir-opt/dataflow-const-prop/repeat.rs9
-rw-r--r--tests/mir-opt/dataflow-const-prop/repr_transparent.main.DataflowConstProp.diff67
-rw-r--r--tests/mir-opt/dataflow-const-prop/repr_transparent.rs1
-rw-r--r--tests/mir-opt/dataflow-const-prop/self_assign.main.DataflowConstProp.diff66
-rw-r--r--tests/mir-opt/dataflow-const-prop/self_assign.rs1
-rw-r--r--tests/mir-opt/dataflow-const-prop/self_assign_add.main.DataflowConstProp.diff24
-rw-r--r--tests/mir-opt/dataflow-const-prop/self_assign_add.rs1
-rw-r--r--tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.diff54
-rw-r--r--tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-abort.diff51
-rw-r--r--tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-unwind.diff51
-rw-r--r--tests/mir-opt/dataflow-const-prop/sibling_ptr.rs3
-rw-r--r--tests/mir-opt/dataflow-const-prop/slice_len.main.DataflowConstProp.32bit.panic-abort.diff77
-rw-r--r--tests/mir-opt/dataflow-const-prop/slice_len.main.DataflowConstProp.32bit.panic-unwind.diff77
-rw-r--r--tests/mir-opt/dataflow-const-prop/slice_len.main.DataflowConstProp.64bit.panic-abort.diff77
-rw-r--r--tests/mir-opt/dataflow-const-prop/slice_len.main.DataflowConstProp.64bit.panic-unwind.diff77
-rw-r--r--tests/mir-opt/dataflow-const-prop/slice_len.rs13
-rw-r--r--tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.32bit.diff247
-rw-r--r--tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.64bit.diff247
-rw-r--r--tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.diff51
-rw-r--r--tests/mir-opt/dataflow-const-prop/struct.rs27
-rw-r--r--tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.diff40
-rw-r--r--tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.panic-abort.diff37
-rw-r--r--tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.panic-unwind.diff37
-rw-r--r--tests/mir-opt/dataflow-const-prop/terminator.rs3
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.from_char.DataflowConstProp.32bit.diff15
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.from_char.DataflowConstProp.64bit.diff15
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.invalid_bool.DataflowConstProp.32bit.diff15
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.invalid_bool.DataflowConstProp.64bit.diff15
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.invalid_char.DataflowConstProp.32bit.diff15
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.invalid_char.DataflowConstProp.64bit.diff15
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.less_as_i8.DataflowConstProp.32bit.diff18
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.less_as_i8.DataflowConstProp.64bit.diff18
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.rs85
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.undef_union_as_integer.DataflowConstProp.32bit.diff24
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.undef_union_as_integer.DataflowConstProp.64bit.diff24
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.32bit.diff22
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.64bit.diff22
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.unreachable_direct.DataflowConstProp.32bit.diff24
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.unreachable_direct.DataflowConstProp.64bit.diff24
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.unreachable_mut.DataflowConstProp.32bit.diff24
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.unreachable_mut.DataflowConstProp.64bit.diff24
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.unreachable_ref.DataflowConstProp.32bit.diff20
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.unreachable_ref.DataflowConstProp.64bit.diff20
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.valid_char.DataflowConstProp.32bit.diff15
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.valid_char.DataflowConstProp.64bit.diff15
-rw-r--r--tests/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.32bit.diff112
-rw-r--r--tests/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.64bit.diff112
-rw-r--r--tests/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.diff71
-rw-r--r--tests/mir-opt/dataflow-const-prop/tuple.rs4
113 files changed, 4944 insertions, 756 deletions
diff --git a/tests/mir-opt/dataflow-const-prop/array_index.main.DataflowConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/array_index.main.DataflowConstProp.32bit.panic-abort.diff
new file mode 100644
index 000000000..212ddc5b1
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/array_index.main.DataflowConstProp.32bit.panic-abort.diff
@@ -0,0 +1,39 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: u32;
+ let mut _2: [u32; 4];
+ let _3: usize;
+ let mut _4: usize;
+ let mut _5: bool;
+ scope 1 {
+ debug x => _1;
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32];
+ StorageLive(_3);
+ _3 = const 2_usize;
+- _4 = Len(_2);
+- _5 = Lt(_3, _4);
+- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable];
++ _4 = const 4_usize;
++ _5 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+- _1 = _2[_3];
++ _1 = _2[2 of 3];
+ StorageDead(_3);
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/array_index.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/array_index.main.DataflowConstProp.32bit.panic-unwind.diff
new file mode 100644
index 000000000..5c53d4f44
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/array_index.main.DataflowConstProp.32bit.panic-unwind.diff
@@ -0,0 +1,39 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: u32;
+ let mut _2: [u32; 4];
+ let _3: usize;
+ let mut _4: usize;
+ let mut _5: bool;
+ scope 1 {
+ debug x => _1;
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32];
+ StorageLive(_3);
+ _3 = const 2_usize;
+- _4 = Len(_2);
+- _5 = Lt(_3, _4);
+- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue];
++ _4 = const 4_usize;
++ _5 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+- _1 = _2[_3];
++ _1 = _2[2 of 3];
+ StorageDead(_3);
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/array_index.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/array_index.main.DataflowConstProp.64bit.panic-abort.diff
new file mode 100644
index 000000000..212ddc5b1
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/array_index.main.DataflowConstProp.64bit.panic-abort.diff
@@ -0,0 +1,39 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: u32;
+ let mut _2: [u32; 4];
+ let _3: usize;
+ let mut _4: usize;
+ let mut _5: bool;
+ scope 1 {
+ debug x => _1;
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32];
+ StorageLive(_3);
+ _3 = const 2_usize;
+- _4 = Len(_2);
+- _5 = Lt(_3, _4);
+- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable];
++ _4 = const 4_usize;
++ _5 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+- _1 = _2[_3];
++ _1 = _2[2 of 3];
+ StorageDead(_3);
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/array_index.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/array_index.main.DataflowConstProp.64bit.panic-unwind.diff
new file mode 100644
index 000000000..5c53d4f44
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/array_index.main.DataflowConstProp.64bit.panic-unwind.diff
@@ -0,0 +1,39 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: u32;
+ let mut _2: [u32; 4];
+ let _3: usize;
+ let mut _4: usize;
+ let mut _5: bool;
+ scope 1 {
+ debug x => _1;
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32];
+ StorageLive(_3);
+ _3 = const 2_usize;
+- _4 = Len(_2);
+- _5 = Lt(_3, _4);
+- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue];
++ _4 = const 4_usize;
++ _5 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+- _1 = _2[_3];
++ _1 = _2[2 of 3];
+ StorageDead(_3);
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/array_index.rs b/tests/mir-opt/dataflow-const-prop/array_index.rs
new file mode 100644
index 000000000..3d420f930
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/array_index.rs
@@ -0,0 +1,9 @@
+// skip-filecheck
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+// unit-test: DataflowConstProp
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+
+// EMIT_MIR array_index.main.DataflowConstProp.diff
+fn main() {
+ let x: u32 = [0, 1, 2, 3][2];
+}
diff --git a/tests/mir-opt/dataflow-const-prop/boolean_identities.rs b/tests/mir-opt/dataflow-const-prop/boolean_identities.rs
new file mode 100644
index 000000000..2605c7019
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/boolean_identities.rs
@@ -0,0 +1,11 @@
+// skip-filecheck
+// unit-test: DataflowConstProp
+
+// EMIT_MIR boolean_identities.test.DataflowConstProp.diff
+pub fn test(x: bool, y: bool) -> bool {
+ (y | true) & (x & false)
+}
+
+fn main() {
+ test(true, false);
+}
diff --git a/tests/mir-opt/dataflow-const-prop/boolean_identities.test.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/boolean_identities.test.DataflowConstProp.diff
new file mode 100644
index 000000000..5440c38ce
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/boolean_identities.test.DataflowConstProp.diff
@@ -0,0 +1,33 @@
+- // MIR for `test` before DataflowConstProp
++ // MIR for `test` after DataflowConstProp
+
+ fn test(_1: bool, _2: bool) -> bool {
+ debug x => _1;
+ debug y => _2;
+ let mut _0: bool;
+ let mut _3: bool;
+ let mut _4: bool;
+ let mut _5: bool;
+ let mut _6: bool;
+
+ bb0: {
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = _2;
+- _3 = BitOr(move _4, const true);
++ _3 = const true;
+ StorageDead(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+ _6 = _1;
+- _5 = BitAnd(move _6, const false);
++ _5 = const false;
+ StorageDead(_6);
+- _0 = BitAnd(move _3, move _5);
++ _0 = const false;
+ StorageDead(_5);
+ StorageDead(_3);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/cast.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/cast.main.DataflowConstProp.diff
index bf9ab8669..0ca446c89 100644
--- a/tests/mir-opt/dataflow-const-prop/cast.main.DataflowConstProp.diff
+++ b/tests/mir-opt/dataflow-const-prop/cast.main.DataflowConstProp.diff
@@ -2,36 +2,36 @@
+ // MIR for `main` after DataflowConstProp
fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/cast.rs:+0:11: +0:11
- let _1: i32; // in scope 0 at $DIR/cast.rs:+1:9: +1:10
- let mut _3: u8; // in scope 0 at $DIR/cast.rs:+2:13: +2:20
- let mut _4: i32; // in scope 0 at $DIR/cast.rs:+2:13: +2:14
+ let mut _0: ();
+ let _1: i32;
+ let mut _3: u8;
+ let mut _4: i32;
scope 1 {
- debug a => _1; // in scope 1 at $DIR/cast.rs:+1:9: +1:10
- let _2: u8; // in scope 1 at $DIR/cast.rs:+2:9: +2:10
+ debug a => _1;
+ let _2: u8;
scope 2 {
- debug b => _2; // in scope 2 at $DIR/cast.rs:+2:9: +2:10
+ debug b => _2;
}
}
bb0: {
- StorageLive(_1); // scope 0 at $DIR/cast.rs:+1:9: +1:10
- _1 = const 257_i32; // scope 0 at $DIR/cast.rs:+1:13: +1:16
- StorageLive(_2); // scope 1 at $DIR/cast.rs:+2:9: +2:10
- StorageLive(_3); // scope 1 at $DIR/cast.rs:+2:13: +2:20
- StorageLive(_4); // scope 1 at $DIR/cast.rs:+2:13: +2:14
-- _4 = _1; // scope 1 at $DIR/cast.rs:+2:13: +2:14
-- _3 = move _4 as u8 (IntToInt); // scope 1 at $DIR/cast.rs:+2:13: +2:20
-+ _4 = const 257_i32; // scope 1 at $DIR/cast.rs:+2:13: +2:14
-+ _3 = const 1_u8; // scope 1 at $DIR/cast.rs:+2:13: +2:20
- StorageDead(_4); // scope 1 at $DIR/cast.rs:+2:19: +2:20
-- _2 = Add(move _3, const 1_u8); // scope 1 at $DIR/cast.rs:+2:13: +2:24
-+ _2 = const 2_u8; // scope 1 at $DIR/cast.rs:+2:13: +2:24
- StorageDead(_3); // scope 1 at $DIR/cast.rs:+2:23: +2:24
- _0 = const (); // scope 0 at $DIR/cast.rs:+0:11: +3:2
- StorageDead(_2); // scope 1 at $DIR/cast.rs:+3:1: +3:2
- StorageDead(_1); // scope 0 at $DIR/cast.rs:+3:1: +3:2
- return; // scope 0 at $DIR/cast.rs:+3:2: +3:2
+ StorageLive(_1);
+ _1 = const 257_i32;
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+- _4 = _1;
+- _3 = move _4 as u8 (IntToInt);
++ _4 = const 257_i32;
++ _3 = const 1_u8;
+ StorageDead(_4);
+- _2 = Add(move _3, const 1_u8);
++ _2 = const 2_u8;
+ StorageDead(_3);
+ _0 = const ();
+ StorageDead(_2);
+ StorageDead(_1);
+ return;
}
}
diff --git a/tests/mir-opt/dataflow-const-prop/cast.rs b/tests/mir-opt/dataflow-const-prop/cast.rs
index 484403f7f..c87872609 100644
--- a/tests/mir-opt/dataflow-const-prop/cast.rs
+++ b/tests/mir-opt/dataflow-const-prop/cast.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// unit-test: DataflowConstProp
// EMIT_MIR cast.main.DataflowConstProp.diff
diff --git a/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.diff
deleted file mode 100644
index 944afed8f..000000000
--- a/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.diff
+++ /dev/null
@@ -1,80 +0,0 @@
-- // MIR for `main` before DataflowConstProp
-+ // MIR for `main` after DataflowConstProp
-
- fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/checked.rs:+0:11: +0:11
- let _1: i32; // in scope 0 at $DIR/checked.rs:+1:9: +1:10
- let mut _4: i32; // in scope 0 at $DIR/checked.rs:+3:13: +3:14
- let mut _5: i32; // in scope 0 at $DIR/checked.rs:+3:17: +3:18
- let mut _6: (i32, bool); // in scope 0 at $DIR/checked.rs:+3:13: +3:18
- let mut _9: i32; // in scope 0 at $DIR/checked.rs:+6:13: +6:14
- let mut _10: (i32, bool); // in scope 0 at $DIR/checked.rs:+6:13: +6:18
- scope 1 {
- debug a => _1; // in scope 1 at $DIR/checked.rs:+1:9: +1:10
- let _2: i32; // in scope 1 at $DIR/checked.rs:+2:9: +2:10
- scope 2 {
- debug b => _2; // in scope 2 at $DIR/checked.rs:+2:9: +2:10
- let _3: i32; // in scope 2 at $DIR/checked.rs:+3:9: +3:10
- scope 3 {
- debug c => _3; // in scope 3 at $DIR/checked.rs:+3:9: +3:10
- let _7: i32; // in scope 3 at $DIR/checked.rs:+5:9: +5:10
- scope 4 {
- debug d => _7; // in scope 4 at $DIR/checked.rs:+5:9: +5:10
- let _8: i32; // in scope 4 at $DIR/checked.rs:+6:9: +6:10
- scope 5 {
- debug e => _8; // in scope 5 at $DIR/checked.rs:+6:9: +6:10
- }
- }
- }
- }
- }
-
- bb0: {
- StorageLive(_1); // scope 0 at $DIR/checked.rs:+1:9: +1:10
- _1 = const 1_i32; // scope 0 at $DIR/checked.rs:+1:13: +1:14
- StorageLive(_2); // scope 1 at $DIR/checked.rs:+2:9: +2:10
- _2 = const 2_i32; // scope 1 at $DIR/checked.rs:+2:13: +2:14
- StorageLive(_3); // scope 2 at $DIR/checked.rs:+3:9: +3:10
- StorageLive(_4); // scope 2 at $DIR/checked.rs:+3:13: +3:14
-- _4 = _1; // scope 2 at $DIR/checked.rs:+3:13: +3:14
-+ _4 = const 1_i32; // scope 2 at $DIR/checked.rs:+3:13: +3:14
- StorageLive(_5); // scope 2 at $DIR/checked.rs:+3:17: +3:18
-- _5 = _2; // scope 2 at $DIR/checked.rs:+3:17: +3:18
-- _6 = CheckedAdd(_4, _5); // scope 2 at $DIR/checked.rs:+3:13: +3:18
-- assert(!move (_6.1: bool), "attempt to compute `{} + {}`, which would overflow", move _4, move _5) -> bb1; // scope 2 at $DIR/checked.rs:+3:13: +3:18
-+ _5 = const 2_i32; // scope 2 at $DIR/checked.rs:+3:17: +3:18
-+ _6 = CheckedAdd(const 1_i32, const 2_i32); // scope 2 at $DIR/checked.rs:+3:13: +3:18
-+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_i32, const 2_i32) -> bb1; // scope 2 at $DIR/checked.rs:+3:13: +3:18
- }
-
- bb1: {
-- _3 = move (_6.0: i32); // scope 2 at $DIR/checked.rs:+3:13: +3:18
-+ _3 = const 3_i32; // scope 2 at $DIR/checked.rs:+3:13: +3:18
- StorageDead(_5); // scope 2 at $DIR/checked.rs:+3:17: +3:18
- StorageDead(_4); // scope 2 at $DIR/checked.rs:+3:17: +3:18
- StorageLive(_7); // scope 3 at $DIR/checked.rs:+5:9: +5:10
- _7 = const _; // scope 3 at $DIR/checked.rs:+5:13: +5:21
- StorageLive(_8); // scope 4 at $DIR/checked.rs:+6:9: +6:10
- StorageLive(_9); // scope 4 at $DIR/checked.rs:+6:13: +6:14
-- _9 = _7; // scope 4 at $DIR/checked.rs:+6:13: +6:14
-- _10 = CheckedAdd(_9, const 1_i32); // scope 4 at $DIR/checked.rs:+6:13: +6:18
-- assert(!move (_10.1: bool), "attempt to compute `{} + {}`, which would overflow", move _9, const 1_i32) -> bb2; // scope 4 at $DIR/checked.rs:+6:13: +6:18
-+ _9 = const i32::MAX; // scope 4 at $DIR/checked.rs:+6:13: +6:14
-+ _10 = CheckedAdd(const i32::MAX, const 1_i32); // scope 4 at $DIR/checked.rs:+6:13: +6:18
-+ assert(!const true, "attempt to compute `{} + {}`, which would overflow", const i32::MAX, const 1_i32) -> bb2; // scope 4 at $DIR/checked.rs:+6:13: +6:18
- }
-
- bb2: {
-- _8 = move (_10.0: i32); // scope 4 at $DIR/checked.rs:+6:13: +6:18
-+ _8 = const i32::MIN; // scope 4 at $DIR/checked.rs:+6:13: +6:18
- StorageDead(_9); // scope 4 at $DIR/checked.rs:+6:17: +6:18
- _0 = const (); // scope 0 at $DIR/checked.rs:+0:11: +7:2
- StorageDead(_8); // scope 4 at $DIR/checked.rs:+7:1: +7:2
- StorageDead(_7); // scope 3 at $DIR/checked.rs:+7:1: +7:2
- StorageDead(_3); // scope 2 at $DIR/checked.rs:+7:1: +7:2
- StorageDead(_2); // scope 1 at $DIR/checked.rs:+7:1: +7:2
- StorageDead(_1); // scope 0 at $DIR/checked.rs:+7:1: +7:2
- return; // scope 0 at $DIR/checked.rs:+7:2: +7:2
- }
- }
-
diff --git a/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-abort.diff
new file mode 100644
index 000000000..4569ffe48
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-abort.diff
@@ -0,0 +1,88 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: i32;
+ let mut _4: i32;
+ let mut _5: i32;
+ let mut _6: (i32, bool);
+ let mut _9: i32;
+ let mut _10: (i32, bool);
+ scope 1 {
+ debug a => _1;
+ let _2: i32;
+ scope 2 {
+ debug b => _2;
+ let _3: i32;
+ scope 3 {
+ debug c => _3;
+ let _7: i32;
+ scope 4 {
+ debug d => _7;
+ let _8: i32;
+ scope 5 {
+ debug e => _8;
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = const 1_i32;
+ StorageLive(_2);
+ _2 = const 2_i32;
+ StorageLive(_3);
+ StorageLive(_4);
+- _4 = _1;
++ _4 = const 1_i32;
+ StorageLive(_5);
+- _5 = _2;
+- _6 = CheckedAdd(_4, _5);
+- assert(!move (_6.1: bool), "attempt to compute `{} + {}`, which would overflow", move _4, move _5) -> [success: bb1, unwind unreachable];
++ _5 = const 2_i32;
++ _6 = const (3_i32, false);
++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_i32, const 2_i32) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+- _3 = move (_6.0: i32);
++ _3 = const 3_i32;
+ StorageDead(_5);
+ StorageDead(_4);
+ StorageLive(_7);
+ _7 = const _;
+ StorageLive(_8);
+ StorageLive(_9);
+- _9 = _7;
+- _10 = CheckedAdd(_9, const 1_i32);
+- assert(!move (_10.1: bool), "attempt to compute `{} + {}`, which would overflow", move _9, const 1_i32) -> [success: bb2, unwind unreachable];
++ _9 = const i32::MAX;
++ _10 = const (i32::MIN, true);
++ assert(!const true, "attempt to compute `{} + {}`, which would overflow", const i32::MAX, const 1_i32) -> [success: bb2, unwind unreachable];
+ }
+
+ bb2: {
+- _8 = move (_10.0: i32);
++ _8 = const i32::MIN;
+ StorageDead(_9);
+ _0 = const ();
+ StorageDead(_8);
+ StorageDead(_7);
+ StorageDead(_3);
+ StorageDead(_2);
+ StorageDead(_1);
+ return;
+ }
++ }
++
++ ALLOC0 (size: 8, align: 4) {
++ 00 00 00 80 01 __ __ __ │ .....░░░
++ }
++
++ ALLOC1 (size: 8, align: 4) {
++ 03 00 00 00 00 __ __ __ │ .....░░░
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-unwind.diff
new file mode 100644
index 000000000..aa7e404eb
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-unwind.diff
@@ -0,0 +1,88 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: i32;
+ let mut _4: i32;
+ let mut _5: i32;
+ let mut _6: (i32, bool);
+ let mut _9: i32;
+ let mut _10: (i32, bool);
+ scope 1 {
+ debug a => _1;
+ let _2: i32;
+ scope 2 {
+ debug b => _2;
+ let _3: i32;
+ scope 3 {
+ debug c => _3;
+ let _7: i32;
+ scope 4 {
+ debug d => _7;
+ let _8: i32;
+ scope 5 {
+ debug e => _8;
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = const 1_i32;
+ StorageLive(_2);
+ _2 = const 2_i32;
+ StorageLive(_3);
+ StorageLive(_4);
+- _4 = _1;
++ _4 = const 1_i32;
+ StorageLive(_5);
+- _5 = _2;
+- _6 = CheckedAdd(_4, _5);
+- assert(!move (_6.1: bool), "attempt to compute `{} + {}`, which would overflow", move _4, move _5) -> [success: bb1, unwind continue];
++ _5 = const 2_i32;
++ _6 = const (3_i32, false);
++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_i32, const 2_i32) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+- _3 = move (_6.0: i32);
++ _3 = const 3_i32;
+ StorageDead(_5);
+ StorageDead(_4);
+ StorageLive(_7);
+ _7 = const _;
+ StorageLive(_8);
+ StorageLive(_9);
+- _9 = _7;
+- _10 = CheckedAdd(_9, const 1_i32);
+- assert(!move (_10.1: bool), "attempt to compute `{} + {}`, which would overflow", move _9, const 1_i32) -> [success: bb2, unwind continue];
++ _9 = const i32::MAX;
++ _10 = const (i32::MIN, true);
++ assert(!const true, "attempt to compute `{} + {}`, which would overflow", const i32::MAX, const 1_i32) -> [success: bb2, unwind continue];
+ }
+
+ bb2: {
+- _8 = move (_10.0: i32);
++ _8 = const i32::MIN;
+ StorageDead(_9);
+ _0 = const ();
+ StorageDead(_8);
+ StorageDead(_7);
+ StorageDead(_3);
+ StorageDead(_2);
+ StorageDead(_1);
+ return;
+ }
++ }
++
++ ALLOC0 (size: 8, align: 4) {
++ 00 00 00 80 01 __ __ __ │ .....░░░
++ }
++
++ ALLOC1 (size: 8, align: 4) {
++ 03 00 00 00 00 __ __ __ │ .....░░░
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/checked.rs b/tests/mir-opt/dataflow-const-prop/checked.rs
index 0f9f5a97f..f7fac8890 100644
--- a/tests/mir-opt/dataflow-const-prop/checked.rs
+++ b/tests/mir-opt/dataflow-const-prop/checked.rs
@@ -1,6 +1,7 @@
-// ignore-wasm32 compiled with panic=abort by default
+// skip-filecheck
// unit-test: DataflowConstProp
// compile-flags: -Coverflow-checks=on
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// EMIT_MIR checked.main.DataflowConstProp.diff
#[allow(arithmetic_overflow)]
diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-abort.diff
new file mode 100644
index 000000000..8363783e6
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-abort.diff
@@ -0,0 +1,119 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: A;
+ let mut _2: std::boxed::Box<[bool]>;
+ scope 1 {
+ debug a => _1;
+ }
+ scope 2 (inlined <Box<[bool]> as Default>::default) {
+ let _3: std::ptr::Unique<[bool]>;
+ let mut _4: std::ptr::Unique<[bool; 0]>;
+ scope 3 {
+ debug ptr => _3;
+ }
+ scope 4 (inlined Unique::<[bool; 0]>::dangling) {
+ let mut _5: std::ptr::NonNull<[bool; 0]>;
+ scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
+ let mut _7: usize;
+ scope 6 {
+ let _6: *mut [bool; 0];
+ scope 7 {
+ debug ptr => _6;
+ scope 11 (inlined NonNull::<[bool; 0]>::new_unchecked) {
+ debug ptr => _6;
+ let mut _8: *const [bool; 0];
+ scope 12 {
+ scope 13 (inlined NonNull::<T>::new_unchecked::runtime::<[bool; 0]>) {
+ debug ptr => _6;
+ scope 14 (inlined std::ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) {
+ debug self => _6;
+ let mut _9: *mut u8;
+ scope 15 {
+ scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _9;
+ scope 17 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _9;
+ scope 18 {
+ scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
+ debug self => _9;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ scope 8 (inlined align_of::<[bool; 0]>) {
+ }
+ scope 9 (inlined invalid_mut::<[bool; 0]>) {
+ debug addr => _7;
+ scope 10 {
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+ StorageLive(_7);
+- _7 = AlignOf([bool; 0]);
+- _6 = _7 as *mut [bool; 0] (Transmute);
++ _7 = const 1_usize;
++ _6 = const {0x1 as *mut [bool; 0]};
+ StorageDead(_7);
+ StorageLive(_8);
+ StorageLive(_9);
+- _8 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer));
+- _5 = NonNull::<[bool; 0]> { pointer: _8 };
++ _8 = const {0x1 as *const [bool; 0]};
++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }};
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageDead(_6);
+- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> };
++ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }};
+ StorageDead(_5);
+- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize));
++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
+ StorageDead(_4);
+- _2 = Box::<[bool]>(_3, const std::alloc::Global);
++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
+ StorageDead(_3);
+- _1 = A { foo: move _2 };
++ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) };
+ StorageDead(_2);
+ _0 = const ();
+ drop(_1) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ StorageDead(_1);
+ return;
+ }
++ }
++
++ ALLOC2 (size: 8, align: 4) {
++ 01 00 00 00 00 00 00 00 │ ........
++ }
++
++ ALLOC1 (size: 8, align: 4) {
++ 01 00 00 00 00 00 00 00 │ ........
++ }
++
++ ALLOC0 (size: 8, align: 4) {
++ 01 00 00 00 00 00 00 00 │ ........
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff
new file mode 100644
index 000000000..19326b6a9
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff
@@ -0,0 +1,123 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: A;
+ let mut _2: std::boxed::Box<[bool]>;
+ scope 1 {
+ debug a => _1;
+ }
+ scope 2 (inlined <Box<[bool]> as Default>::default) {
+ let _3: std::ptr::Unique<[bool]>;
+ let mut _4: std::ptr::Unique<[bool; 0]>;
+ scope 3 {
+ debug ptr => _3;
+ }
+ scope 4 (inlined Unique::<[bool; 0]>::dangling) {
+ let mut _5: std::ptr::NonNull<[bool; 0]>;
+ scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
+ let mut _7: usize;
+ scope 6 {
+ let _6: *mut [bool; 0];
+ scope 7 {
+ debug ptr => _6;
+ scope 11 (inlined NonNull::<[bool; 0]>::new_unchecked) {
+ debug ptr => _6;
+ let mut _8: *const [bool; 0];
+ scope 12 {
+ scope 13 (inlined NonNull::<T>::new_unchecked::runtime::<[bool; 0]>) {
+ debug ptr => _6;
+ scope 14 (inlined std::ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) {
+ debug self => _6;
+ let mut _9: *mut u8;
+ scope 15 {
+ scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _9;
+ scope 17 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _9;
+ scope 18 {
+ scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
+ debug self => _9;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ scope 8 (inlined align_of::<[bool; 0]>) {
+ }
+ scope 9 (inlined invalid_mut::<[bool; 0]>) {
+ debug addr => _7;
+ scope 10 {
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+ StorageLive(_7);
+- _7 = AlignOf([bool; 0]);
+- _6 = _7 as *mut [bool; 0] (Transmute);
++ _7 = const 1_usize;
++ _6 = const {0x1 as *mut [bool; 0]};
+ StorageDead(_7);
+ StorageLive(_8);
+ StorageLive(_9);
+- _8 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer));
+- _5 = NonNull::<[bool; 0]> { pointer: _8 };
++ _8 = const {0x1 as *const [bool; 0]};
++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }};
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageDead(_6);
+- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> };
++ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }};
+ StorageDead(_5);
+- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize));
++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
+ StorageDead(_4);
+- _2 = Box::<[bool]>(_3, const std::alloc::Global);
++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
+ StorageDead(_3);
+- _1 = A { foo: move _2 };
++ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) };
+ StorageDead(_2);
+ _0 = const ();
+ drop(_1) -> [return: bb1, unwind: bb2];
+ }
+
+ bb1: {
+ StorageDead(_1);
+ return;
+ }
+
+ bb2 (cleanup): {
+ resume;
+ }
++ }
++
++ ALLOC2 (size: 8, align: 4) {
++ 01 00 00 00 00 00 00 00 │ ........
++ }
++
++ ALLOC1 (size: 8, align: 4) {
++ 01 00 00 00 00 00 00 00 │ ........
++ }
++
++ ALLOC0 (size: 8, align: 4) {
++ 01 00 00 00 00 00 00 00 │ ........
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-abort.diff
new file mode 100644
index 000000000..0d1e2430c
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-abort.diff
@@ -0,0 +1,119 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: A;
+ let mut _2: std::boxed::Box<[bool]>;
+ scope 1 {
+ debug a => _1;
+ }
+ scope 2 (inlined <Box<[bool]> as Default>::default) {
+ let _3: std::ptr::Unique<[bool]>;
+ let mut _4: std::ptr::Unique<[bool; 0]>;
+ scope 3 {
+ debug ptr => _3;
+ }
+ scope 4 (inlined Unique::<[bool; 0]>::dangling) {
+ let mut _5: std::ptr::NonNull<[bool; 0]>;
+ scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
+ let mut _7: usize;
+ scope 6 {
+ let _6: *mut [bool; 0];
+ scope 7 {
+ debug ptr => _6;
+ scope 11 (inlined NonNull::<[bool; 0]>::new_unchecked) {
+ debug ptr => _6;
+ let mut _8: *const [bool; 0];
+ scope 12 {
+ scope 13 (inlined NonNull::<T>::new_unchecked::runtime::<[bool; 0]>) {
+ debug ptr => _6;
+ scope 14 (inlined std::ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) {
+ debug self => _6;
+ let mut _9: *mut u8;
+ scope 15 {
+ scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _9;
+ scope 17 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _9;
+ scope 18 {
+ scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
+ debug self => _9;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ scope 8 (inlined align_of::<[bool; 0]>) {
+ }
+ scope 9 (inlined invalid_mut::<[bool; 0]>) {
+ debug addr => _7;
+ scope 10 {
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+ StorageLive(_7);
+- _7 = AlignOf([bool; 0]);
+- _6 = _7 as *mut [bool; 0] (Transmute);
++ _7 = const 1_usize;
++ _6 = const {0x1 as *mut [bool; 0]};
+ StorageDead(_7);
+ StorageLive(_8);
+ StorageLive(_9);
+- _8 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer));
+- _5 = NonNull::<[bool; 0]> { pointer: _8 };
++ _8 = const {0x1 as *const [bool; 0]};
++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }};
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageDead(_6);
+- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> };
++ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }};
+ StorageDead(_5);
+- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize));
++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
+ StorageDead(_4);
+- _2 = Box::<[bool]>(_3, const std::alloc::Global);
++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
+ StorageDead(_3);
+- _1 = A { foo: move _2 };
++ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) };
+ StorageDead(_2);
+ _0 = const ();
+ drop(_1) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ StorageDead(_1);
+ return;
+ }
++ }
++
++ ALLOC2 (size: 16, align: 8) {
++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
++ }
++
++ ALLOC1 (size: 16, align: 8) {
++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
++ }
++
++ ALLOC0 (size: 16, align: 8) {
++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff
new file mode 100644
index 000000000..35f1e5ba7
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff
@@ -0,0 +1,123 @@
+- // MIR for `main` before ConstProp
++ // MIR for `main` after ConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: A;
+ let mut _2: std::boxed::Box<[bool]>;
+ scope 1 {
+ debug a => _1;
+ }
+ scope 2 (inlined <Box<[bool]> as Default>::default) {
+ let _3: std::ptr::Unique<[bool]>;
+ let mut _4: std::ptr::Unique<[bool; 0]>;
+ scope 3 {
+ debug ptr => _3;
+ }
+ scope 4 (inlined Unique::<[bool; 0]>::dangling) {
+ let mut _5: std::ptr::NonNull<[bool; 0]>;
+ scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
+ let mut _7: usize;
+ scope 6 {
+ let _6: *mut [bool; 0];
+ scope 7 {
+ debug ptr => _6;
+ scope 11 (inlined NonNull::<[bool; 0]>::new_unchecked) {
+ debug ptr => _6;
+ let mut _8: *const [bool; 0];
+ scope 12 {
+ scope 13 (inlined NonNull::<T>::new_unchecked::runtime::<[bool; 0]>) {
+ debug ptr => _6;
+ scope 14 (inlined std::ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) {
+ debug self => _6;
+ let mut _9: *mut u8;
+ scope 15 {
+ scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _9;
+ scope 17 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _9;
+ scope 18 {
+ scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
+ debug self => _9;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ scope 8 (inlined align_of::<[bool; 0]>) {
+ }
+ scope 9 (inlined invalid_mut::<[bool; 0]>) {
+ debug addr => _7;
+ scope 10 {
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+ StorageLive(_7);
+- _7 = AlignOf([bool; 0]);
+- _6 = _7 as *mut [bool; 0] (Transmute);
++ _7 = const 1_usize;
++ _6 = const {0x1 as *mut [bool; 0]};
+ StorageDead(_7);
+ StorageLive(_8);
+ StorageLive(_9);
+- _8 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer));
+- _5 = NonNull::<[bool; 0]> { pointer: _8 };
++ _8 = const {0x1 as *const [bool; 0]};
++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }};
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageDead(_6);
+- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> };
++ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }};
+ StorageDead(_5);
+- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize));
++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
+ StorageDead(_4);
+- _2 = Box::<[bool]>(_3, const std::alloc::Global);
++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
+ StorageDead(_3);
+- _1 = A { foo: move _2 };
++ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) };
+ StorageDead(_2);
+ _0 = const ();
+ drop(_1) -> [return: bb1, unwind: bb2];
+ }
+
+ bb1: {
+ StorageDead(_1);
+ return;
+ }
+
+ bb2 (cleanup): {
+ resume;
+ }
++ }
++
++ ALLOC2 (size: 16, align: 8) {
++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
++ }
++
++ ALLOC1 (size: 16, align: 8) {
++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
++ }
++
++ ALLOC0 (size: 16, align: 8) {
++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff
new file mode 100644
index 000000000..ddfe2e8c8
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff
@@ -0,0 +1,111 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: A;
+ let mut _2: std::boxed::Box<[bool]>;
+ scope 1 {
+ debug a => _1;
+ }
+ scope 2 (inlined <Box<[bool]> as Default>::default) {
+ let _3: std::ptr::Unique<[bool]>;
+ let mut _4: std::ptr::Unique<[bool; 0]>;
+ scope 3 {
+ debug ptr => _3;
+ }
+ scope 4 (inlined Unique::<[bool; 0]>::dangling) {
+ let mut _5: std::ptr::NonNull<[bool; 0]>;
+ scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
+ let mut _7: usize;
+ scope 6 {
+ let _6: *mut [bool; 0];
+ scope 7 {
+ debug ptr => _6;
+ scope 11 (inlined NonNull::<[bool; 0]>::new_unchecked) {
+ debug ptr => _6;
+ let mut _8: *const [bool; 0];
+ scope 12 {
+ scope 13 (inlined NonNull::<T>::new_unchecked::runtime::<[bool; 0]>) {
+ debug ptr => _6;
+ scope 14 (inlined std::ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) {
+ debug self => _6;
+ let mut _9: *mut u8;
+ scope 15 {
+ scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _9;
+ scope 17 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _9;
+ scope 18 {
+ scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
+ debug self => _9;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ scope 8 (inlined align_of::<[bool; 0]>) {
+ }
+ scope 9 (inlined invalid_mut::<[bool; 0]>) {
+ debug addr => _7;
+ scope 10 {
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+ StorageLive(_7);
+ _7 = const 1_usize;
+ _6 = const {0x1 as *mut [bool; 0]};
+ StorageDead(_7);
+ StorageLive(_8);
+ StorageLive(_9);
+ _8 = const {0x1 as *const [bool; 0]};
+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }};
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageDead(_6);
+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }};
+ StorageDead(_5);
+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
+ StorageDead(_4);
+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
+ StorageDead(_3);
+ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) };
+ StorageDead(_2);
+ _0 = const ();
+ drop(_1) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ StorageDead(_1);
+ return;
+ }
+ }
+
+ ALLOC2 (size: 8, align: 4) {
+ 01 00 00 00 00 00 00 00 │ ........
+ }
+
+ ALLOC1 (size: 8, align: 4) {
+ 01 00 00 00 00 00 00 00 │ ........
+ }
+
+ ALLOC0 (size: 8, align: 4) {
+ 01 00 00 00 00 00 00 00 │ ........
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff
new file mode 100644
index 000000000..861295faa
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff
@@ -0,0 +1,115 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: A;
+ let mut _2: std::boxed::Box<[bool]>;
+ scope 1 {
+ debug a => _1;
+ }
+ scope 2 (inlined <Box<[bool]> as Default>::default) {
+ let _3: std::ptr::Unique<[bool]>;
+ let mut _4: std::ptr::Unique<[bool; 0]>;
+ scope 3 {
+ debug ptr => _3;
+ }
+ scope 4 (inlined Unique::<[bool; 0]>::dangling) {
+ let mut _5: std::ptr::NonNull<[bool; 0]>;
+ scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
+ let mut _7: usize;
+ scope 6 {
+ let _6: *mut [bool; 0];
+ scope 7 {
+ debug ptr => _6;
+ scope 11 (inlined NonNull::<[bool; 0]>::new_unchecked) {
+ debug ptr => _6;
+ let mut _8: *const [bool; 0];
+ scope 12 {
+ scope 13 (inlined NonNull::<T>::new_unchecked::runtime::<[bool; 0]>) {
+ debug ptr => _6;
+ scope 14 (inlined std::ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) {
+ debug self => _6;
+ let mut _9: *mut u8;
+ scope 15 {
+ scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _9;
+ scope 17 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _9;
+ scope 18 {
+ scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
+ debug self => _9;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ scope 8 (inlined align_of::<[bool; 0]>) {
+ }
+ scope 9 (inlined invalid_mut::<[bool; 0]>) {
+ debug addr => _7;
+ scope 10 {
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+ StorageLive(_7);
+ _7 = const 1_usize;
+ _6 = const {0x1 as *mut [bool; 0]};
+ StorageDead(_7);
+ StorageLive(_8);
+ StorageLive(_9);
+ _8 = const {0x1 as *const [bool; 0]};
+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }};
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageDead(_6);
+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }};
+ StorageDead(_5);
+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
+ StorageDead(_4);
+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
+ StorageDead(_3);
+ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) };
+ StorageDead(_2);
+ _0 = const ();
+ drop(_1) -> [return: bb1, unwind: bb2];
+ }
+
+ bb1: {
+ StorageDead(_1);
+ return;
+ }
+
+ bb2 (cleanup): {
+ resume;
+ }
+ }
+
+ ALLOC2 (size: 8, align: 4) {
+ 01 00 00 00 00 00 00 00 │ ........
+ }
+
+ ALLOC1 (size: 8, align: 4) {
+ 01 00 00 00 00 00 00 00 │ ........
+ }
+
+ ALLOC0 (size: 8, align: 4) {
+ 01 00 00 00 00 00 00 00 │ ........
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff
new file mode 100644
index 000000000..cbb639edc
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff
@@ -0,0 +1,111 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: A;
+ let mut _2: std::boxed::Box<[bool]>;
+ scope 1 {
+ debug a => _1;
+ }
+ scope 2 (inlined <Box<[bool]> as Default>::default) {
+ let _3: std::ptr::Unique<[bool]>;
+ let mut _4: std::ptr::Unique<[bool; 0]>;
+ scope 3 {
+ debug ptr => _3;
+ }
+ scope 4 (inlined Unique::<[bool; 0]>::dangling) {
+ let mut _5: std::ptr::NonNull<[bool; 0]>;
+ scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
+ let mut _7: usize;
+ scope 6 {
+ let _6: *mut [bool; 0];
+ scope 7 {
+ debug ptr => _6;
+ scope 11 (inlined NonNull::<[bool; 0]>::new_unchecked) {
+ debug ptr => _6;
+ let mut _8: *const [bool; 0];
+ scope 12 {
+ scope 13 (inlined NonNull::<T>::new_unchecked::runtime::<[bool; 0]>) {
+ debug ptr => _6;
+ scope 14 (inlined std::ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) {
+ debug self => _6;
+ let mut _9: *mut u8;
+ scope 15 {
+ scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _9;
+ scope 17 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _9;
+ scope 18 {
+ scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
+ debug self => _9;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ scope 8 (inlined align_of::<[bool; 0]>) {
+ }
+ scope 9 (inlined invalid_mut::<[bool; 0]>) {
+ debug addr => _7;
+ scope 10 {
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+ StorageLive(_7);
+ _7 = const 1_usize;
+ _6 = const {0x1 as *mut [bool; 0]};
+ StorageDead(_7);
+ StorageLive(_8);
+ StorageLive(_9);
+ _8 = const {0x1 as *const [bool; 0]};
+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }};
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageDead(_6);
+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }};
+ StorageDead(_5);
+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
+ StorageDead(_4);
+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
+ StorageDead(_3);
+ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) };
+ StorageDead(_2);
+ _0 = const ();
+ drop(_1) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ StorageDead(_1);
+ return;
+ }
+ }
+
+ ALLOC2 (size: 16, align: 8) {
+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
+ }
+
+ ALLOC1 (size: 16, align: 8) {
+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
+ }
+
+ ALLOC0 (size: 16, align: 8) {
+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff
new file mode 100644
index 000000000..656846e9f
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff
@@ -0,0 +1,115 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: A;
+ let mut _2: std::boxed::Box<[bool]>;
+ scope 1 {
+ debug a => _1;
+ }
+ scope 2 (inlined <Box<[bool]> as Default>::default) {
+ let _3: std::ptr::Unique<[bool]>;
+ let mut _4: std::ptr::Unique<[bool; 0]>;
+ scope 3 {
+ debug ptr => _3;
+ }
+ scope 4 (inlined Unique::<[bool; 0]>::dangling) {
+ let mut _5: std::ptr::NonNull<[bool; 0]>;
+ scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
+ let mut _7: usize;
+ scope 6 {
+ let _6: *mut [bool; 0];
+ scope 7 {
+ debug ptr => _6;
+ scope 11 (inlined NonNull::<[bool; 0]>::new_unchecked) {
+ debug ptr => _6;
+ let mut _8: *const [bool; 0];
+ scope 12 {
+ scope 13 (inlined NonNull::<T>::new_unchecked::runtime::<[bool; 0]>) {
+ debug ptr => _6;
+ scope 14 (inlined std::ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) {
+ debug self => _6;
+ let mut _9: *mut u8;
+ scope 15 {
+ scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _9;
+ scope 17 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _9;
+ scope 18 {
+ scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
+ debug self => _9;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ scope 8 (inlined align_of::<[bool; 0]>) {
+ }
+ scope 9 (inlined invalid_mut::<[bool; 0]>) {
+ debug addr => _7;
+ scope 10 {
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+ StorageLive(_7);
+ _7 = const 1_usize;
+ _6 = const {0x1 as *mut [bool; 0]};
+ StorageDead(_7);
+ StorageLive(_8);
+ StorageLive(_9);
+ _8 = const {0x1 as *const [bool; 0]};
+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }};
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageDead(_6);
+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }};
+ StorageDead(_5);
+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
+ StorageDead(_4);
+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
+ StorageDead(_3);
+ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) };
+ StorageDead(_2);
+ _0 = const ();
+ drop(_1) -> [return: bb1, unwind: bb2];
+ }
+
+ bb1: {
+ StorageDead(_1);
+ return;
+ }
+
+ bb2 (cleanup): {
+ resume;
+ }
+ }
+
+ ALLOC2 (size: 16, align: 8) {
+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
+ }
+
+ ALLOC1 (size: 16, align: 8) {
+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
+ }
+
+ ALLOC0 (size: 16, align: 8) {
+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs
new file mode 100644
index 000000000..1bb052736
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs
@@ -0,0 +1,18 @@
+// skip-filecheck
+// unit-test: DataflowConstProp
+// compile-flags: -Zmir-enable-passes=+ConstProp,+Inline
+// ignore-debug assertions change the output MIR
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+
+struct A {
+ foo: Box<[bool]>,
+}
+
+// EMIT_MIR default_boxed_slice.main.ConstProp.diff
+// EMIT_MIR default_boxed_slice.main.DataflowConstProp.diff
+fn main() {
+ // ConstProp will create a constant of type `Box<[bool]>`.
+ // Verify that `DataflowConstProp` does not ICE trying to dereference it directly.
+ let a: A = A { foo: Box::default() };
+}
diff --git a/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..07ac5b72e
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.32bit.diff
@@ -0,0 +1,63 @@
+- // MIR for `constant` before DataflowConstProp
++ // MIR for `constant` after DataflowConstProp
+
+ fn constant() -> () {
+ let mut _0: ();
+ let _1: E;
+ let mut _3: isize;
+ scope 1 {
+ debug e => _1;
+ let _2: i32;
+ let _4: i32;
+ let _5: i32;
+ scope 2 {
+ debug x => _2;
+ }
+ scope 3 {
+ debug x => _4;
+ }
+ scope 4 {
+ debug x => _5;
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = const _;
+ StorageLive(_2);
+- _3 = discriminant(_1);
+- switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2];
++ _3 = const 0_isize;
++ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ StorageLive(_5);
+ _5 = ((_1 as V2).0: i32);
+ _2 = _5;
+ StorageDead(_5);
+ goto -> bb4;
+ }
+
+ bb2: {
+ unreachable;
+ }
+
+ bb3: {
+ StorageLive(_4);
+- _4 = ((_1 as V1).0: i32);
+- _2 = _4;
++ _4 = const 0_i32;
++ _2 = const 0_i32;
+ StorageDead(_4);
+ goto -> bb4;
+ }
+
+ bb4: {
+ _0 = const ();
+ StorageDead(_2);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.64bit.diff
new file mode 100644
index 000000000..07ac5b72e
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.64bit.diff
@@ -0,0 +1,63 @@
+- // MIR for `constant` before DataflowConstProp
++ // MIR for `constant` after DataflowConstProp
+
+ fn constant() -> () {
+ let mut _0: ();
+ let _1: E;
+ let mut _3: isize;
+ scope 1 {
+ debug e => _1;
+ let _2: i32;
+ let _4: i32;
+ let _5: i32;
+ scope 2 {
+ debug x => _2;
+ }
+ scope 3 {
+ debug x => _4;
+ }
+ scope 4 {
+ debug x => _5;
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = const _;
+ StorageLive(_2);
+- _3 = discriminant(_1);
+- switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2];
++ _3 = const 0_isize;
++ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ StorageLive(_5);
+ _5 = ((_1 as V2).0: i32);
+ _2 = _5;
+ StorageDead(_5);
+ goto -> bb4;
+ }
+
+ bb2: {
+ unreachable;
+ }
+
+ bb3: {
+ StorageLive(_4);
+- _4 = ((_1 as V1).0: i32);
+- _2 = _4;
++ _4 = const 0_i32;
++ _2 = const 0_i32;
+ StorageDead(_4);
+ goto -> bb4;
+ }
+
+ bb4: {
+ _0 = const ();
+ StorageDead(_2);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..775325c4d
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.32bit.diff
@@ -0,0 +1,82 @@
+- // MIR for `multiple` before DataflowConstProp
++ // MIR for `multiple` after DataflowConstProp
+
+ fn multiple(_1: bool, _2: u8) -> () {
+ debug x => _1;
+ debug i => _2;
+ let mut _0: ();
+ let _3: std::option::Option<u8>;
+ let mut _4: bool;
+ let mut _5: u8;
+ let mut _7: isize;
+ scope 1 {
+ debug e => _3;
+ let _6: u8;
+ let _8: u8;
+ scope 2 {
+ debug x => _6;
+ let _9: u8;
+ scope 4 {
+ debug y => _9;
+ }
+ }
+ scope 3 {
+ debug i => _8;
+ }
+ }
+
+ bb0: {
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = _1;
+ switchInt(move _4) -> [0: bb2, otherwise: bb1];
+ }
+
+ bb1: {
+ StorageLive(_5);
+ _5 = _2;
+ _3 = Option::<u8>::Some(move _5);
+ StorageDead(_5);
+ goto -> bb3;
+ }
+
+ bb2: {
+ _3 = Option::<u8>::None;
+ goto -> bb3;
+ }
+
+ bb3: {
+ StorageDead(_4);
+ StorageLive(_6);
+ _7 = discriminant(_3);
+ switchInt(move _7) -> [0: bb4, 1: bb6, otherwise: bb5];
+ }
+
+ bb4: {
+ _6 = const 0_u8;
+ goto -> bb7;
+ }
+
+ bb5: {
+ unreachable;
+ }
+
+ bb6: {
+ StorageLive(_8);
+ _8 = ((_3 as Some).0: u8);
+ _6 = _8;
+ StorageDead(_8);
+ goto -> bb7;
+ }
+
+ bb7: {
+ StorageLive(_9);
+ _9 = _6;
+ _0 = const ();
+ StorageDead(_9);
+ StorageDead(_6);
+ StorageDead(_3);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.64bit.diff
new file mode 100644
index 000000000..775325c4d
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.64bit.diff
@@ -0,0 +1,82 @@
+- // MIR for `multiple` before DataflowConstProp
++ // MIR for `multiple` after DataflowConstProp
+
+ fn multiple(_1: bool, _2: u8) -> () {
+ debug x => _1;
+ debug i => _2;
+ let mut _0: ();
+ let _3: std::option::Option<u8>;
+ let mut _4: bool;
+ let mut _5: u8;
+ let mut _7: isize;
+ scope 1 {
+ debug e => _3;
+ let _6: u8;
+ let _8: u8;
+ scope 2 {
+ debug x => _6;
+ let _9: u8;
+ scope 4 {
+ debug y => _9;
+ }
+ }
+ scope 3 {
+ debug i => _8;
+ }
+ }
+
+ bb0: {
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = _1;
+ switchInt(move _4) -> [0: bb2, otherwise: bb1];
+ }
+
+ bb1: {
+ StorageLive(_5);
+ _5 = _2;
+ _3 = Option::<u8>::Some(move _5);
+ StorageDead(_5);
+ goto -> bb3;
+ }
+
+ bb2: {
+ _3 = Option::<u8>::None;
+ goto -> bb3;
+ }
+
+ bb3: {
+ StorageDead(_4);
+ StorageLive(_6);
+ _7 = discriminant(_3);
+ switchInt(move _7) -> [0: bb4, 1: bb6, otherwise: bb5];
+ }
+
+ bb4: {
+ _6 = const 0_u8;
+ goto -> bb7;
+ }
+
+ bb5: {
+ unreachable;
+ }
+
+ bb6: {
+ StorageLive(_8);
+ _8 = ((_3 as Some).0: u8);
+ _6 = _8;
+ StorageDead(_8);
+ goto -> bb7;
+ }
+
+ bb7: {
+ StorageLive(_9);
+ _9 = _6;
+ _0 = const ();
+ StorageDead(_9);
+ StorageDead(_6);
+ StorageDead(_3);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.diff
deleted file mode 100644
index c4002d65e..000000000
--- a/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.diff
+++ /dev/null
@@ -1,82 +0,0 @@
-- // MIR for `multiple` before DataflowConstProp
-+ // MIR for `multiple` after DataflowConstProp
-
- fn multiple(_1: bool, _2: u8) -> () {
- debug x => _1; // in scope 0 at $DIR/enum.rs:+0:13: +0:14
- debug i => _2; // in scope 0 at $DIR/enum.rs:+0:22: +0:23
- let mut _0: (); // return place in scope 0 at $DIR/enum.rs:+0:29: +0:29
- let _3: std::option::Option<u8>; // in scope 0 at $DIR/enum.rs:+1:9: +1:10
- let mut _4: bool; // in scope 0 at $DIR/enum.rs:+1:16: +1:17
- let mut _5: u8; // in scope 0 at $DIR/enum.rs:+2:14: +2:15
- let mut _7: isize; // in scope 0 at $DIR/enum.rs:+9:23: +9:30
- scope 1 {
- debug e => _3; // in scope 1 at $DIR/enum.rs:+1:9: +1:10
- let _6: u8; // in scope 1 at $DIR/enum.rs:+9:9: +9:10
- let _8: u8; // in scope 1 at $DIR/enum.rs:+9:28: +9:29
- scope 2 {
- debug x => _6; // in scope 2 at $DIR/enum.rs:+9:9: +9:10
- let _9: u8; // in scope 2 at $DIR/enum.rs:+11:9: +11:10
- scope 4 {
- debug y => _9; // in scope 4 at $DIR/enum.rs:+11:9: +11:10
- }
- }
- scope 3 {
- debug i => _8; // in scope 3 at $DIR/enum.rs:+9:28: +9:29
- }
- }
-
- bb0: {
- StorageLive(_3); // scope 0 at $DIR/enum.rs:+1:9: +1:10
- StorageLive(_4); // scope 0 at $DIR/enum.rs:+1:16: +1:17
- _4 = _1; // scope 0 at $DIR/enum.rs:+1:16: +1:17
- switchInt(move _4) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/enum.rs:+1:16: +1:17
- }
-
- bb1: {
- StorageLive(_5); // scope 0 at $DIR/enum.rs:+2:14: +2:15
- _5 = _2; // scope 0 at $DIR/enum.rs:+2:14: +2:15
- _3 = Option::<u8>::Some(move _5); // scope 0 at $DIR/enum.rs:+2:9: +2:16
- StorageDead(_5); // scope 0 at $DIR/enum.rs:+2:15: +2:16
- goto -> bb3; // scope 0 at $DIR/enum.rs:+1:13: +5:6
- }
-
- bb2: {
- _3 = Option::<u8>::None; // scope 0 at $DIR/enum.rs:+4:9: +4:13
- goto -> bb3; // scope 0 at $DIR/enum.rs:+1:13: +5:6
- }
-
- bb3: {
- StorageDead(_4); // scope 0 at $DIR/enum.rs:+5:5: +5:6
- StorageLive(_6); // scope 1 at $DIR/enum.rs:+9:9: +9:10
- _7 = discriminant(_3); // scope 1 at $DIR/enum.rs:+9:19: +9:20
- switchInt(move _7) -> [0: bb4, 1: bb6, otherwise: bb5]; // scope 1 at $DIR/enum.rs:+9:13: +9:20
- }
-
- bb4: {
- _6 = const 0_u8; // scope 1 at $DIR/enum.rs:+9:45: +9:46
- goto -> bb7; // scope 1 at $DIR/enum.rs:+9:45: +9:46
- }
-
- bb5: {
- unreachable; // scope 1 at $DIR/enum.rs:+9:19: +9:20
- }
-
- bb6: {
- StorageLive(_8); // scope 1 at $DIR/enum.rs:+9:28: +9:29
- _8 = ((_3 as Some).0: u8); // scope 1 at $DIR/enum.rs:+9:28: +9:29
- _6 = _8; // scope 3 at $DIR/enum.rs:+9:34: +9:35
- StorageDead(_8); // scope 1 at $DIR/enum.rs:+9:34: +9:35
- goto -> bb7; // scope 1 at $DIR/enum.rs:+9:34: +9:35
- }
-
- bb7: {
- StorageLive(_9); // scope 2 at $DIR/enum.rs:+11:9: +11:10
- _9 = _6; // scope 2 at $DIR/enum.rs:+11:13: +11:14
- _0 = const (); // scope 0 at $DIR/enum.rs:+0:29: +12:2
- StorageDead(_9); // scope 2 at $DIR/enum.rs:+12:1: +12:2
- StorageDead(_6); // scope 1 at $DIR/enum.rs:+12:1: +12:2
- StorageDead(_3); // scope 0 at $DIR/enum.rs:+12:1: +12:2
- return; // scope 0 at $DIR/enum.rs:+12:2: +12:2
- }
- }
-
diff --git a/tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..960e69ee9
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.32bit.diff
@@ -0,0 +1,26 @@
+- // MIR for `mutate_discriminant` before DataflowConstProp
++ // MIR for `mutate_discriminant` after DataflowConstProp
+
+ fn mutate_discriminant() -> u8 {
+ let mut _0: u8;
+ let mut _1: std::option::Option<NonZeroUsize>;
+ let mut _2: isize;
+
+ bb0: {
+ discriminant(_1) = 1;
+ (((_1 as variant#1).0: NonZeroUsize).0: usize) = const 0_usize;
+ _2 = discriminant(_1);
+ switchInt(_2) -> [0: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ _0 = const 1_u8;
+ return;
+ }
+
+ bb2: {
+ _0 = const 2_u8;
+ unreachable;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.64bit.diff
new file mode 100644
index 000000000..960e69ee9
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.64bit.diff
@@ -0,0 +1,26 @@
+- // MIR for `mutate_discriminant` before DataflowConstProp
++ // MIR for `mutate_discriminant` after DataflowConstProp
+
+ fn mutate_discriminant() -> u8 {
+ let mut _0: u8;
+ let mut _1: std::option::Option<NonZeroUsize>;
+ let mut _2: isize;
+
+ bb0: {
+ discriminant(_1) = 1;
+ (((_1 as variant#1).0: NonZeroUsize).0: usize) = const 0_usize;
+ _2 = discriminant(_1);
+ switchInt(_2) -> [0: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ _0 = const 1_u8;
+ return;
+ }
+
+ bb2: {
+ _0 = const 2_u8;
+ unreachable;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.diff
deleted file mode 100644
index 038e6c6bd..000000000
--- a/tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.diff
+++ /dev/null
@@ -1,26 +0,0 @@
-- // MIR for `mutate_discriminant` before DataflowConstProp
-+ // MIR for `mutate_discriminant` after DataflowConstProp
-
- fn mutate_discriminant() -> u8 {
- let mut _0: u8; // return place in scope 0 at $DIR/enum.rs:+0:29: +0:31
- let mut _1: std::option::Option<NonZeroUsize>; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
- let mut _2: isize; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
-
- bb0: {
- discriminant(_1) = 1; // scope 0 at $DIR/enum.rs:+4:13: +4:34
- (((_1 as variant#1).0: NonZeroUsize).0: usize) = const 0_usize; // scope 0 at $DIR/enum.rs:+6:13: +6:64
- _2 = discriminant(_1); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
- switchInt(_2) -> [0: bb1, otherwise: bb2]; // scope 0 at $DIR/enum.rs:+9:13: +12:14
- }
-
- bb1: {
- _0 = const 1_u8; // scope 0 at $DIR/enum.rs:+15:13: +15:20
- return; // scope 0 at $DIR/enum.rs:+16:13: +16:21
- }
-
- bb2: {
- _0 = const 2_u8; // scope 0 at $DIR/enum.rs:+19:13: +19:20
- unreachable; // scope 0 at $DIR/enum.rs:+20:13: +20:26
- }
- }
-
diff --git a/tests/mir-opt/dataflow-const-prop/enum.rs b/tests/mir-opt/dataflow-const-prop/enum.rs
index 79a20d7ef..e35c0e6e8 100644
--- a/tests/mir-opt/dataflow-const-prop/enum.rs
+++ b/tests/mir-opt/dataflow-const-prop/enum.rs
@@ -1,9 +1,12 @@
+// skip-filecheck
// unit-test: DataflowConstProp
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
#![feature(custom_mir, core_intrinsics, rustc_attrs)]
use std::intrinsics::mir::*;
+#[derive(Copy, Clone)]
enum E {
V1(i32),
V2(i32)
@@ -15,6 +18,24 @@ fn simple() {
let x = match e { E::V1(x) => x, E::V2(x) => x };
}
+// EMIT_MIR enum.constant.DataflowConstProp.diff
+fn constant() {
+ const C: E = E::V1(0);
+ let e = C;
+ let x = match e { E::V1(x) => x, E::V2(x) => x };
+}
+
+// EMIT_MIR enum.statics.DataflowConstProp.diff
+fn statics() {
+ static C: E = E::V1(0);
+ let e = C;
+ let x = match e { E::V1(x) => x, E::V2(x) => x };
+
+ static RC: &E = &E::V2(4);
+ let e = RC;
+ let x = match e { E::V1(x) => x, E::V2(x) => x };
+}
+
#[rustc_layout_scalar_valid_range_start(1)]
#[rustc_nonnull_optimization_guaranteed]
struct NonZeroUsize(usize);
@@ -63,6 +84,8 @@ fn multiple(x: bool, i: u8) {
fn main() {
simple();
+ constant();
+ statics();
mutate_discriminant();
multiple(false, 5);
}
diff --git a/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..798b0c041
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.32bit.diff
@@ -0,0 +1,68 @@
+- // MIR for `simple` before DataflowConstProp
++ // MIR for `simple` after DataflowConstProp
+
+ fn simple() -> () {
+ let mut _0: ();
+ let _1: E;
+ let mut _3: isize;
+ scope 1 {
+ debug e => _1;
+ let _2: i32;
+ let _4: i32;
+ let _5: i32;
+ scope 2 {
+ debug x => _2;
+ }
+ scope 3 {
+ debug x => _4;
+ }
+ scope 4 {
+ debug x => _5;
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+- _1 = E::V1(const 0_i32);
++ _1 = const E::V1(0_i32);
+ StorageLive(_2);
+- _3 = discriminant(_1);
+- switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2];
++ _3 = const 0_isize;
++ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ StorageLive(_5);
+ _5 = ((_1 as V2).0: i32);
+ _2 = _5;
+ StorageDead(_5);
+ goto -> bb4;
+ }
+
+ bb2: {
+ unreachable;
+ }
+
+ bb3: {
+ StorageLive(_4);
+- _4 = ((_1 as V1).0: i32);
+- _2 = _4;
++ _4 = const 0_i32;
++ _2 = const 0_i32;
+ StorageDead(_4);
+ goto -> bb4;
+ }
+
+ bb4: {
+ _0 = const ();
+ StorageDead(_2);
+ StorageDead(_1);
+ return;
+ }
++ }
++
++ ALLOC0 (size: 8, align: 4) {
++ 00 00 00 00 00 00 00 00 │ ........
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.64bit.diff
new file mode 100644
index 000000000..798b0c041
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.64bit.diff
@@ -0,0 +1,68 @@
+- // MIR for `simple` before DataflowConstProp
++ // MIR for `simple` after DataflowConstProp
+
+ fn simple() -> () {
+ let mut _0: ();
+ let _1: E;
+ let mut _3: isize;
+ scope 1 {
+ debug e => _1;
+ let _2: i32;
+ let _4: i32;
+ let _5: i32;
+ scope 2 {
+ debug x => _2;
+ }
+ scope 3 {
+ debug x => _4;
+ }
+ scope 4 {
+ debug x => _5;
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+- _1 = E::V1(const 0_i32);
++ _1 = const E::V1(0_i32);
+ StorageLive(_2);
+- _3 = discriminant(_1);
+- switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2];
++ _3 = const 0_isize;
++ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ StorageLive(_5);
+ _5 = ((_1 as V2).0: i32);
+ _2 = _5;
+ StorageDead(_5);
+ goto -> bb4;
+ }
+
+ bb2: {
+ unreachable;
+ }
+
+ bb3: {
+ StorageLive(_4);
+- _4 = ((_1 as V1).0: i32);
+- _2 = _4;
++ _4 = const 0_i32;
++ _2 = const 0_i32;
+ StorageDead(_4);
+ goto -> bb4;
+ }
+
+ bb4: {
+ _0 = const ();
+ StorageDead(_2);
+ StorageDead(_1);
+ return;
+ }
++ }
++
++ ALLOC0 (size: 8, align: 4) {
++ 00 00 00 00 00 00 00 00 │ ........
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.diff
deleted file mode 100644
index 22bdc35d6..000000000
--- a/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.diff
+++ /dev/null
@@ -1,63 +0,0 @@
-- // MIR for `simple` before DataflowConstProp
-+ // MIR for `simple` after DataflowConstProp
-
- fn simple() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/enum.rs:+0:13: +0:13
- let _1: E; // in scope 0 at $DIR/enum.rs:+1:9: +1:10
- let mut _3: isize; // in scope 0 at $DIR/enum.rs:+2:23: +2:31
- scope 1 {
- debug e => _1; // in scope 1 at $DIR/enum.rs:+1:9: +1:10
- let _2: i32; // in scope 1 at $DIR/enum.rs:+2:9: +2:10
- let _4: i32; // in scope 1 at $DIR/enum.rs:+2:29: +2:30
- let _5: i32; // in scope 1 at $DIR/enum.rs:+2:44: +2:45
- scope 2 {
- debug x => _2; // in scope 2 at $DIR/enum.rs:+2:9: +2:10
- }
- scope 3 {
- debug x => _4; // in scope 3 at $DIR/enum.rs:+2:29: +2:30
- }
- scope 4 {
- debug x => _5; // in scope 4 at $DIR/enum.rs:+2:44: +2:45
- }
- }
-
- bb0: {
- StorageLive(_1); // scope 0 at $DIR/enum.rs:+1:9: +1:10
- _1 = E::V1(const 0_i32); // scope 0 at $DIR/enum.rs:+1:13: +1:21
- StorageLive(_2); // scope 1 at $DIR/enum.rs:+2:9: +2:10
-- _3 = discriminant(_1); // scope 1 at $DIR/enum.rs:+2:19: +2:20
-- switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; // scope 1 at $DIR/enum.rs:+2:13: +2:20
-+ _3 = const 0_isize; // scope 1 at $DIR/enum.rs:+2:19: +2:20
-+ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2]; // scope 1 at $DIR/enum.rs:+2:13: +2:20
- }
-
- bb1: {
- StorageLive(_5); // scope 1 at $DIR/enum.rs:+2:44: +2:45
- _5 = ((_1 as V2).0: i32); // scope 1 at $DIR/enum.rs:+2:44: +2:45
- _2 = _5; // scope 4 at $DIR/enum.rs:+2:50: +2:51
- StorageDead(_5); // scope 1 at $DIR/enum.rs:+2:50: +2:51
- goto -> bb4; // scope 1 at $DIR/enum.rs:+2:50: +2:51
- }
-
- bb2: {
- unreachable; // scope 1 at $DIR/enum.rs:+2:19: +2:20
- }
-
- bb3: {
- StorageLive(_4); // scope 1 at $DIR/enum.rs:+2:29: +2:30
-- _4 = ((_1 as V1).0: i32); // scope 1 at $DIR/enum.rs:+2:29: +2:30
-- _2 = _4; // scope 3 at $DIR/enum.rs:+2:35: +2:36
-+ _4 = const 0_i32; // scope 1 at $DIR/enum.rs:+2:29: +2:30
-+ _2 = const 0_i32; // scope 3 at $DIR/enum.rs:+2:35: +2:36
- StorageDead(_4); // scope 1 at $DIR/enum.rs:+2:35: +2:36
- goto -> bb4; // scope 1 at $DIR/enum.rs:+2:35: +2:36
- }
-
- bb4: {
- _0 = const (); // scope 0 at $DIR/enum.rs:+0:13: +3:2
- StorageDead(_2); // scope 1 at $DIR/enum.rs:+3:1: +3:2
- StorageDead(_1); // scope 0 at $DIR/enum.rs:+3:1: +3:2
- return; // scope 0 at $DIR/enum.rs:+3:2: +3:2
- }
- }
-
diff --git a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..053981abe
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff
@@ -0,0 +1,131 @@
+- // MIR for `statics` before DataflowConstProp
++ // MIR for `statics` after DataflowConstProp
+
+ fn statics() -> () {
+ let mut _0: ();
+ let _1: E;
+ let mut _2: &E;
+ let mut _4: isize;
+ let mut _8: &&E;
+ let mut _10: isize;
+ scope 1 {
+ debug e => _1;
+ let _3: i32;
+ let _5: i32;
+ let _6: i32;
+ scope 2 {
+ debug x => _3;
+ let _7: &E;
+ scope 5 {
+ debug e => _7;
+ let _9: &i32;
+ let _11: &i32;
+ let _12: &i32;
+ scope 6 {
+ debug x => _9;
+ }
+ scope 7 {
+ debug x => _11;
+ }
+ scope 8 {
+ debug x => _12;
+ }
+ }
+ }
+ scope 3 {
+ debug x => _5;
+ }
+ scope 4 {
+ debug x => _6;
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ _2 = const {ALLOC1: &E};
+- _1 = (*_2);
++ _1 = const E::V1(0_i32);
+ StorageDead(_2);
+ StorageLive(_3);
+- _4 = discriminant(_1);
+- switchInt(move _4) -> [0: bb3, 1: bb1, otherwise: bb2];
++ _4 = const 0_isize;
++ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ StorageLive(_6);
+ _6 = ((_1 as V2).0: i32);
+ _3 = _6;
+ StorageDead(_6);
+ goto -> bb4;
+ }
+
+ bb2: {
+ unreachable;
+ }
+
+ bb3: {
+ StorageLive(_5);
+- _5 = ((_1 as V1).0: i32);
+- _3 = _5;
++ _5 = const 0_i32;
++ _3 = const 0_i32;
+ StorageDead(_5);
+ goto -> bb4;
+ }
+
+ bb4: {
+ StorageLive(_7);
+ StorageLive(_8);
+ _8 = const {ALLOC2: &&E};
+ _7 = (*_8);
+ StorageDead(_8);
+ StorageLive(_9);
+ _10 = discriminant((*_7));
+ switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb2];
+ }
+
+ bb5: {
+ StorageLive(_12);
+ _12 = &(((*_7) as V2).0: i32);
+ _9 = &(*_12);
+ StorageDead(_12);
+ goto -> bb7;
+ }
+
+ bb6: {
+ StorageLive(_11);
+ _11 = &(((*_7) as V1).0: i32);
+ _9 = _11;
+ StorageDead(_11);
+ goto -> bb7;
+ }
+
+ bb7: {
+ _0 = const ();
+ StorageDead(_9);
+ StorageDead(_7);
+ StorageDead(_3);
+ StorageDead(_1);
+ return;
+ }
++ }
++
++ ALLOC3 (size: 8, align: 4) {
++ 00 00 00 00 00 00 00 00 │ ........
+ }
+
+ ALLOC2 (static: RC, size: 4, align: 4) {
+ ╾ALLOC0<imm>╼ │ ╾──╼
+ }
+
+ ALLOC0 (size: 8, align: 4) {
+ 01 00 00 00 04 00 00 00 │ ........
+ }
+
+ ALLOC1 (static: statics::C, size: 8, align: 4) {
+ 00 00 00 00 00 00 00 00 │ ........
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff
new file mode 100644
index 000000000..d862bd93f
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff
@@ -0,0 +1,131 @@
+- // MIR for `statics` before DataflowConstProp
++ // MIR for `statics` after DataflowConstProp
+
+ fn statics() -> () {
+ let mut _0: ();
+ let _1: E;
+ let mut _2: &E;
+ let mut _4: isize;
+ let mut _8: &&E;
+ let mut _10: isize;
+ scope 1 {
+ debug e => _1;
+ let _3: i32;
+ let _5: i32;
+ let _6: i32;
+ scope 2 {
+ debug x => _3;
+ let _7: &E;
+ scope 5 {
+ debug e => _7;
+ let _9: &i32;
+ let _11: &i32;
+ let _12: &i32;
+ scope 6 {
+ debug x => _9;
+ }
+ scope 7 {
+ debug x => _11;
+ }
+ scope 8 {
+ debug x => _12;
+ }
+ }
+ }
+ scope 3 {
+ debug x => _5;
+ }
+ scope 4 {
+ debug x => _6;
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ _2 = const {ALLOC1: &E};
+- _1 = (*_2);
++ _1 = const E::V1(0_i32);
+ StorageDead(_2);
+ StorageLive(_3);
+- _4 = discriminant(_1);
+- switchInt(move _4) -> [0: bb3, 1: bb1, otherwise: bb2];
++ _4 = const 0_isize;
++ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ StorageLive(_6);
+ _6 = ((_1 as V2).0: i32);
+ _3 = _6;
+ StorageDead(_6);
+ goto -> bb4;
+ }
+
+ bb2: {
+ unreachable;
+ }
+
+ bb3: {
+ StorageLive(_5);
+- _5 = ((_1 as V1).0: i32);
+- _3 = _5;
++ _5 = const 0_i32;
++ _3 = const 0_i32;
+ StorageDead(_5);
+ goto -> bb4;
+ }
+
+ bb4: {
+ StorageLive(_7);
+ StorageLive(_8);
+ _8 = const {ALLOC2: &&E};
+ _7 = (*_8);
+ StorageDead(_8);
+ StorageLive(_9);
+ _10 = discriminant((*_7));
+ switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb2];
+ }
+
+ bb5: {
+ StorageLive(_12);
+ _12 = &(((*_7) as V2).0: i32);
+ _9 = &(*_12);
+ StorageDead(_12);
+ goto -> bb7;
+ }
+
+ bb6: {
+ StorageLive(_11);
+ _11 = &(((*_7) as V1).0: i32);
+ _9 = _11;
+ StorageDead(_11);
+ goto -> bb7;
+ }
+
+ bb7: {
+ _0 = const ();
+ StorageDead(_9);
+ StorageDead(_7);
+ StorageDead(_3);
+ StorageDead(_1);
+ return;
+ }
++ }
++
++ ALLOC3 (size: 8, align: 4) {
++ 00 00 00 00 00 00 00 00 │ ........
+ }
+
+ ALLOC2 (static: RC, size: 8, align: 8) {
+ ╾ALLOC0<imm>╼ │ ╾──────╼
+ }
+
+ ALLOC0 (size: 8, align: 4) {
+ 01 00 00 00 04 00 00 00 │ ........
+ }
+
+ ALLOC1 (static: statics::C, size: 8, align: 4) {
+ 00 00 00 00 00 00 00 00 │ ........
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/if.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/if.main.DataflowConstProp.diff
index 32489b4bd..355f28b03 100644
--- a/tests/mir-opt/dataflow-const-prop/if.main.DataflowConstProp.diff
+++ b/tests/mir-opt/dataflow-const-prop/if.main.DataflowConstProp.diff
@@ -2,29 +2,29 @@
+ // MIR for `main` after DataflowConstProp
fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/if.rs:+0:11: +0:11
- let _1: i32; // in scope 0 at $DIR/if.rs:+1:9: +1:10
- let mut _3: bool; // in scope 0 at $DIR/if.rs:+2:16: +2:22
- let mut _4: i32; // in scope 0 at $DIR/if.rs:+2:16: +2:17
- let mut _6: i32; // in scope 0 at $DIR/if.rs:+3:13: +3:14
- let mut _8: bool; // in scope 0 at $DIR/if.rs:+5:16: +5:22
- let mut _9: i32; // in scope 0 at $DIR/if.rs:+5:16: +5:17
- let mut _10: i32; // in scope 0 at $DIR/if.rs:+5:36: +5:37
- let mut _12: i32; // in scope 0 at $DIR/if.rs:+6:13: +6:14
+ let mut _0: ();
+ let _1: i32;
+ let mut _3: bool;
+ let mut _4: i32;
+ let mut _6: i32;
+ let mut _8: bool;
+ let mut _9: i32;
+ let mut _10: i32;
+ let mut _12: i32;
scope 1 {
- debug a => _1; // in scope 1 at $DIR/if.rs:+1:9: +1:10
- let _2: i32; // in scope 1 at $DIR/if.rs:+2:9: +2:10
+ debug a => _1;
+ let _2: i32;
scope 2 {
- debug b => _2; // in scope 2 at $DIR/if.rs:+2:9: +2:10
- let _5: i32; // in scope 2 at $DIR/if.rs:+3:9: +3:10
+ debug b => _2;
+ let _5: i32;
scope 3 {
- debug c => _5; // in scope 3 at $DIR/if.rs:+3:9: +3:10
- let _7: i32; // in scope 3 at $DIR/if.rs:+5:9: +5:10
+ debug c => _5;
+ let _7: i32;
scope 4 {
- debug d => _7; // in scope 4 at $DIR/if.rs:+5:9: +5:10
- let _11: i32; // in scope 4 at $DIR/if.rs:+6:9: +6:10
+ debug d => _7;
+ let _11: i32;
scope 5 {
- debug e => _11; // in scope 5 at $DIR/if.rs:+6:9: +6:10
+ debug e => _11;
}
}
}
@@ -32,81 +32,83 @@
}
bb0: {
- StorageLive(_1); // scope 0 at $DIR/if.rs:+1:9: +1:10
- _1 = const 1_i32; // scope 0 at $DIR/if.rs:+1:13: +1:14
- StorageLive(_2); // scope 1 at $DIR/if.rs:+2:9: +2:10
- StorageLive(_3); // scope 1 at $DIR/if.rs:+2:16: +2:22
- StorageLive(_4); // scope 1 at $DIR/if.rs:+2:16: +2:17
-- _4 = _1; // scope 1 at $DIR/if.rs:+2:16: +2:17
-- _3 = Eq(move _4, const 1_i32); // scope 1 at $DIR/if.rs:+2:16: +2:22
-+ _4 = const 1_i32; // scope 1 at $DIR/if.rs:+2:16: +2:17
-+ _3 = const true; // scope 1 at $DIR/if.rs:+2:16: +2:22
- StorageDead(_4); // scope 1 at $DIR/if.rs:+2:21: +2:22
-- switchInt(move _3) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/if.rs:+2:16: +2:22
-+ switchInt(const true) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/if.rs:+2:16: +2:22
+ StorageLive(_1);
+ _1 = const 1_i32;
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+- _4 = _1;
+- _3 = Eq(move _4, const 1_i32);
+- switchInt(move _3) -> [0: bb2, otherwise: bb1];
++ _4 = const 1_i32;
++ _3 = const true;
++ switchInt(const true) -> [0: bb2, otherwise: bb1];
}
bb1: {
- _2 = const 2_i32; // scope 1 at $DIR/if.rs:+2:25: +2:26
- goto -> bb3; // scope 1 at $DIR/if.rs:+2:13: +2:39
+ StorageDead(_4);
+ _2 = const 2_i32;
+ goto -> bb3;
}
bb2: {
- _2 = const 3_i32; // scope 1 at $DIR/if.rs:+2:36: +2:37
- goto -> bb3; // scope 1 at $DIR/if.rs:+2:13: +2:39
+ StorageDead(_4);
+ _2 = const 3_i32;
+ goto -> bb3;
}
bb3: {
- StorageDead(_3); // scope 1 at $DIR/if.rs:+2:38: +2:39
- StorageLive(_5); // scope 2 at $DIR/if.rs:+3:9: +3:10
- StorageLive(_6); // scope 2 at $DIR/if.rs:+3:13: +3:14
-- _6 = _2; // scope 2 at $DIR/if.rs:+3:13: +3:14
-- _5 = Add(move _6, const 1_i32); // scope 2 at $DIR/if.rs:+3:13: +3:18
-+ _6 = const 2_i32; // scope 2 at $DIR/if.rs:+3:13: +3:14
-+ _5 = const 3_i32; // scope 2 at $DIR/if.rs:+3:13: +3:18
- StorageDead(_6); // scope 2 at $DIR/if.rs:+3:17: +3:18
- StorageLive(_7); // scope 3 at $DIR/if.rs:+5:9: +5:10
- StorageLive(_8); // scope 3 at $DIR/if.rs:+5:16: +5:22
- StorageLive(_9); // scope 3 at $DIR/if.rs:+5:16: +5:17
-- _9 = _1; // scope 3 at $DIR/if.rs:+5:16: +5:17
-- _8 = Eq(move _9, const 1_i32); // scope 3 at $DIR/if.rs:+5:16: +5:22
-+ _9 = const 1_i32; // scope 3 at $DIR/if.rs:+5:16: +5:17
-+ _8 = const true; // scope 3 at $DIR/if.rs:+5:16: +5:22
- StorageDead(_9); // scope 3 at $DIR/if.rs:+5:21: +5:22
-- switchInt(move _8) -> [0: bb5, otherwise: bb4]; // scope 3 at $DIR/if.rs:+5:16: +5:22
-+ switchInt(const true) -> [0: bb5, otherwise: bb4]; // scope 3 at $DIR/if.rs:+5:16: +5:22
+ StorageDead(_3);
+ StorageLive(_5);
+ StorageLive(_6);
+- _6 = _2;
+- _5 = Add(move _6, const 1_i32);
++ _6 = const 2_i32;
++ _5 = const 3_i32;
+ StorageDead(_6);
+ StorageLive(_7);
+ StorageLive(_8);
+ StorageLive(_9);
+- _9 = _1;
+- _8 = Eq(move _9, const 1_i32);
+- switchInt(move _8) -> [0: bb5, otherwise: bb4];
++ _9 = const 1_i32;
++ _8 = const true;
++ switchInt(const true) -> [0: bb5, otherwise: bb4];
}
bb4: {
-- _7 = _1; // scope 3 at $DIR/if.rs:+5:25: +5:26
-+ _7 = const 1_i32; // scope 3 at $DIR/if.rs:+5:25: +5:26
- goto -> bb6; // scope 3 at $DIR/if.rs:+5:13: +5:43
+ StorageDead(_9);
+- _7 = _1;
++ _7 = const 1_i32;
+ goto -> bb6;
}
bb5: {
- StorageLive(_10); // scope 3 at $DIR/if.rs:+5:36: +5:37
- _10 = _1; // scope 3 at $DIR/if.rs:+5:36: +5:37
- _7 = Add(move _10, const 1_i32); // scope 3 at $DIR/if.rs:+5:36: +5:41
- StorageDead(_10); // scope 3 at $DIR/if.rs:+5:40: +5:41
- goto -> bb6; // scope 3 at $DIR/if.rs:+5:13: +5:43
+ StorageDead(_9);
+ StorageLive(_10);
+ _10 = _1;
+ _7 = Add(move _10, const 1_i32);
+ StorageDead(_10);
+ goto -> bb6;
}
bb6: {
- StorageDead(_8); // scope 3 at $DIR/if.rs:+5:42: +5:43
- StorageLive(_11); // scope 4 at $DIR/if.rs:+6:9: +6:10
- StorageLive(_12); // scope 4 at $DIR/if.rs:+6:13: +6:14
-- _12 = _7; // scope 4 at $DIR/if.rs:+6:13: +6:14
-- _11 = Add(move _12, const 1_i32); // scope 4 at $DIR/if.rs:+6:13: +6:18
-+ _12 = const 1_i32; // scope 4 at $DIR/if.rs:+6:13: +6:14
-+ _11 = const 2_i32; // scope 4 at $DIR/if.rs:+6:13: +6:18
- StorageDead(_12); // scope 4 at $DIR/if.rs:+6:17: +6:18
- _0 = const (); // scope 0 at $DIR/if.rs:+0:11: +7:2
- StorageDead(_11); // scope 4 at $DIR/if.rs:+7:1: +7:2
- StorageDead(_7); // scope 3 at $DIR/if.rs:+7:1: +7:2
- StorageDead(_5); // scope 2 at $DIR/if.rs:+7:1: +7:2
- StorageDead(_2); // scope 1 at $DIR/if.rs:+7:1: +7:2
- StorageDead(_1); // scope 0 at $DIR/if.rs:+7:1: +7:2
- return; // scope 0 at $DIR/if.rs:+7:2: +7:2
+ StorageDead(_8);
+ StorageLive(_11);
+ StorageLive(_12);
+- _12 = _7;
+- _11 = Add(move _12, const 1_i32);
++ _12 = const 1_i32;
++ _11 = const 2_i32;
+ StorageDead(_12);
+ _0 = const ();
+ StorageDead(_11);
+ StorageDead(_7);
+ StorageDead(_5);
+ StorageDead(_2);
+ StorageDead(_1);
+ return;
}
}
diff --git a/tests/mir-opt/dataflow-const-prop/if.rs b/tests/mir-opt/dataflow-const-prop/if.rs
index 34fc35790..72aabbccf 100644
--- a/tests/mir-opt/dataflow-const-prop/if.rs
+++ b/tests/mir-opt/dataflow-const-prop/if.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// unit-test: DataflowConstProp
// EMIT_MIR if.main.DataflowConstProp.diff
diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff
deleted file mode 100644
index 1edcc28e6..000000000
--- a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff
+++ /dev/null
@@ -1,39 +0,0 @@
-- // MIR for `main` before DataflowConstProp
-+ // MIR for `main` after DataflowConstProp
-
- fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/inherit_overflow.rs:+0:11: +0:11
- let mut _1: u8; // in scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47
- let mut _2: u8; // in scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47
- let mut _3: u8; // in scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47
- scope 1 {
- }
- scope 2 (inlined <u8 as Add>::add) { // at $DIR/inherit_overflow.rs:9:13: 9:47
- debug self => _2; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL
- debug other => _3; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL
- let mut _4: (u8, bool); // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL
- }
-
- bb0: {
- StorageLive(_1); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47
- StorageLive(_2); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47
- _2 = const u8::MAX; // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47
- StorageLive(_3); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47
- _3 = const 1_u8; // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47
-- _4 = CheckedAdd(_2, _3); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL
-- assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> bb1; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL
-+ _4 = CheckedAdd(const u8::MAX, const 1_u8); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL
-+ assert(!const true, "attempt to compute `{} + {}`, which would overflow", const u8::MAX, const 1_u8) -> bb1; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL
- }
-
- bb1: {
-- _1 = move (_4.0: u8); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL
-+ _1 = const 0_u8; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL
- StorageDead(_3); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47
- StorageDead(_2); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47
- StorageDead(_1); // scope 0 at $DIR/inherit_overflow.rs:+3:47: +3:48
- _0 = const (); // scope 0 at $DIR/inherit_overflow.rs:+0:11: +4:2
- return; // scope 0 at $DIR/inherit_overflow.rs:+4:2: +4:2
- }
- }
-
diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff
new file mode 100644
index 000000000..09fc48043
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff
@@ -0,0 +1,45 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let mut _1: u8;
+ let mut _2: u8;
+ let mut _3: u8;
+ scope 1 {
+ }
+ scope 2 (inlined #[track_caller] <u8 as Add>::add) {
+ debug self => _2;
+ debug other => _3;
+ let mut _4: (u8, bool);
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ _2 = const u8::MAX;
+ StorageLive(_3);
+ _3 = const 1_u8;
+ StorageLive(_4);
+- _4 = CheckedAdd(_2, _3);
+- assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind unreachable];
++ _4 = const (0_u8, true);
++ assert(!const true, "attempt to compute `{} + {}`, which would overflow", const u8::MAX, const 1_u8) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+- _1 = move (_4.0: u8);
++ _1 = const 0_u8;
+ StorageDead(_4);
+ StorageDead(_3);
+ StorageDead(_2);
+ StorageDead(_1);
+ _0 = const ();
+ return;
+ }
++ }
++
++ ALLOC0 (size: 2, align: 1) {
++ 00 01 │ ..
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff
new file mode 100644
index 000000000..c0b26080f
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff
@@ -0,0 +1,45 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let mut _1: u8;
+ let mut _2: u8;
+ let mut _3: u8;
+ scope 1 {
+ }
+ scope 2 (inlined #[track_caller] <u8 as Add>::add) {
+ debug self => _2;
+ debug other => _3;
+ let mut _4: (u8, bool);
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ _2 = const u8::MAX;
+ StorageLive(_3);
+ _3 = const 1_u8;
+ StorageLive(_4);
+- _4 = CheckedAdd(_2, _3);
+- assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind continue];
++ _4 = const (0_u8, true);
++ assert(!const true, "attempt to compute `{} + {}`, which would overflow", const u8::MAX, const 1_u8) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+- _1 = move (_4.0: u8);
++ _1 = const 0_u8;
+ StorageDead(_4);
+ StorageDead(_3);
+ StorageDead(_2);
+ StorageDead(_1);
+ _0 = const ();
+ return;
+ }
++ }
++
++ ALLOC0 (size: 2, align: 1) {
++ 00 01 │ ..
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.rs b/tests/mir-opt/dataflow-const-prop/inherit_overflow.rs
index 90349d527..664cbcb2c 100644
--- a/tests/mir-opt/dataflow-const-prop/inherit_overflow.rs
+++ b/tests/mir-opt/dataflow-const-prop/inherit_overflow.rs
@@ -1,4 +1,5 @@
-// ignore-wasm32 compiled with panic=abort by default
+// skip-filecheck
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: DataflowConstProp
// compile-flags: -Zmir-enable-passes=+Inline
diff --git a/tests/mir-opt/dataflow-const-prop/issue_81605.f.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/issue_81605.f.DataflowConstProp.diff
index 5a8788497..3f65d3fff 100644
--- a/tests/mir-opt/dataflow-const-prop/issue_81605.f.DataflowConstProp.diff
+++ b/tests/mir-opt/dataflow-const-prop/issue_81605.f.DataflowConstProp.diff
@@ -2,34 +2,34 @@
+ // MIR for `f` after DataflowConstProp
fn f() -> usize {
- let mut _0: usize; // return place in scope 0 at $DIR/issue_81605.rs:+0:11: +0:16
- let mut _1: usize; // in scope 0 at $DIR/issue_81605.rs:+1:9: +1:33
- let mut _2: bool; // in scope 0 at $DIR/issue_81605.rs:+1:12: +1:16
+ let mut _0: usize;
+ let mut _1: usize;
+ let mut _2: bool;
bb0: {
- StorageLive(_1); // scope 0 at $DIR/issue_81605.rs:+1:9: +1:33
- StorageLive(_2); // scope 0 at $DIR/issue_81605.rs:+1:12: +1:16
- _2 = const true; // scope 0 at $DIR/issue_81605.rs:+1:12: +1:16
-- switchInt(move _2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/issue_81605.rs:+1:12: +1:16
-+ switchInt(const true) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/issue_81605.rs:+1:12: +1:16
+ StorageLive(_1);
+ StorageLive(_2);
+ _2 = const true;
+- switchInt(move _2) -> [0: bb2, otherwise: bb1];
++ switchInt(const true) -> [0: bb2, otherwise: bb1];
}
bb1: {
- _1 = const 1_usize; // scope 0 at $DIR/issue_81605.rs:+1:19: +1:20
- goto -> bb3; // scope 0 at $DIR/issue_81605.rs:+1:9: +1:33
+ _1 = const 1_usize;
+ goto -> bb3;
}
bb2: {
- _1 = const 2_usize; // scope 0 at $DIR/issue_81605.rs:+1:30: +1:31
- goto -> bb3; // scope 0 at $DIR/issue_81605.rs:+1:9: +1:33
+ _1 = const 2_usize;
+ goto -> bb3;
}
bb3: {
- StorageDead(_2); // scope 0 at $DIR/issue_81605.rs:+1:32: +1:33
-- _0 = Add(const 1_usize, move _1); // scope 0 at $DIR/issue_81605.rs:+1:5: +1:33
-+ _0 = const 2_usize; // scope 0 at $DIR/issue_81605.rs:+1:5: +1:33
- StorageDead(_1); // scope 0 at $DIR/issue_81605.rs:+1:32: +1:33
- return; // scope 0 at $DIR/issue_81605.rs:+2:2: +2:2
+ StorageDead(_2);
+- _0 = Add(const 1_usize, move _1);
++ _0 = const 2_usize;
+ StorageDead(_1);
+ return;
}
}
diff --git a/tests/mir-opt/dataflow-const-prop/issue_81605.rs b/tests/mir-opt/dataflow-const-prop/issue_81605.rs
index d75e2a28b..7c5eceb8a 100644
--- a/tests/mir-opt/dataflow-const-prop/issue_81605.rs
+++ b/tests/mir-opt/dataflow-const-prop/issue_81605.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// unit-test: DataflowConstProp
// EMIT_MIR issue_81605.f.DataflowConstProp.diff
diff --git a/tests/mir-opt/dataflow-const-prop/large_array_index.main.DataflowConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/large_array_index.main.DataflowConstProp.32bit.panic-abort.diff
new file mode 100644
index 000000000..6c612d467
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/large_array_index.main.DataflowConstProp.32bit.panic-abort.diff
@@ -0,0 +1,39 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: u8;
+ let mut _2: [u8; 5000];
+ let _3: usize;
+ let mut _4: usize;
+ let mut _5: bool;
+ scope 1 {
+ debug x => _1;
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ _2 = [const 0_u8; 5000];
+ StorageLive(_3);
+ _3 = const 2_usize;
+- _4 = Len(_2);
+- _5 = Lt(_3, _4);
+- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable];
++ _4 = const 5000_usize;
++ _5 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+- _1 = _2[_3];
++ _1 = _2[2 of 3];
+ StorageDead(_3);
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/large_array_index.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/large_array_index.main.DataflowConstProp.32bit.panic-unwind.diff
new file mode 100644
index 000000000..87024da26
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/large_array_index.main.DataflowConstProp.32bit.panic-unwind.diff
@@ -0,0 +1,39 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: u8;
+ let mut _2: [u8; 5000];
+ let _3: usize;
+ let mut _4: usize;
+ let mut _5: bool;
+ scope 1 {
+ debug x => _1;
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ _2 = [const 0_u8; 5000];
+ StorageLive(_3);
+ _3 = const 2_usize;
+- _4 = Len(_2);
+- _5 = Lt(_3, _4);
+- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue];
++ _4 = const 5000_usize;
++ _5 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+- _1 = _2[_3];
++ _1 = _2[2 of 3];
+ StorageDead(_3);
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/large_array_index.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/large_array_index.main.DataflowConstProp.64bit.panic-abort.diff
new file mode 100644
index 000000000..6c612d467
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/large_array_index.main.DataflowConstProp.64bit.panic-abort.diff
@@ -0,0 +1,39 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: u8;
+ let mut _2: [u8; 5000];
+ let _3: usize;
+ let mut _4: usize;
+ let mut _5: bool;
+ scope 1 {
+ debug x => _1;
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ _2 = [const 0_u8; 5000];
+ StorageLive(_3);
+ _3 = const 2_usize;
+- _4 = Len(_2);
+- _5 = Lt(_3, _4);
+- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable];
++ _4 = const 5000_usize;
++ _5 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+- _1 = _2[_3];
++ _1 = _2[2 of 3];
+ StorageDead(_3);
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/large_array_index.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/large_array_index.main.DataflowConstProp.64bit.panic-unwind.diff
new file mode 100644
index 000000000..87024da26
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/large_array_index.main.DataflowConstProp.64bit.panic-unwind.diff
@@ -0,0 +1,39 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: u8;
+ let mut _2: [u8; 5000];
+ let _3: usize;
+ let mut _4: usize;
+ let mut _5: bool;
+ scope 1 {
+ debug x => _1;
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ _2 = [const 0_u8; 5000];
+ StorageLive(_3);
+ _3 = const 2_usize;
+- _4 = Len(_2);
+- _5 = Lt(_3, _4);
+- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue];
++ _4 = const 5000_usize;
++ _5 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+- _1 = _2[_3];
++ _1 = _2[2 of 3];
+ StorageDead(_3);
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/large_array_index.rs b/tests/mir-opt/dataflow-const-prop/large_array_index.rs
new file mode 100644
index 000000000..d611a54ba
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/large_array_index.rs
@@ -0,0 +1,10 @@
+// skip-filecheck
+// unit-test: DataflowConstProp
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+
+// EMIT_MIR large_array_index.main.DataflowConstProp.diff
+fn main() {
+ // check that we don't propagate this, because it's too large
+ let x: u8 = [0_u8; 5000][2];
+}
diff --git a/tests/mir-opt/dataflow-const-prop/mult_by_zero.rs b/tests/mir-opt/dataflow-const-prop/mult_by_zero.rs
new file mode 100644
index 000000000..16a45c8e9
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/mult_by_zero.rs
@@ -0,0 +1,11 @@
+// skip-filecheck
+// unit-test: DataflowConstProp
+
+// EMIT_MIR mult_by_zero.test.DataflowConstProp.diff
+fn test(x : i32) -> i32 {
+ x * 0
+}
+
+fn main() {
+ test(10);
+}
diff --git a/tests/mir-opt/dataflow-const-prop/mult_by_zero.test.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/mult_by_zero.test.DataflowConstProp.diff
new file mode 100644
index 000000000..91bc10a56
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/mult_by_zero.test.DataflowConstProp.diff
@@ -0,0 +1,18 @@
+- // MIR for `test` before DataflowConstProp
++ // MIR for `test` after DataflowConstProp
+
+ fn test(_1: i32) -> i32 {
+ debug x => _1;
+ let mut _0: i32;
+ let mut _2: i32;
+
+ bb0: {
+ StorageLive(_2);
+ _2 = _1;
+- _0 = Mul(move _2, const 0_i32);
++ _0 = const 0_i32;
+ StorageDead(_2);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/offset_of.concrete.DataflowConstProp.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/offset_of.concrete.DataflowConstProp.panic-abort.diff
new file mode 100644
index 000000000..f8f891750
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/offset_of.concrete.DataflowConstProp.panic-abort.diff
@@ -0,0 +1,76 @@
+- // MIR for `concrete` before DataflowConstProp
++ // MIR for `concrete` after DataflowConstProp
+
+ fn concrete() -> () {
+ let mut _0: ();
+ let _1: usize;
+ let mut _2: usize;
+ let mut _4: usize;
+ let mut _6: usize;
+ let mut _8: usize;
+ scope 1 {
+ debug x => _1;
+ let _3: usize;
+ scope 2 {
+ debug y => _3;
+ let _5: usize;
+ scope 3 {
+ debug z0 => _5;
+ let _7: usize;
+ scope 4 {
+ debug z1 => _7;
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+- _2 = OffsetOf(Alpha, [(0, 0)]);
+- _1 = must_use::<usize>(move _2) -> [return: bb1, unwind unreachable];
++ _2 = const 4_usize;
++ _1 = must_use::<usize>(const 4_usize) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ StorageDead(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+- _4 = OffsetOf(Alpha, [(0, 1)]);
+- _3 = must_use::<usize>(move _4) -> [return: bb2, unwind unreachable];
++ _4 = const 0_usize;
++ _3 = must_use::<usize>(const 0_usize) -> [return: bb2, unwind unreachable];
+ }
+
+ bb2: {
+ StorageDead(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+- _6 = OffsetOf(Alpha, [(0, 2), (0, 0)]);
+- _5 = must_use::<usize>(move _6) -> [return: bb3, unwind unreachable];
++ _6 = const 2_usize;
++ _5 = must_use::<usize>(const 2_usize) -> [return: bb3, unwind unreachable];
+ }
+
+ bb3: {
+ StorageDead(_6);
+ StorageLive(_7);
+ StorageLive(_8);
+- _8 = OffsetOf(Alpha, [(0, 2), (0, 1)]);
+- _7 = must_use::<usize>(move _8) -> [return: bb4, unwind unreachable];
++ _8 = const 3_usize;
++ _7 = must_use::<usize>(const 3_usize) -> [return: bb4, unwind unreachable];
+ }
+
+ bb4: {
+ StorageDead(_8);
+ _0 = const ();
+ StorageDead(_7);
+ StorageDead(_5);
+ StorageDead(_3);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/offset_of.concrete.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/offset_of.concrete.DataflowConstProp.panic-unwind.diff
new file mode 100644
index 000000000..d4f8cb667
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/offset_of.concrete.DataflowConstProp.panic-unwind.diff
@@ -0,0 +1,76 @@
+- // MIR for `concrete` before DataflowConstProp
++ // MIR for `concrete` after DataflowConstProp
+
+ fn concrete() -> () {
+ let mut _0: ();
+ let _1: usize;
+ let mut _2: usize;
+ let mut _4: usize;
+ let mut _6: usize;
+ let mut _8: usize;
+ scope 1 {
+ debug x => _1;
+ let _3: usize;
+ scope 2 {
+ debug y => _3;
+ let _5: usize;
+ scope 3 {
+ debug z0 => _5;
+ let _7: usize;
+ scope 4 {
+ debug z1 => _7;
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+- _2 = OffsetOf(Alpha, [(0, 0)]);
+- _1 = must_use::<usize>(move _2) -> [return: bb1, unwind continue];
++ _2 = const 4_usize;
++ _1 = must_use::<usize>(const 4_usize) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ StorageDead(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+- _4 = OffsetOf(Alpha, [(0, 1)]);
+- _3 = must_use::<usize>(move _4) -> [return: bb2, unwind continue];
++ _4 = const 0_usize;
++ _3 = must_use::<usize>(const 0_usize) -> [return: bb2, unwind continue];
+ }
+
+ bb2: {
+ StorageDead(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+- _6 = OffsetOf(Alpha, [(0, 2), (0, 0)]);
+- _5 = must_use::<usize>(move _6) -> [return: bb3, unwind continue];
++ _6 = const 2_usize;
++ _5 = must_use::<usize>(const 2_usize) -> [return: bb3, unwind continue];
+ }
+
+ bb3: {
+ StorageDead(_6);
+ StorageLive(_7);
+ StorageLive(_8);
+- _8 = OffsetOf(Alpha, [(0, 2), (0, 1)]);
+- _7 = must_use::<usize>(move _8) -> [return: bb4, unwind continue];
++ _8 = const 3_usize;
++ _7 = must_use::<usize>(const 3_usize) -> [return: bb4, unwind continue];
+ }
+
+ bb4: {
+ StorageDead(_8);
+ _0 = const ();
+ StorageDead(_7);
+ StorageDead(_5);
+ StorageDead(_3);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/offset_of.generic.DataflowConstProp.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/offset_of.generic.DataflowConstProp.panic-abort.diff
new file mode 100644
index 000000000..7f166e4fa
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/offset_of.generic.DataflowConstProp.panic-abort.diff
@@ -0,0 +1,72 @@
+- // MIR for `generic` before DataflowConstProp
++ // MIR for `generic` after DataflowConstProp
+
+ fn generic() -> () {
+ let mut _0: ();
+ let _1: usize;
+ let mut _2: usize;
+ let mut _4: usize;
+ let mut _6: usize;
+ let mut _8: usize;
+ scope 1 {
+ debug gx => _1;
+ let _3: usize;
+ scope 2 {
+ debug gy => _3;
+ let _5: usize;
+ scope 3 {
+ debug dx => _5;
+ let _7: usize;
+ scope 4 {
+ debug dy => _7;
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ _2 = OffsetOf(Gamma<T>, [(0, 0)]);
+ _1 = must_use::<usize>(move _2) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ StorageDead(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = OffsetOf(Gamma<T>, [(0, 1)]);
+ _3 = must_use::<usize>(move _4) -> [return: bb2, unwind unreachable];
+ }
+
+ bb2: {
+ StorageDead(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+- _6 = OffsetOf(Delta<T>, [(0, 1)]);
+- _5 = must_use::<usize>(move _6) -> [return: bb3, unwind unreachable];
++ _6 = const 0_usize;
++ _5 = must_use::<usize>(const 0_usize) -> [return: bb3, unwind unreachable];
+ }
+
+ bb3: {
+ StorageDead(_6);
+ StorageLive(_7);
+ StorageLive(_8);
+- _8 = OffsetOf(Delta<T>, [(0, 2)]);
+- _7 = must_use::<usize>(move _8) -> [return: bb4, unwind unreachable];
++ _8 = const 2_usize;
++ _7 = must_use::<usize>(const 2_usize) -> [return: bb4, unwind unreachable];
+ }
+
+ bb4: {
+ StorageDead(_8);
+ _0 = const ();
+ StorageDead(_7);
+ StorageDead(_5);
+ StorageDead(_3);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/offset_of.generic.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/offset_of.generic.DataflowConstProp.panic-unwind.diff
new file mode 100644
index 000000000..38ad6f798
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/offset_of.generic.DataflowConstProp.panic-unwind.diff
@@ -0,0 +1,72 @@
+- // MIR for `generic` before DataflowConstProp
++ // MIR for `generic` after DataflowConstProp
+
+ fn generic() -> () {
+ let mut _0: ();
+ let _1: usize;
+ let mut _2: usize;
+ let mut _4: usize;
+ let mut _6: usize;
+ let mut _8: usize;
+ scope 1 {
+ debug gx => _1;
+ let _3: usize;
+ scope 2 {
+ debug gy => _3;
+ let _5: usize;
+ scope 3 {
+ debug dx => _5;
+ let _7: usize;
+ scope 4 {
+ debug dy => _7;
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ _2 = OffsetOf(Gamma<T>, [(0, 0)]);
+ _1 = must_use::<usize>(move _2) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ StorageDead(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = OffsetOf(Gamma<T>, [(0, 1)]);
+ _3 = must_use::<usize>(move _4) -> [return: bb2, unwind continue];
+ }
+
+ bb2: {
+ StorageDead(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+- _6 = OffsetOf(Delta<T>, [(0, 1)]);
+- _5 = must_use::<usize>(move _6) -> [return: bb3, unwind continue];
++ _6 = const 0_usize;
++ _5 = must_use::<usize>(const 0_usize) -> [return: bb3, unwind continue];
+ }
+
+ bb3: {
+ StorageDead(_6);
+ StorageLive(_7);
+ StorageLive(_8);
+- _8 = OffsetOf(Delta<T>, [(0, 2)]);
+- _7 = must_use::<usize>(move _8) -> [return: bb4, unwind continue];
++ _8 = const 2_usize;
++ _7 = must_use::<usize>(const 2_usize) -> [return: bb4, unwind continue];
+ }
+
+ bb4: {
+ StorageDead(_8);
+ _0 = const ();
+ StorageDead(_7);
+ StorageDead(_5);
+ StorageDead(_3);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/offset_of.rs b/tests/mir-opt/dataflow-const-prop/offset_of.rs
new file mode 100644
index 000000000..e71b3f59e
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/offset_of.rs
@@ -0,0 +1,50 @@
+// skip-filecheck
+// unit-test: DataflowConstProp
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+
+#![feature(offset_of)]
+
+use std::marker::PhantomData;
+use std::mem::offset_of;
+
+struct Alpha {
+ x: u8,
+ y: u16,
+ z: Beta,
+}
+
+struct Beta(u8, u8);
+
+struct Gamma<T> {
+ x: u8,
+ y: u16,
+ _t: T,
+}
+
+#[repr(C)]
+struct Delta<T> {
+ _phantom: PhantomData<T>,
+ x: u8,
+ y: u16,
+}
+
+// EMIT_MIR offset_of.concrete.DataflowConstProp.diff
+fn concrete() {
+ let x = offset_of!(Alpha, x);
+ let y = offset_of!(Alpha, y);
+ let z0 = offset_of!(Alpha, z.0);
+ let z1 = offset_of!(Alpha, z.1);
+}
+
+// EMIT_MIR offset_of.generic.DataflowConstProp.diff
+fn generic<T>() {
+ let gx = offset_of!(Gamma<T>, x);
+ let gy = offset_of!(Gamma<T>, y);
+ let dx = offset_of!(Delta<T>, x);
+ let dy = offset_of!(Delta<T>, y);
+}
+
+fn main() {
+ concrete();
+ generic::<()>();
+}
diff --git a/tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff
deleted file mode 100644
index 70ef17afd..000000000
--- a/tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff
+++ /dev/null
@@ -1,55 +0,0 @@
-- // MIR for `main` before DataflowConstProp
-+ // MIR for `main` after DataflowConstProp
-
- fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/ref_without_sb.rs:+0:11: +0:11
- let mut _1: i32; // in scope 0 at $DIR/ref_without_sb.rs:+1:9: +1:14
- let _2: (); // in scope 0 at $DIR/ref_without_sb.rs:+2:5: +2:15
- let mut _3: &i32; // in scope 0 at $DIR/ref_without_sb.rs:+2:12: +2:14
- let _4: &i32; // in scope 0 at $DIR/ref_without_sb.rs:+2:12: +2:14
- let _5: (); // in scope 0 at $DIR/ref_without_sb.rs:+4:5: +4:20
- scope 1 {
- debug a => _1; // in scope 1 at $DIR/ref_without_sb.rs:+1:9: +1:14
- let _6: i32; // in scope 1 at $DIR/ref_without_sb.rs:+6:9: +6:10
- scope 2 {
- debug b => _6; // in scope 2 at $DIR/ref_without_sb.rs:+6:9: +6:10
- }
- }
-
- bb0: {
- StorageLive(_1); // scope 0 at $DIR/ref_without_sb.rs:+1:9: +1:14
- _1 = const 0_i32; // scope 0 at $DIR/ref_without_sb.rs:+1:17: +1:18
- StorageLive(_2); // scope 1 at $DIR/ref_without_sb.rs:+2:5: +2:15
- StorageLive(_3); // scope 1 at $DIR/ref_without_sb.rs:+2:12: +2:14
- StorageLive(_4); // scope 1 at $DIR/ref_without_sb.rs:+2:12: +2:14
- _4 = &_1; // scope 1 at $DIR/ref_without_sb.rs:+2:12: +2:14
- _3 = &(*_4); // scope 1 at $DIR/ref_without_sb.rs:+2:12: +2:14
- _2 = escape::<i32>(move _3) -> bb1; // scope 1 at $DIR/ref_without_sb.rs:+2:5: +2:15
- // mir::Constant
- // + span: $DIR/ref_without_sb.rs:13:5: 13:11
- // + literal: Const { ty: for<'a> fn(&'a i32) {escape::<i32>}, val: Value(<ZST>) }
- }
-
- bb1: {
- StorageDead(_3); // scope 1 at $DIR/ref_without_sb.rs:+2:14: +2:15
- StorageDead(_4); // scope 1 at $DIR/ref_without_sb.rs:+2:15: +2:16
- StorageDead(_2); // scope 1 at $DIR/ref_without_sb.rs:+2:15: +2:16
- _1 = const 1_i32; // scope 1 at $DIR/ref_without_sb.rs:+3:5: +3:10
- StorageLive(_5); // scope 1 at $DIR/ref_without_sb.rs:+4:5: +4:20
- _5 = some_function() -> bb2; // scope 1 at $DIR/ref_without_sb.rs:+4:5: +4:20
- // mir::Constant
- // + span: $DIR/ref_without_sb.rs:15:5: 15:18
- // + literal: Const { ty: fn() {some_function}, val: Value(<ZST>) }
- }
-
- bb2: {
- StorageDead(_5); // scope 1 at $DIR/ref_without_sb.rs:+4:20: +4:21
- StorageLive(_6); // scope 1 at $DIR/ref_without_sb.rs:+6:9: +6:10
- _6 = _1; // scope 1 at $DIR/ref_without_sb.rs:+6:13: +6:14
- _0 = const (); // scope 0 at $DIR/ref_without_sb.rs:+0:11: +7:2
- StorageDead(_6); // scope 1 at $DIR/ref_without_sb.rs:+7:1: +7:2
- StorageDead(_1); // scope 0 at $DIR/ref_without_sb.rs:+7:1: +7:2
- return; // scope 0 at $DIR/ref_without_sb.rs:+7:2: +7:2
- }
- }
-
diff --git a/tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.panic-abort.diff
new file mode 100644
index 000000000..fbbfd61bb
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.panic-abort.diff
@@ -0,0 +1,49 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let mut _1: i32;
+ let _2: ();
+ let mut _3: &i32;
+ let _4: &i32;
+ let _5: ();
+ scope 1 {
+ debug a => _1;
+ let _6: i32;
+ scope 2 {
+ debug b => _6;
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = const 0_i32;
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = &_1;
+ _3 = &(*_4);
+ _2 = escape::<i32>(move _3) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ StorageDead(_3);
+ StorageDead(_4);
+ StorageDead(_2);
+ _1 = const 1_i32;
+ StorageLive(_5);
+ _5 = some_function() -> [return: bb2, unwind unreachable];
+ }
+
+ bb2: {
+ StorageDead(_5);
+ StorageLive(_6);
+ _6 = _1;
+ _0 = const ();
+ StorageDead(_6);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.panic-unwind.diff
new file mode 100644
index 000000000..4e1d26acf
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.panic-unwind.diff
@@ -0,0 +1,49 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let mut _1: i32;
+ let _2: ();
+ let mut _3: &i32;
+ let _4: &i32;
+ let _5: ();
+ scope 1 {
+ debug a => _1;
+ let _6: i32;
+ scope 2 {
+ debug b => _6;
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = const 0_i32;
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = &_1;
+ _3 = &(*_4);
+ _2 = escape::<i32>(move _3) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ StorageDead(_3);
+ StorageDead(_4);
+ StorageDead(_2);
+ _1 = const 1_i32;
+ StorageLive(_5);
+ _5 = some_function() -> [return: bb2, unwind continue];
+ }
+
+ bb2: {
+ StorageDead(_5);
+ StorageLive(_6);
+ _6 = _1;
+ _0 = const ();
+ StorageDead(_6);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/ref_without_sb.rs b/tests/mir-opt/dataflow-const-prop/ref_without_sb.rs
index f53de3cf2..2851c0590 100644
--- a/tests/mir-opt/dataflow-const-prop/ref_without_sb.rs
+++ b/tests/mir-opt/dataflow-const-prop/ref_without_sb.rs
@@ -1,4 +1,5 @@
-// ignore-wasm32 compiled with panic=abort by default
+// skip-filecheck
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: DataflowConstProp
#[inline(never)]
diff --git a/tests/mir-opt/dataflow-const-prop/repeat.main.DataflowConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/repeat.main.DataflowConstProp.32bit.panic-abort.diff
new file mode 100644
index 000000000..a18ef6c9d
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/repeat.main.DataflowConstProp.32bit.panic-abort.diff
@@ -0,0 +1,43 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: u32;
+ let mut _2: u32;
+ let mut _3: [u32; 8];
+ let _4: usize;
+ let mut _5: usize;
+ let mut _6: bool;
+ scope 1 {
+ debug x => _1;
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ _3 = [const 42_u32; 8];
+ StorageLive(_4);
+ _4 = const 2_usize;
+- _5 = Len(_3);
+- _6 = Lt(_4, _5);
+- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind unreachable];
++ _5 = const 8_usize;
++ _6 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+- _2 = _3[_4];
++ _2 = _3[2 of 3];
+ _1 = Add(move _2, const 0_u32);
+ StorageDead(_2);
+ StorageDead(_4);
+ StorageDead(_3);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/repeat.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/repeat.main.DataflowConstProp.32bit.panic-unwind.diff
new file mode 100644
index 000000000..3356ef98b
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/repeat.main.DataflowConstProp.32bit.panic-unwind.diff
@@ -0,0 +1,43 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: u32;
+ let mut _2: u32;
+ let mut _3: [u32; 8];
+ let _4: usize;
+ let mut _5: usize;
+ let mut _6: bool;
+ scope 1 {
+ debug x => _1;
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ _3 = [const 42_u32; 8];
+ StorageLive(_4);
+ _4 = const 2_usize;
+- _5 = Len(_3);
+- _6 = Lt(_4, _5);
+- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue];
++ _5 = const 8_usize;
++ _6 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+- _2 = _3[_4];
++ _2 = _3[2 of 3];
+ _1 = Add(move _2, const 0_u32);
+ StorageDead(_2);
+ StorageDead(_4);
+ StorageDead(_3);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/repeat.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/repeat.main.DataflowConstProp.64bit.panic-abort.diff
new file mode 100644
index 000000000..a18ef6c9d
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/repeat.main.DataflowConstProp.64bit.panic-abort.diff
@@ -0,0 +1,43 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: u32;
+ let mut _2: u32;
+ let mut _3: [u32; 8];
+ let _4: usize;
+ let mut _5: usize;
+ let mut _6: bool;
+ scope 1 {
+ debug x => _1;
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ _3 = [const 42_u32; 8];
+ StorageLive(_4);
+ _4 = const 2_usize;
+- _5 = Len(_3);
+- _6 = Lt(_4, _5);
+- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind unreachable];
++ _5 = const 8_usize;
++ _6 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+- _2 = _3[_4];
++ _2 = _3[2 of 3];
+ _1 = Add(move _2, const 0_u32);
+ StorageDead(_2);
+ StorageDead(_4);
+ StorageDead(_3);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/repeat.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/repeat.main.DataflowConstProp.64bit.panic-unwind.diff
new file mode 100644
index 000000000..3356ef98b
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/repeat.main.DataflowConstProp.64bit.panic-unwind.diff
@@ -0,0 +1,43 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: u32;
+ let mut _2: u32;
+ let mut _3: [u32; 8];
+ let _4: usize;
+ let mut _5: usize;
+ let mut _6: bool;
+ scope 1 {
+ debug x => _1;
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ _3 = [const 42_u32; 8];
+ StorageLive(_4);
+ _4 = const 2_usize;
+- _5 = Len(_3);
+- _6 = Lt(_4, _5);
+- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue];
++ _5 = const 8_usize;
++ _6 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+- _2 = _3[_4];
++ _2 = _3[2 of 3];
+ _1 = Add(move _2, const 0_u32);
+ StorageDead(_2);
+ StorageDead(_4);
+ StorageDead(_3);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/repeat.rs b/tests/mir-opt/dataflow-const-prop/repeat.rs
new file mode 100644
index 000000000..b82448194
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/repeat.rs
@@ -0,0 +1,9 @@
+// skip-filecheck
+// unit-test: DataflowConstProp
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+
+// EMIT_MIR repeat.main.DataflowConstProp.diff
+fn main() {
+ let x: u32 = [42; 8][2] + 0;
+}
diff --git a/tests/mir-opt/dataflow-const-prop/repr_transparent.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/repr_transparent.main.DataflowConstProp.diff
index 8f045eedf..98bd40ab2 100644
--- a/tests/mir-opt/dataflow-const-prop/repr_transparent.main.DataflowConstProp.diff
+++ b/tests/mir-opt/dataflow-const-prop/repr_transparent.main.DataflowConstProp.diff
@@ -2,41 +2,50 @@
+ // MIR for `main` after DataflowConstProp
fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/repr_transparent.rs:+0:11: +0:11
- let _1: I32; // in scope 0 at $DIR/repr_transparent.rs:+1:9: +1:10
- let mut _3: i32; // in scope 0 at $DIR/repr_transparent.rs:+2:17: +2:26
- let mut _4: i32; // in scope 0 at $DIR/repr_transparent.rs:+2:17: +2:20
- let mut _5: i32; // in scope 0 at $DIR/repr_transparent.rs:+2:23: +2:26
+ let mut _0: ();
+ let _1: I32;
+ let mut _3: i32;
+ let mut _4: i32;
+ let mut _5: i32;
scope 1 {
- debug x => _1; // in scope 1 at $DIR/repr_transparent.rs:+1:9: +1:10
- let _2: I32; // in scope 1 at $DIR/repr_transparent.rs:+2:9: +2:10
+ debug x => _1;
+ let _2: I32;
scope 2 {
- debug y => _2; // in scope 2 at $DIR/repr_transparent.rs:+2:9: +2:10
+ debug y => _2;
}
}
bb0: {
- StorageLive(_1); // scope 0 at $DIR/repr_transparent.rs:+1:9: +1:10
- _1 = I32(const 0_i32); // scope 0 at $DIR/repr_transparent.rs:+1:13: +1:19
- StorageLive(_2); // scope 1 at $DIR/repr_transparent.rs:+2:9: +2:10
- StorageLive(_3); // scope 1 at $DIR/repr_transparent.rs:+2:17: +2:26
- StorageLive(_4); // scope 1 at $DIR/repr_transparent.rs:+2:17: +2:20
-- _4 = (_1.0: i32); // scope 1 at $DIR/repr_transparent.rs:+2:17: +2:20
-+ _4 = const 0_i32; // scope 1 at $DIR/repr_transparent.rs:+2:17: +2:20
- StorageLive(_5); // scope 1 at $DIR/repr_transparent.rs:+2:23: +2:26
-- _5 = (_1.0: i32); // scope 1 at $DIR/repr_transparent.rs:+2:23: +2:26
-- _3 = Add(move _4, move _5); // scope 1 at $DIR/repr_transparent.rs:+2:17: +2:26
-+ _5 = const 0_i32; // scope 1 at $DIR/repr_transparent.rs:+2:23: +2:26
-+ _3 = const 0_i32; // scope 1 at $DIR/repr_transparent.rs:+2:17: +2:26
- StorageDead(_5); // scope 1 at $DIR/repr_transparent.rs:+2:25: +2:26
- StorageDead(_4); // scope 1 at $DIR/repr_transparent.rs:+2:25: +2:26
-- _2 = I32(move _3); // scope 1 at $DIR/repr_transparent.rs:+2:13: +2:27
-+ _2 = I32(const 0_i32); // scope 1 at $DIR/repr_transparent.rs:+2:13: +2:27
- StorageDead(_3); // scope 1 at $DIR/repr_transparent.rs:+2:26: +2:27
- _0 = const (); // scope 0 at $DIR/repr_transparent.rs:+0:11: +3:2
- StorageDead(_2); // scope 1 at $DIR/repr_transparent.rs:+3:1: +3:2
- StorageDead(_1); // scope 0 at $DIR/repr_transparent.rs:+3:1: +3:2
- return; // scope 0 at $DIR/repr_transparent.rs:+3:2: +3:2
+ StorageLive(_1);
+- _1 = I32(const 0_i32);
++ _1 = const I32(0_i32);
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+- _4 = (_1.0: i32);
++ _4 = const 0_i32;
+ StorageLive(_5);
+- _5 = (_1.0: i32);
+- _3 = Add(move _4, move _5);
++ _5 = const 0_i32;
++ _3 = const 0_i32;
+ StorageDead(_5);
+ StorageDead(_4);
+- _2 = I32(move _3);
++ _2 = const I32(0_i32);
+ StorageDead(_3);
+ _0 = const ();
+ StorageDead(_2);
+ StorageDead(_1);
+ return;
}
++ }
++
++ ALLOC0 (size: 4, align: 4) {
++ 00 00 00 00 │ ....
++ }
++
++ ALLOC1 (size: 4, align: 4) {
++ 00 00 00 00 │ ....
}
diff --git a/tests/mir-opt/dataflow-const-prop/repr_transparent.rs b/tests/mir-opt/dataflow-const-prop/repr_transparent.rs
index 4ce0ca4df..8cbed6fbb 100644
--- a/tests/mir-opt/dataflow-const-prop/repr_transparent.rs
+++ b/tests/mir-opt/dataflow-const-prop/repr_transparent.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// unit-test: DataflowConstProp
// The struct has scalar ABI, but is not a scalar type.
diff --git a/tests/mir-opt/dataflow-const-prop/self_assign.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/self_assign.main.DataflowConstProp.diff
index df08eff94..fbdbb3fa3 100644
--- a/tests/mir-opt/dataflow-const-prop/self_assign.main.DataflowConstProp.diff
+++ b/tests/mir-opt/dataflow-const-prop/self_assign.main.DataflowConstProp.diff
@@ -2,45 +2,45 @@
+ // MIR for `main` after DataflowConstProp
fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/self_assign.rs:+0:11: +0:11
- let mut _1: i32; // in scope 0 at $DIR/self_assign.rs:+1:9: +1:14
- let mut _2: i32; // in scope 0 at $DIR/self_assign.rs:+2:9: +2:10
- let mut _3: i32; // in scope 0 at $DIR/self_assign.rs:+3:9: +3:10
- let mut _5: &i32; // in scope 0 at $DIR/self_assign.rs:+6:9: +6:10
- let mut _6: i32; // in scope 0 at $DIR/self_assign.rs:+7:9: +7:11
+ let mut _0: ();
+ let mut _1: i32;
+ let mut _2: i32;
+ let mut _3: i32;
+ let mut _5: &i32;
+ let mut _6: i32;
scope 1 {
- debug a => _1; // in scope 1 at $DIR/self_assign.rs:+1:9: +1:14
- let mut _4: &i32; // in scope 1 at $DIR/self_assign.rs:+5:9: +5:14
+ debug a => _1;
+ let mut _4: &i32;
scope 2 {
- debug b => _4; // in scope 2 at $DIR/self_assign.rs:+5:9: +5:14
+ debug b => _4;
}
}
bb0: {
- StorageLive(_1); // scope 0 at $DIR/self_assign.rs:+1:9: +1:14
- _1 = const 0_i32; // scope 0 at $DIR/self_assign.rs:+1:17: +1:18
- StorageLive(_2); // scope 1 at $DIR/self_assign.rs:+2:9: +2:10
- _2 = _1; // scope 1 at $DIR/self_assign.rs:+2:9: +2:10
- _1 = Add(move _2, const 1_i32); // scope 1 at $DIR/self_assign.rs:+2:5: +2:14
- StorageDead(_2); // scope 1 at $DIR/self_assign.rs:+2:13: +2:14
- StorageLive(_3); // scope 1 at $DIR/self_assign.rs:+3:9: +3:10
- _3 = _1; // scope 1 at $DIR/self_assign.rs:+3:9: +3:10
- _1 = move _3; // scope 1 at $DIR/self_assign.rs:+3:5: +3:10
- StorageDead(_3); // scope 1 at $DIR/self_assign.rs:+3:9: +3:10
- StorageLive(_4); // scope 1 at $DIR/self_assign.rs:+5:9: +5:14
- _4 = &_1; // scope 1 at $DIR/self_assign.rs:+5:17: +5:19
- StorageLive(_5); // scope 2 at $DIR/self_assign.rs:+6:9: +6:10
- _5 = _4; // scope 2 at $DIR/self_assign.rs:+6:9: +6:10
- _4 = move _5; // scope 2 at $DIR/self_assign.rs:+6:5: +6:10
- StorageDead(_5); // scope 2 at $DIR/self_assign.rs:+6:9: +6:10
- StorageLive(_6); // scope 2 at $DIR/self_assign.rs:+7:9: +7:11
- _6 = (*_4); // scope 2 at $DIR/self_assign.rs:+7:9: +7:11
- _1 = move _6; // scope 2 at $DIR/self_assign.rs:+7:5: +7:11
- StorageDead(_6); // scope 2 at $DIR/self_assign.rs:+7:10: +7:11
- _0 = const (); // scope 0 at $DIR/self_assign.rs:+0:11: +8:2
- StorageDead(_4); // scope 1 at $DIR/self_assign.rs:+8:1: +8:2
- StorageDead(_1); // scope 0 at $DIR/self_assign.rs:+8:1: +8:2
- return; // scope 0 at $DIR/self_assign.rs:+8:2: +8:2
+ StorageLive(_1);
+ _1 = const 0_i32;
+ StorageLive(_2);
+ _2 = _1;
+ _1 = Add(move _2, const 1_i32);
+ StorageDead(_2);
+ StorageLive(_3);
+ _3 = _1;
+ _1 = move _3;
+ StorageDead(_3);
+ StorageLive(_4);
+ _4 = &_1;
+ StorageLive(_5);
+ _5 = _4;
+ _4 = move _5;
+ StorageDead(_5);
+ StorageLive(_6);
+ _6 = (*_4);
+ _1 = move _6;
+ StorageDead(_6);
+ _0 = const ();
+ StorageDead(_4);
+ StorageDead(_1);
+ return;
}
}
diff --git a/tests/mir-opt/dataflow-const-prop/self_assign.rs b/tests/mir-opt/dataflow-const-prop/self_assign.rs
index 8de2195f9..c5866c4a9 100644
--- a/tests/mir-opt/dataflow-const-prop/self_assign.rs
+++ b/tests/mir-opt/dataflow-const-prop/self_assign.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// unit-test: DataflowConstProp
// EMIT_MIR self_assign.main.DataflowConstProp.diff
diff --git a/tests/mir-opt/dataflow-const-prop/self_assign_add.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/self_assign_add.main.DataflowConstProp.diff
index c09e4061e..e2468a964 100644
--- a/tests/mir-opt/dataflow-const-prop/self_assign_add.main.DataflowConstProp.diff
+++ b/tests/mir-opt/dataflow-const-prop/self_assign_add.main.DataflowConstProp.diff
@@ -2,22 +2,22 @@
+ // MIR for `main` after DataflowConstProp
fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/self_assign_add.rs:+0:11: +0:11
- let mut _1: i32; // in scope 0 at $DIR/self_assign_add.rs:+1:9: +1:14
+ let mut _0: ();
+ let mut _1: i32;
scope 1 {
- debug a => _1; // in scope 1 at $DIR/self_assign_add.rs:+1:9: +1:14
+ debug a => _1;
}
bb0: {
- StorageLive(_1); // scope 0 at $DIR/self_assign_add.rs:+1:9: +1:14
- _1 = const 0_i32; // scope 0 at $DIR/self_assign_add.rs:+1:17: +1:18
-- _1 = Add(_1, const 1_i32); // scope 1 at $DIR/self_assign_add.rs:+2:5: +2:11
-- _1 = Add(_1, const 1_i32); // scope 1 at $DIR/self_assign_add.rs:+3:5: +3:11
-+ _1 = const 1_i32; // scope 1 at $DIR/self_assign_add.rs:+2:5: +2:11
-+ _1 = const 2_i32; // scope 1 at $DIR/self_assign_add.rs:+3:5: +3:11
- _0 = const (); // scope 0 at $DIR/self_assign_add.rs:+0:11: +4:2
- StorageDead(_1); // scope 0 at $DIR/self_assign_add.rs:+4:1: +4:2
- return; // scope 0 at $DIR/self_assign_add.rs:+4:2: +4:2
+ StorageLive(_1);
+ _1 = const 0_i32;
+- _1 = Add(_1, const 1_i32);
+- _1 = Add(_1, const 1_i32);
++ _1 = const 1_i32;
++ _1 = const 2_i32;
+ _0 = const ();
+ StorageDead(_1);
+ return;
}
}
diff --git a/tests/mir-opt/dataflow-const-prop/self_assign_add.rs b/tests/mir-opt/dataflow-const-prop/self_assign_add.rs
index e32827624..cfe1458e4 100644
--- a/tests/mir-opt/dataflow-const-prop/self_assign_add.rs
+++ b/tests/mir-opt/dataflow-const-prop/self_assign_add.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// unit-test: DataflowConstProp
// EMIT_MIR self_assign_add.main.DataflowConstProp.diff
diff --git a/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.diff
deleted file mode 100644
index 6ca569f3d..000000000
--- a/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.diff
+++ /dev/null
@@ -1,54 +0,0 @@
-- // MIR for `main` before DataflowConstProp
-+ // MIR for `main` after DataflowConstProp
-
- fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/sibling_ptr.rs:+0:11: +0:11
- let mut _1: (u8, u8); // in scope 0 at $DIR/sibling_ptr.rs:+1:9: +1:14
- let _2: (); // in scope 0 at $DIR/sibling_ptr.rs:+2:5: +5:6
- let mut _4: *mut u8; // in scope 0 at $DIR/sibling_ptr.rs:+4:10: +4:18
- let mut _5: *mut u8; // in scope 0 at $DIR/sibling_ptr.rs:+4:10: +4:11
- scope 1 {
- debug x => _1; // in scope 1 at $DIR/sibling_ptr.rs:+1:9: +1:14
- let _6: u8; // in scope 1 at $DIR/sibling_ptr.rs:+6:9: +6:11
- scope 2 {
- let _3: *mut u8; // in scope 2 at $DIR/sibling_ptr.rs:+3:13: +3:14
- scope 3 {
- debug p => _3; // in scope 3 at $DIR/sibling_ptr.rs:+3:13: +3:14
- }
- }
- scope 4 {
- debug x1 => _6; // in scope 4 at $DIR/sibling_ptr.rs:+6:9: +6:11
- }
- }
-
- bb0: {
- StorageLive(_1); // scope 0 at $DIR/sibling_ptr.rs:+1:9: +1:14
- _1 = (const 0_u8, const 0_u8); // scope 0 at $DIR/sibling_ptr.rs:+1:27: +1:33
- StorageLive(_2); // scope 1 at $DIR/sibling_ptr.rs:+2:5: +5:6
- StorageLive(_3); // scope 2 at $DIR/sibling_ptr.rs:+3:13: +3:14
- _3 = &raw mut (_1.0: u8); // scope 2 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- StorageLive(_4); // scope 3 at $DIR/sibling_ptr.rs:+4:10: +4:18
- StorageLive(_5); // scope 3 at $DIR/sibling_ptr.rs:+4:10: +4:11
- _5 = _3; // scope 3 at $DIR/sibling_ptr.rs:+4:10: +4:11
- _4 = ptr::mut_ptr::<impl *mut u8>::add(move _5, const 1_usize) -> bb1; // scope 3 at $DIR/sibling_ptr.rs:+4:10: +4:18
- // mir::Constant
- // + span: $DIR/sibling_ptr.rs:16:12: 16:15
- // + literal: Const { ty: unsafe fn(*mut u8, usize) -> *mut u8 {ptr::mut_ptr::<impl *mut u8>::add}, val: Value(<ZST>) }
- }
-
- bb1: {
- StorageDead(_5); // scope 3 at $DIR/sibling_ptr.rs:+4:17: +4:18
- (*_4) = const 1_u8; // scope 3 at $DIR/sibling_ptr.rs:+4:9: +4:22
- StorageDead(_4); // scope 3 at $DIR/sibling_ptr.rs:+4:22: +4:23
- _2 = const (); // scope 2 at $DIR/sibling_ptr.rs:+2:5: +5:6
- StorageDead(_3); // scope 2 at $DIR/sibling_ptr.rs:+5:5: +5:6
- StorageDead(_2); // scope 1 at $DIR/sibling_ptr.rs:+5:5: +5:6
- StorageLive(_6); // scope 1 at $DIR/sibling_ptr.rs:+6:9: +6:11
- _6 = (_1.1: u8); // scope 1 at $DIR/sibling_ptr.rs:+6:14: +6:17
- _0 = const (); // scope 0 at $DIR/sibling_ptr.rs:+0:11: +7:2
- StorageDead(_6); // scope 1 at $DIR/sibling_ptr.rs:+7:1: +7:2
- StorageDead(_1); // scope 0 at $DIR/sibling_ptr.rs:+7:1: +7:2
- return; // scope 0 at $DIR/sibling_ptr.rs:+7:2: +7:2
- }
- }
-
diff --git a/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-abort.diff
new file mode 100644
index 000000000..9b0093c45
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-abort.diff
@@ -0,0 +1,51 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let mut _1: (u8, u8);
+ let _2: ();
+ let mut _4: *mut u8;
+ let mut _5: *mut u8;
+ scope 1 {
+ debug x => _1;
+ let _6: u8;
+ scope 2 {
+ let _3: *mut u8;
+ scope 3 {
+ debug p => _3;
+ }
+ }
+ scope 4 {
+ debug x1 => _6;
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = (const 0_u8, const 0_u8);
+ StorageLive(_2);
+ StorageLive(_3);
+ _3 = &raw mut (_1.0: u8);
+ StorageLive(_4);
+ StorageLive(_5);
+ _5 = _3;
+ _4 = std::ptr::mut_ptr::<impl *mut u8>::add(move _5, const 1_usize) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ StorageDead(_5);
+ (*_4) = const 1_u8;
+ StorageDead(_4);
+ _2 = const ();
+ StorageDead(_3);
+ StorageDead(_2);
+ StorageLive(_6);
+ _6 = (_1.1: u8);
+ _0 = const ();
+ StorageDead(_6);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-unwind.diff
new file mode 100644
index 000000000..635a21425
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-unwind.diff
@@ -0,0 +1,51 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let mut _1: (u8, u8);
+ let _2: ();
+ let mut _4: *mut u8;
+ let mut _5: *mut u8;
+ scope 1 {
+ debug x => _1;
+ let _6: u8;
+ scope 2 {
+ let _3: *mut u8;
+ scope 3 {
+ debug p => _3;
+ }
+ }
+ scope 4 {
+ debug x1 => _6;
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = (const 0_u8, const 0_u8);
+ StorageLive(_2);
+ StorageLive(_3);
+ _3 = &raw mut (_1.0: u8);
+ StorageLive(_4);
+ StorageLive(_5);
+ _5 = _3;
+ _4 = std::ptr::mut_ptr::<impl *mut u8>::add(move _5, const 1_usize) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ StorageDead(_5);
+ (*_4) = const 1_u8;
+ StorageDead(_4);
+ _2 = const ();
+ StorageDead(_3);
+ StorageDead(_2);
+ StorageLive(_6);
+ _6 = (_1.1: u8);
+ _0 = const ();
+ StorageDead(_6);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs b/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs
index 81fc3c2f4..68aff5286 100644
--- a/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs
+++ b/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs
@@ -1,4 +1,5 @@
-// ignore-wasm32 compiled with panic=abort by default
+// skip-filecheck
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// This attempts to modify `x.1` via a pointer derived from `addr_of_mut!(x.0)`.
// According to Miri, that is UB. However, T-opsem has not finalized that
// decision and as such we cannot rely on it in optimizations. Consequently,
diff --git a/tests/mir-opt/dataflow-const-prop/slice_len.main.DataflowConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/slice_len.main.DataflowConstProp.32bit.panic-abort.diff
new file mode 100644
index 000000000..e99b413f7
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/slice_len.main.DataflowConstProp.32bit.panic-abort.diff
@@ -0,0 +1,77 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: u32;
+ let mut _2: &[u32];
+ let mut _3: &[u32; 3];
+ let _4: &[u32; 3];
+ let _5: [u32; 3];
+ let _6: usize;
+ let mut _7: usize;
+ let mut _8: bool;
+ let mut _10: &[u32];
+ let _11: usize;
+ let mut _12: usize;
+ let mut _13: bool;
+ let mut _14: &[u32; 3];
+ scope 1 {
+ debug local => _1;
+ let _9: u32;
+ scope 2 {
+ debug constant => _9;
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ _14 = const _;
+ _4 = _14;
+ _3 = _4;
+ _2 = move _3 as &[u32] (PointerCoercion(Unsize));
+ StorageDead(_3);
+ StorageLive(_6);
+ _6 = const 1_usize;
+- _7 = Len((*_2));
+- _8 = Lt(_6, _7);
+- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable];
++ _7 = const 3_usize;
++ _8 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+- _1 = (*_2)[_6];
++ _1 = (*_2)[1 of 2];
+ StorageDead(_6);
+ StorageDead(_4);
+ StorageDead(_2);
+ StorageLive(_9);
+ StorageLive(_10);
+ _10 = const _;
+ StorageLive(_11);
+ _11 = const 1_usize;
+- _12 = Len((*_10));
+- _13 = Lt(_11, _12);
+- assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb2, unwind unreachable];
++ _12 = const 3_usize;
++ _13 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb2, unwind unreachable];
+ }
+
+ bb2: {
+- _9 = (*_10)[_11];
++ _9 = (*_10)[1 of 2];
+ StorageDead(_11);
+ StorageDead(_10);
+ _0 = const ();
+ StorageDead(_9);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/slice_len.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/slice_len.main.DataflowConstProp.32bit.panic-unwind.diff
new file mode 100644
index 000000000..759a793fb
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/slice_len.main.DataflowConstProp.32bit.panic-unwind.diff
@@ -0,0 +1,77 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: u32;
+ let mut _2: &[u32];
+ let mut _3: &[u32; 3];
+ let _4: &[u32; 3];
+ let _5: [u32; 3];
+ let _6: usize;
+ let mut _7: usize;
+ let mut _8: bool;
+ let mut _10: &[u32];
+ let _11: usize;
+ let mut _12: usize;
+ let mut _13: bool;
+ let mut _14: &[u32; 3];
+ scope 1 {
+ debug local => _1;
+ let _9: u32;
+ scope 2 {
+ debug constant => _9;
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ _14 = const _;
+ _4 = _14;
+ _3 = _4;
+ _2 = move _3 as &[u32] (PointerCoercion(Unsize));
+ StorageDead(_3);
+ StorageLive(_6);
+ _6 = const 1_usize;
+- _7 = Len((*_2));
+- _8 = Lt(_6, _7);
+- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue];
++ _7 = const 3_usize;
++ _8 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+- _1 = (*_2)[_6];
++ _1 = (*_2)[1 of 2];
+ StorageDead(_6);
+ StorageDead(_4);
+ StorageDead(_2);
+ StorageLive(_9);
+ StorageLive(_10);
+ _10 = const _;
+ StorageLive(_11);
+ _11 = const 1_usize;
+- _12 = Len((*_10));
+- _13 = Lt(_11, _12);
+- assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb2, unwind continue];
++ _12 = const 3_usize;
++ _13 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb2, unwind continue];
+ }
+
+ bb2: {
+- _9 = (*_10)[_11];
++ _9 = (*_10)[1 of 2];
+ StorageDead(_11);
+ StorageDead(_10);
+ _0 = const ();
+ StorageDead(_9);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/slice_len.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/slice_len.main.DataflowConstProp.64bit.panic-abort.diff
new file mode 100644
index 000000000..e99b413f7
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/slice_len.main.DataflowConstProp.64bit.panic-abort.diff
@@ -0,0 +1,77 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: u32;
+ let mut _2: &[u32];
+ let mut _3: &[u32; 3];
+ let _4: &[u32; 3];
+ let _5: [u32; 3];
+ let _6: usize;
+ let mut _7: usize;
+ let mut _8: bool;
+ let mut _10: &[u32];
+ let _11: usize;
+ let mut _12: usize;
+ let mut _13: bool;
+ let mut _14: &[u32; 3];
+ scope 1 {
+ debug local => _1;
+ let _9: u32;
+ scope 2 {
+ debug constant => _9;
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ _14 = const _;
+ _4 = _14;
+ _3 = _4;
+ _2 = move _3 as &[u32] (PointerCoercion(Unsize));
+ StorageDead(_3);
+ StorageLive(_6);
+ _6 = const 1_usize;
+- _7 = Len((*_2));
+- _8 = Lt(_6, _7);
+- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable];
++ _7 = const 3_usize;
++ _8 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind unreachable];
+ }
+
+ bb1: {
+- _1 = (*_2)[_6];
++ _1 = (*_2)[1 of 2];
+ StorageDead(_6);
+ StorageDead(_4);
+ StorageDead(_2);
+ StorageLive(_9);
+ StorageLive(_10);
+ _10 = const _;
+ StorageLive(_11);
+ _11 = const 1_usize;
+- _12 = Len((*_10));
+- _13 = Lt(_11, _12);
+- assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb2, unwind unreachable];
++ _12 = const 3_usize;
++ _13 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb2, unwind unreachable];
+ }
+
+ bb2: {
+- _9 = (*_10)[_11];
++ _9 = (*_10)[1 of 2];
+ StorageDead(_11);
+ StorageDead(_10);
+ _0 = const ();
+ StorageDead(_9);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/slice_len.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/slice_len.main.DataflowConstProp.64bit.panic-unwind.diff
new file mode 100644
index 000000000..759a793fb
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/slice_len.main.DataflowConstProp.64bit.panic-unwind.diff
@@ -0,0 +1,77 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: u32;
+ let mut _2: &[u32];
+ let mut _3: &[u32; 3];
+ let _4: &[u32; 3];
+ let _5: [u32; 3];
+ let _6: usize;
+ let mut _7: usize;
+ let mut _8: bool;
+ let mut _10: &[u32];
+ let _11: usize;
+ let mut _12: usize;
+ let mut _13: bool;
+ let mut _14: &[u32; 3];
+ scope 1 {
+ debug local => _1;
+ let _9: u32;
+ scope 2 {
+ debug constant => _9;
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ _14 = const _;
+ _4 = _14;
+ _3 = _4;
+ _2 = move _3 as &[u32] (PointerCoercion(Unsize));
+ StorageDead(_3);
+ StorageLive(_6);
+ _6 = const 1_usize;
+- _7 = Len((*_2));
+- _8 = Lt(_6, _7);
+- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue];
++ _7 = const 3_usize;
++ _8 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind continue];
+ }
+
+ bb1: {
+- _1 = (*_2)[_6];
++ _1 = (*_2)[1 of 2];
+ StorageDead(_6);
+ StorageDead(_4);
+ StorageDead(_2);
+ StorageLive(_9);
+ StorageLive(_10);
+ _10 = const _;
+ StorageLive(_11);
+ _11 = const 1_usize;
+- _12 = Len((*_10));
+- _13 = Lt(_11, _12);
+- assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb2, unwind continue];
++ _12 = const 3_usize;
++ _13 = const true;
++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb2, unwind continue];
+ }
+
+ bb2: {
+- _9 = (*_10)[_11];
++ _9 = (*_10)[1 of 2];
+ StorageDead(_11);
+ StorageDead(_10);
+ _0 = const ();
+ StorageDead(_9);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/slice_len.rs b/tests/mir-opt/dataflow-const-prop/slice_len.rs
new file mode 100644
index 000000000..86266ef5d
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/slice_len.rs
@@ -0,0 +1,13 @@
+// skip-filecheck
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+// unit-test: DataflowConstProp
+// compile-flags: -Zmir-enable-passes=+InstSimplify
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+
+// EMIT_MIR slice_len.main.DataflowConstProp.diff
+fn main() {
+ let local = (&[1u32, 2, 3] as &[u32])[1];
+
+ const SLICE: &[u32] = &[1, 2, 3];
+ let constant = SLICE[1];
+}
diff --git a/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..0f461f515
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.32bit.diff
@@ -0,0 +1,247 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let mut _1: S;
+ let mut _3: i32;
+ let mut _5: i32;
+ let mut _6: i32;
+ let mut _10: SmallStruct;
+ let mut _14: &&SmallStruct;
+ let mut _16: f32;
+ let mut _17: std::option::Option<S>;
+ let mut _18: &[f32];
+ let mut _22: BigStruct;
+ let mut _26: &&BigStruct;
+ let mut _28: f32;
+ let mut _29: std::option::Option<S>;
+ let mut _30: &[f32];
+ let mut _31: &SmallStruct;
+ let mut _32: &SmallStruct;
+ let mut _33: &SmallStruct;
+ let mut _34: &SmallStruct;
+ let mut _35: &BigStruct;
+ let mut _36: &BigStruct;
+ let mut _37: &BigStruct;
+ let mut _38: &BigStruct;
+ scope 1 {
+ debug s => _1;
+ let _2: i32;
+ scope 2 {
+ debug a => _2;
+ let _4: i32;
+ scope 3 {
+ debug b => _4;
+ let _7: f32;
+ let _8: std::option::Option<S>;
+ let _9: &[f32];
+ scope 4 {
+ debug a => _7;
+ debug b => _8;
+ debug c => _9;
+ let _11: f32;
+ let _12: std::option::Option<S>;
+ let _13: &[f32];
+ scope 5 {
+ debug a => _11;
+ debug b => _12;
+ debug c => _13;
+ let _15: SmallStruct;
+ scope 6 {
+ debug ss => _15;
+ let _19: f32;
+ let _20: std::option::Option<S>;
+ let _21: &[f32];
+ scope 7 {
+ debug a => _19;
+ debug b => _20;
+ debug c => _21;
+ let _23: f32;
+ let _24: std::option::Option<S>;
+ let _25: &[f32];
+ scope 8 {
+ debug a => _23;
+ debug b => _24;
+ debug c => _25;
+ let _27: BigStruct;
+ scope 9 {
+ debug bs => _27;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+- _1 = S(const 1_i32);
++ _1 = const S(1_i32);
+ StorageLive(_2);
+ StorageLive(_3);
+- _3 = (_1.0: i32);
+- _2 = Add(move _3, const 2_i32);
++ _3 = const 1_i32;
++ _2 = const 3_i32;
+ StorageDead(_3);
+ (_1.0: i32) = const 3_i32;
+ StorageLive(_4);
+ StorageLive(_5);
+- _5 = _2;
++ _5 = const 3_i32;
+ StorageLive(_6);
+- _6 = (_1.0: i32);
+- _4 = Add(move _5, move _6);
++ _6 = const 3_i32;
++ _4 = const 6_i32;
+ StorageDead(_6);
+ StorageDead(_5);
+ StorageLive(_10);
+ _10 = const _;
+ StorageLive(_7);
+- _7 = (_10.0: f32);
++ _7 = const 4f32;
+ StorageLive(_8);
+- _8 = (_10.1: std::option::Option<S>);
++ _8 = const Option::<S>::Some(S(1_i32));
+ StorageLive(_9);
+ _9 = (_10.2: &[f32]);
+ StorageDead(_10);
+ StorageLive(_14);
+ _14 = const {ALLOC4: &&SmallStruct};
+ _31 = deref_copy (*_14);
+ StorageLive(_11);
+ _32 = deref_copy (*_14);
+- _11 = ((*_32).0: f32);
++ _11 = const 9f32;
+ StorageLive(_12);
+ _33 = deref_copy (*_14);
+ _12 = ((*_33).1: std::option::Option<S>);
+ StorageLive(_13);
+ _34 = deref_copy (*_14);
+ _13 = ((*_34).2: &[f32]);
+ StorageDead(_14);
+ StorageLive(_15);
+ StorageLive(_16);
+- _16 = _11;
++ _16 = const 9f32;
+ StorageLive(_17);
+ _17 = _12;
+ StorageLive(_18);
+ _18 = _13;
+- _15 = SmallStruct(move _16, move _17, move _18);
++ _15 = SmallStruct(const 9f32, move _17, move _18);
+ StorageDead(_18);
+ StorageDead(_17);
+ StorageDead(_16);
+ StorageLive(_22);
+ _22 = const _;
+ StorageLive(_19);
+- _19 = (_22.0: f32);
++ _19 = const 25f32;
+ StorageLive(_20);
+ _20 = (_22.1: std::option::Option<S>);
+ StorageLive(_21);
+ _21 = (_22.2: &[f32]);
+ StorageDead(_22);
+ StorageLive(_26);
+ _26 = const {ALLOC5: &&BigStruct};
+ _35 = deref_copy (*_26);
+ StorageLive(_23);
+ _36 = deref_copy (*_26);
+- _23 = ((*_36).0: f32);
++ _23 = const 82f32;
+ StorageLive(_24);
+ _37 = deref_copy (*_26);
+- _24 = ((*_37).1: std::option::Option<S>);
++ _24 = const Option::<S>::Some(S(35_i32));
+ StorageLive(_25);
+ _38 = deref_copy (*_26);
+ _25 = ((*_38).2: &[f32]);
+ StorageDead(_26);
+ StorageLive(_27);
+ StorageLive(_28);
+- _28 = _23;
++ _28 = const 82f32;
+ StorageLive(_29);
+- _29 = _24;
++ _29 = const Option::<S>::Some(S(35_i32));
+ StorageLive(_30);
+ _30 = _25;
+- _27 = BigStruct(move _28, move _29, move _30);
++ _27 = BigStruct(const 82f32, const Option::<S>::Some(S(35_i32)), move _30);
+ StorageDead(_30);
+ StorageDead(_29);
+ StorageDead(_28);
+ _0 = const ();
+ StorageDead(_27);
+ StorageDead(_25);
+ StorageDead(_24);
+ StorageDead(_23);
+ StorageDead(_21);
+ StorageDead(_20);
+ StorageDead(_19);
+ StorageDead(_15);
+ StorageDead(_13);
+ StorageDead(_12);
+ StorageDead(_11);
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageDead(_7);
+ StorageDead(_4);
+ StorageDead(_2);
+ StorageDead(_1);
+ return;
+ }
++ }
++
++ ALLOC6 (size: 8, align: 4) {
++ 01 00 00 00 23 00 00 00 │ ....#...
++ }
++
++ ALLOC7 (size: 8, align: 4) {
++ 01 00 00 00 23 00 00 00 │ ....#...
++ }
++
++ ALLOC8 (size: 8, align: 4) {
++ 01 00 00 00 23 00 00 00 │ ....#...
++ }
++
++ ALLOC9 (size: 8, align: 4) {
++ 01 00 00 00 01 00 00 00 │ ........
++ }
++
++ ALLOC10 (size: 4, align: 4) {
++ 01 00 00 00 │ ....
+ }
+
+ ALLOC5 (static: BIG_STAT, size: 4, align: 4) {
+ ╾ALLOC0<imm>╼ │ ╾──╼
+ }
+
+ ALLOC0 (size: 20, align: 4) {
+ 0x00 │ 01 00 00 00 23 00 00 00 ╾ALLOC1<imm>╼ 02 00 00 00 │ ....#...╾──╼....
+ 0x10 │ 00 00 a4 42 │ ...B
+ }
+
+ ALLOC1 (size: 8, align: 4) {
+ 00 00 34 42 00 00 90 42 │ ..4B...B
+ }
+
+ ALLOC4 (static: SMALL_STAT, size: 4, align: 4) {
+ ╾ALLOC2<imm>╼ │ ╾──╼
+ }
+
+ ALLOC2 (size: 20, align: 4) {
+ 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC3<imm>╼ 01 00 00 00 │ ....░░░░╾──╼....
+ 0x10 │ 00 00 10 41 │ ...A
+ }
+
+ ALLOC3 (size: 4, align: 4) {
+ 00 00 50 41 │ ..PA
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.64bit.diff
new file mode 100644
index 000000000..3c40ec8bf
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.64bit.diff
@@ -0,0 +1,247 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let mut _1: S;
+ let mut _3: i32;
+ let mut _5: i32;
+ let mut _6: i32;
+ let mut _10: SmallStruct;
+ let mut _14: &&SmallStruct;
+ let mut _16: f32;
+ let mut _17: std::option::Option<S>;
+ let mut _18: &[f32];
+ let mut _22: BigStruct;
+ let mut _26: &&BigStruct;
+ let mut _28: f32;
+ let mut _29: std::option::Option<S>;
+ let mut _30: &[f32];
+ let mut _31: &SmallStruct;
+ let mut _32: &SmallStruct;
+ let mut _33: &SmallStruct;
+ let mut _34: &SmallStruct;
+ let mut _35: &BigStruct;
+ let mut _36: &BigStruct;
+ let mut _37: &BigStruct;
+ let mut _38: &BigStruct;
+ scope 1 {
+ debug s => _1;
+ let _2: i32;
+ scope 2 {
+ debug a => _2;
+ let _4: i32;
+ scope 3 {
+ debug b => _4;
+ let _7: f32;
+ let _8: std::option::Option<S>;
+ let _9: &[f32];
+ scope 4 {
+ debug a => _7;
+ debug b => _8;
+ debug c => _9;
+ let _11: f32;
+ let _12: std::option::Option<S>;
+ let _13: &[f32];
+ scope 5 {
+ debug a => _11;
+ debug b => _12;
+ debug c => _13;
+ let _15: SmallStruct;
+ scope 6 {
+ debug ss => _15;
+ let _19: f32;
+ let _20: std::option::Option<S>;
+ let _21: &[f32];
+ scope 7 {
+ debug a => _19;
+ debug b => _20;
+ debug c => _21;
+ let _23: f32;
+ let _24: std::option::Option<S>;
+ let _25: &[f32];
+ scope 8 {
+ debug a => _23;
+ debug b => _24;
+ debug c => _25;
+ let _27: BigStruct;
+ scope 9 {
+ debug bs => _27;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+- _1 = S(const 1_i32);
++ _1 = const S(1_i32);
+ StorageLive(_2);
+ StorageLive(_3);
+- _3 = (_1.0: i32);
+- _2 = Add(move _3, const 2_i32);
++ _3 = const 1_i32;
++ _2 = const 3_i32;
+ StorageDead(_3);
+ (_1.0: i32) = const 3_i32;
+ StorageLive(_4);
+ StorageLive(_5);
+- _5 = _2;
++ _5 = const 3_i32;
+ StorageLive(_6);
+- _6 = (_1.0: i32);
+- _4 = Add(move _5, move _6);
++ _6 = const 3_i32;
++ _4 = const 6_i32;
+ StorageDead(_6);
+ StorageDead(_5);
+ StorageLive(_10);
+ _10 = const _;
+ StorageLive(_7);
+- _7 = (_10.0: f32);
++ _7 = const 4f32;
+ StorageLive(_8);
+- _8 = (_10.1: std::option::Option<S>);
++ _8 = const Option::<S>::Some(S(1_i32));
+ StorageLive(_9);
+ _9 = (_10.2: &[f32]);
+ StorageDead(_10);
+ StorageLive(_14);
+ _14 = const {ALLOC4: &&SmallStruct};
+ _31 = deref_copy (*_14);
+ StorageLive(_11);
+ _32 = deref_copy (*_14);
+- _11 = ((*_32).0: f32);
++ _11 = const 9f32;
+ StorageLive(_12);
+ _33 = deref_copy (*_14);
+ _12 = ((*_33).1: std::option::Option<S>);
+ StorageLive(_13);
+ _34 = deref_copy (*_14);
+ _13 = ((*_34).2: &[f32]);
+ StorageDead(_14);
+ StorageLive(_15);
+ StorageLive(_16);
+- _16 = _11;
++ _16 = const 9f32;
+ StorageLive(_17);
+ _17 = _12;
+ StorageLive(_18);
+ _18 = _13;
+- _15 = SmallStruct(move _16, move _17, move _18);
++ _15 = SmallStruct(const 9f32, move _17, move _18);
+ StorageDead(_18);
+ StorageDead(_17);
+ StorageDead(_16);
+ StorageLive(_22);
+ _22 = const _;
+ StorageLive(_19);
+- _19 = (_22.0: f32);
++ _19 = const 25f32;
+ StorageLive(_20);
+ _20 = (_22.1: std::option::Option<S>);
+ StorageLive(_21);
+ _21 = (_22.2: &[f32]);
+ StorageDead(_22);
+ StorageLive(_26);
+ _26 = const {ALLOC5: &&BigStruct};
+ _35 = deref_copy (*_26);
+ StorageLive(_23);
+ _36 = deref_copy (*_26);
+- _23 = ((*_36).0: f32);
++ _23 = const 82f32;
+ StorageLive(_24);
+ _37 = deref_copy (*_26);
+- _24 = ((*_37).1: std::option::Option<S>);
++ _24 = const Option::<S>::Some(S(35_i32));
+ StorageLive(_25);
+ _38 = deref_copy (*_26);
+ _25 = ((*_38).2: &[f32]);
+ StorageDead(_26);
+ StorageLive(_27);
+ StorageLive(_28);
+- _28 = _23;
++ _28 = const 82f32;
+ StorageLive(_29);
+- _29 = _24;
++ _29 = const Option::<S>::Some(S(35_i32));
+ StorageLive(_30);
+ _30 = _25;
+- _27 = BigStruct(move _28, move _29, move _30);
++ _27 = BigStruct(const 82f32, const Option::<S>::Some(S(35_i32)), move _30);
+ StorageDead(_30);
+ StorageDead(_29);
+ StorageDead(_28);
+ _0 = const ();
+ StorageDead(_27);
+ StorageDead(_25);
+ StorageDead(_24);
+ StorageDead(_23);
+ StorageDead(_21);
+ StorageDead(_20);
+ StorageDead(_19);
+ StorageDead(_15);
+ StorageDead(_13);
+ StorageDead(_12);
+ StorageDead(_11);
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageDead(_7);
+ StorageDead(_4);
+ StorageDead(_2);
+ StorageDead(_1);
+ return;
+ }
++ }
++
++ ALLOC6 (size: 8, align: 4) {
++ 01 00 00 00 23 00 00 00 │ ....#...
++ }
++
++ ALLOC7 (size: 8, align: 4) {
++ 01 00 00 00 23 00 00 00 │ ....#...
++ }
++
++ ALLOC8 (size: 8, align: 4) {
++ 01 00 00 00 23 00 00 00 │ ....#...
++ }
++
++ ALLOC9 (size: 8, align: 4) {
++ 01 00 00 00 01 00 00 00 │ ........
++ }
++
++ ALLOC10 (size: 4, align: 4) {
++ 01 00 00 00 │ ....
+ }
+
+ ALLOC5 (static: BIG_STAT, size: 8, align: 8) {
+ ╾ALLOC0<imm>╼ │ ╾──────╼
+ }
+
+ ALLOC0 (size: 32, align: 8) {
+ 0x00 │ 01 00 00 00 23 00 00 00 ╾ALLOC1<imm>╼ │ ....#...╾──────╼
+ 0x10 │ 02 00 00 00 00 00 00 00 00 00 a4 42 __ __ __ __ │ ...........B░░░░
+ }
+
+ ALLOC1 (size: 8, align: 4) {
+ 00 00 34 42 00 00 90 42 │ ..4B...B
+ }
+
+ ALLOC4 (static: SMALL_STAT, size: 8, align: 8) {
+ ╾ALLOC2<imm>╼ │ ╾──────╼
+ }
+
+ ALLOC2 (size: 32, align: 8) {
+ 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC3<imm>╼ │ ....░░░░╾──────╼
+ 0x10 │ 01 00 00 00 00 00 00 00 00 00 10 41 __ __ __ __ │ ...........A░░░░
+ }
+
+ ALLOC3 (size: 4, align: 4) {
+ 00 00 50 41 │ ..PA
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.diff
deleted file mode 100644
index 53c62c081..000000000
--- a/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.diff
+++ /dev/null
@@ -1,51 +0,0 @@
-- // MIR for `main` before DataflowConstProp
-+ // MIR for `main` after DataflowConstProp
-
- fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/struct.rs:+0:11: +0:11
- let mut _1: S; // in scope 0 at $DIR/struct.rs:+1:9: +1:14
- let mut _3: i32; // in scope 0 at $DIR/struct.rs:+2:13: +2:16
- let mut _5: i32; // in scope 0 at $DIR/struct.rs:+4:13: +4:14
- let mut _6: i32; // in scope 0 at $DIR/struct.rs:+4:17: +4:20
- scope 1 {
- debug s => _1; // in scope 1 at $DIR/struct.rs:+1:9: +1:14
- let _2: i32; // in scope 1 at $DIR/struct.rs:+2:9: +2:10
- scope 2 {
- debug a => _2; // in scope 2 at $DIR/struct.rs:+2:9: +2:10
- let _4: i32; // in scope 2 at $DIR/struct.rs:+4:9: +4:10
- scope 3 {
- debug b => _4; // in scope 3 at $DIR/struct.rs:+4:9: +4:10
- }
- }
- }
-
- bb0: {
- StorageLive(_1); // scope 0 at $DIR/struct.rs:+1:9: +1:14
- _1 = S(const 1_i32); // scope 0 at $DIR/struct.rs:+1:17: +1:21
- StorageLive(_2); // scope 1 at $DIR/struct.rs:+2:9: +2:10
- StorageLive(_3); // scope 1 at $DIR/struct.rs:+2:13: +2:16
-- _3 = (_1.0: i32); // scope 1 at $DIR/struct.rs:+2:13: +2:16
-- _2 = Add(move _3, const 2_i32); // scope 1 at $DIR/struct.rs:+2:13: +2:20
-+ _3 = const 1_i32; // scope 1 at $DIR/struct.rs:+2:13: +2:16
-+ _2 = const 3_i32; // scope 1 at $DIR/struct.rs:+2:13: +2:20
- StorageDead(_3); // scope 1 at $DIR/struct.rs:+2:19: +2:20
- (_1.0: i32) = const 3_i32; // scope 2 at $DIR/struct.rs:+3:5: +3:12
- StorageLive(_4); // scope 2 at $DIR/struct.rs:+4:9: +4:10
- StorageLive(_5); // scope 2 at $DIR/struct.rs:+4:13: +4:14
-- _5 = _2; // scope 2 at $DIR/struct.rs:+4:13: +4:14
-+ _5 = const 3_i32; // scope 2 at $DIR/struct.rs:+4:13: +4:14
- StorageLive(_6); // scope 2 at $DIR/struct.rs:+4:17: +4:20
-- _6 = (_1.0: i32); // scope 2 at $DIR/struct.rs:+4:17: +4:20
-- _4 = Add(move _5, move _6); // scope 2 at $DIR/struct.rs:+4:13: +4:20
-+ _6 = const 3_i32; // scope 2 at $DIR/struct.rs:+4:17: +4:20
-+ _4 = const 6_i32; // scope 2 at $DIR/struct.rs:+4:13: +4:20
- StorageDead(_6); // scope 2 at $DIR/struct.rs:+4:19: +4:20
- StorageDead(_5); // scope 2 at $DIR/struct.rs:+4:19: +4:20
- _0 = const (); // scope 0 at $DIR/struct.rs:+0:11: +5:2
- StorageDead(_4); // scope 2 at $DIR/struct.rs:+5:1: +5:2
- StorageDead(_2); // scope 1 at $DIR/struct.rs:+5:1: +5:2
- StorageDead(_1); // scope 0 at $DIR/struct.rs:+5:1: +5:2
- return; // scope 0 at $DIR/struct.rs:+5:2: +5:2
- }
- }
-
diff --git a/tests/mir-opt/dataflow-const-prop/struct.rs b/tests/mir-opt/dataflow-const-prop/struct.rs
index 841b279e0..043981a29 100644
--- a/tests/mir-opt/dataflow-const-prop/struct.rs
+++ b/tests/mir-opt/dataflow-const-prop/struct.rs
@@ -1,11 +1,38 @@
+// skip-filecheck
// unit-test: DataflowConstProp
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+#[derive(Copy, Clone)]
struct S(i32);
+#[derive(Copy, Clone)]
+struct SmallStruct(f32, Option<S>, &'static [f32]);
+
+#[derive(Copy, Clone)]
+struct BigStruct(f32, Option<S>, &'static [f32]);
+
// EMIT_MIR struct.main.DataflowConstProp.diff
fn main() {
let mut s = S(1);
let a = s.0 + 2;
s.0 = 3;
let b = a + s.0;
+
+ const SMALL_VAL: SmallStruct = SmallStruct(4., Some(S(1)), &[]);
+ let SmallStruct(a, b, c) = SMALL_VAL;
+
+ static SMALL_STAT: &SmallStruct = &SmallStruct(9., None, &[13.]);
+ let SmallStruct(a, b, c) = *SMALL_STAT;
+
+ let ss = SmallStruct(a, b, c);
+
+ const BIG_VAL: BigStruct = BigStruct(25., None, &[]);
+ let BigStruct(a, b, c) = BIG_VAL;
+
+ static BIG_STAT: &BigStruct = &BigStruct(82., Some(S(35)), &[45., 72.]);
+ let BigStruct(a, b, c) = *BIG_STAT;
+
+ // We arbitrarily limit the size of synthetized values to 4 pointers.
+ // `BigStruct` can be read, but we will keep a MIR aggregate for this.
+ let bs = BigStruct(a, b, c);
}
diff --git a/tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.diff
deleted file mode 100644
index 9854beaeb..000000000
--- a/tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-- // MIR for `main` before DataflowConstProp
-+ // MIR for `main` after DataflowConstProp
-
- fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/terminator.rs:+0:11: +0:11
- let _1: i32; // in scope 0 at $DIR/terminator.rs:+1:9: +1:10
- let _2: (); // in scope 0 at $DIR/terminator.rs:+3:5: +3:15
- let mut _3: i32; // in scope 0 at $DIR/terminator.rs:+3:9: +3:14
- let mut _4: i32; // in scope 0 at $DIR/terminator.rs:+3:9: +3:10
- scope 1 {
- debug a => _1; // in scope 1 at $DIR/terminator.rs:+1:9: +1:10
- }
-
- bb0: {
- StorageLive(_1); // scope 0 at $DIR/terminator.rs:+1:9: +1:10
- _1 = const 1_i32; // scope 0 at $DIR/terminator.rs:+1:13: +1:14
- StorageLive(_2); // scope 1 at $DIR/terminator.rs:+3:5: +3:15
- StorageLive(_3); // scope 1 at $DIR/terminator.rs:+3:9: +3:14
- StorageLive(_4); // scope 1 at $DIR/terminator.rs:+3:9: +3:10
-- _4 = _1; // scope 1 at $DIR/terminator.rs:+3:9: +3:10
-- _3 = Add(move _4, const 1_i32); // scope 1 at $DIR/terminator.rs:+3:9: +3:14
-+ _4 = const 1_i32; // scope 1 at $DIR/terminator.rs:+3:9: +3:10
-+ _3 = const 2_i32; // scope 1 at $DIR/terminator.rs:+3:9: +3:14
- StorageDead(_4); // scope 1 at $DIR/terminator.rs:+3:13: +3:14
-- _2 = foo(move _3) -> bb1; // scope 1 at $DIR/terminator.rs:+3:5: +3:15
-+ _2 = foo(const 2_i32) -> bb1; // scope 1 at $DIR/terminator.rs:+3:5: +3:15
- // mir::Constant
- // + span: $DIR/terminator.rs:10:5: 10:8
- // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) }
- }
-
- bb1: {
- StorageDead(_3); // scope 1 at $DIR/terminator.rs:+3:14: +3:15
- StorageDead(_2); // scope 1 at $DIR/terminator.rs:+3:15: +3:16
- _0 = const (); // scope 0 at $DIR/terminator.rs:+0:11: +4:2
- StorageDead(_1); // scope 0 at $DIR/terminator.rs:+4:1: +4:2
- return; // scope 0 at $DIR/terminator.rs:+4:2: +4:2
- }
- }
-
diff --git a/tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.panic-abort.diff
new file mode 100644
index 000000000..c0f378cc2
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.panic-abort.diff
@@ -0,0 +1,37 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: i32;
+ let _2: ();
+ let mut _3: i32;
+ let mut _4: i32;
+ scope 1 {
+ debug a => _1;
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = const 1_i32;
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+- _4 = _1;
+- _3 = Add(move _4, const 1_i32);
++ _4 = const 1_i32;
++ _3 = const 2_i32;
+ StorageDead(_4);
+- _2 = foo(move _3) -> [return: bb1, unwind unreachable];
++ _2 = foo(const 2_i32) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ StorageDead(_3);
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.panic-unwind.diff
new file mode 100644
index 000000000..395620fec
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.panic-unwind.diff
@@ -0,0 +1,37 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let _1: i32;
+ let _2: ();
+ let mut _3: i32;
+ let mut _4: i32;
+ scope 1 {
+ debug a => _1;
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = const 1_i32;
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+- _4 = _1;
+- _3 = Add(move _4, const 1_i32);
++ _4 = const 1_i32;
++ _3 = const 2_i32;
+ StorageDead(_4);
+- _2 = foo(move _3) -> [return: bb1, unwind continue];
++ _2 = foo(const 2_i32) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ StorageDead(_3);
+ StorageDead(_2);
+ _0 = const ();
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/terminator.rs b/tests/mir-opt/dataflow-const-prop/terminator.rs
index 4f001df35..92a42f22c 100644
--- a/tests/mir-opt/dataflow-const-prop/terminator.rs
+++ b/tests/mir-opt/dataflow-const-prop/terminator.rs
@@ -1,4 +1,5 @@
-// ignore-wasm32 compiled with panic=abort by default
+// skip-filecheck
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: DataflowConstProp
fn foo(n: i32) {}
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.from_char.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.from_char.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..52f096ac0
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.from_char.DataflowConstProp.32bit.diff
@@ -0,0 +1,15 @@
+- // MIR for `from_char` before DataflowConstProp
++ // MIR for `from_char` after DataflowConstProp
+
+ fn from_char() -> i32 {
+ let mut _0: i32;
+ scope 1 {
+ }
+
+ bb0: {
+- _0 = const 'R' as i32 (Transmute);
++ _0 = const 82_i32;
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.from_char.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.from_char.DataflowConstProp.64bit.diff
new file mode 100644
index 000000000..52f096ac0
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.from_char.DataflowConstProp.64bit.diff
@@ -0,0 +1,15 @@
+- // MIR for `from_char` before DataflowConstProp
++ // MIR for `from_char` after DataflowConstProp
+
+ fn from_char() -> i32 {
+ let mut _0: i32;
+ scope 1 {
+ }
+
+ bb0: {
+- _0 = const 'R' as i32 (Transmute);
++ _0 = const 82_i32;
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.invalid_bool.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.invalid_bool.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..3972eb209
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.invalid_bool.DataflowConstProp.32bit.diff
@@ -0,0 +1,15 @@
+- // MIR for `invalid_bool` before DataflowConstProp
++ // MIR for `invalid_bool` after DataflowConstProp
+
+ fn invalid_bool() -> bool {
+ let mut _0: bool;
+ scope 1 {
+ }
+
+ bb0: {
+- _0 = const -1_i8 as bool (Transmute);
++ _0 = const {transmute(0xff): bool};
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.invalid_bool.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.invalid_bool.DataflowConstProp.64bit.diff
new file mode 100644
index 000000000..3972eb209
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.invalid_bool.DataflowConstProp.64bit.diff
@@ -0,0 +1,15 @@
+- // MIR for `invalid_bool` before DataflowConstProp
++ // MIR for `invalid_bool` after DataflowConstProp
+
+ fn invalid_bool() -> bool {
+ let mut _0: bool;
+ scope 1 {
+ }
+
+ bb0: {
+- _0 = const -1_i8 as bool (Transmute);
++ _0 = const {transmute(0xff): bool};
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.invalid_char.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.invalid_char.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..837dabde4
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.invalid_char.DataflowConstProp.32bit.diff
@@ -0,0 +1,15 @@
+- // MIR for `invalid_char` before DataflowConstProp
++ // MIR for `invalid_char` after DataflowConstProp
+
+ fn invalid_char() -> char {
+ let mut _0: char;
+ scope 1 {
+ }
+
+ bb0: {
+- _0 = const _ as char (Transmute);
++ _0 = const {transmute(0x7fffffff): char};
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.invalid_char.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.invalid_char.DataflowConstProp.64bit.diff
new file mode 100644
index 000000000..837dabde4
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.invalid_char.DataflowConstProp.64bit.diff
@@ -0,0 +1,15 @@
+- // MIR for `invalid_char` before DataflowConstProp
++ // MIR for `invalid_char` after DataflowConstProp
+
+ fn invalid_char() -> char {
+ let mut _0: char;
+ scope 1 {
+ }
+
+ bb0: {
+- _0 = const _ as char (Transmute);
++ _0 = const {transmute(0x7fffffff): char};
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.less_as_i8.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.less_as_i8.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..6091e169e
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.less_as_i8.DataflowConstProp.32bit.diff
@@ -0,0 +1,18 @@
+- // MIR for `less_as_i8` before DataflowConstProp
++ // MIR for `less_as_i8` after DataflowConstProp
+
+ fn less_as_i8() -> i8 {
+ let mut _0: i8;
+ let mut _1: std::cmp::Ordering;
+ scope 1 {
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = Less;
+ _0 = move _1 as i8 (Transmute);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.less_as_i8.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.less_as_i8.DataflowConstProp.64bit.diff
new file mode 100644
index 000000000..6091e169e
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.less_as_i8.DataflowConstProp.64bit.diff
@@ -0,0 +1,18 @@
+- // MIR for `less_as_i8` before DataflowConstProp
++ // MIR for `less_as_i8` after DataflowConstProp
+
+ fn less_as_i8() -> i8 {
+ let mut _0: i8;
+ let mut _1: std::cmp::Ordering;
+ scope 1 {
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = Less;
+ _0 = move _1 as i8 (Transmute);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.rs b/tests/mir-opt/dataflow-const-prop/transmute.rs
new file mode 100644
index 000000000..bb85e4586
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.rs
@@ -0,0 +1,85 @@
+// unit-test: DataflowConstProp
+// compile-flags: -O --crate-type=lib
+// ignore-endian-big
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+
+use std::mem::transmute;
+
+// EMIT_MIR transmute.less_as_i8.DataflowConstProp.diff
+pub fn less_as_i8() -> i8 {
+ // CHECK-LABEL: fn less_as_i8(
+ // FIXME-CHECK: _0 = const -1_i8;
+ unsafe { transmute(std::cmp::Ordering::Less) }
+}
+
+// EMIT_MIR transmute.from_char.DataflowConstProp.diff
+pub fn from_char() -> i32 {
+ // CHECK-LABEL: fn from_char(
+ // CHECK: _0 = const 82_i32;
+ unsafe { transmute('R') }
+}
+
+// EMIT_MIR transmute.valid_char.DataflowConstProp.diff
+pub fn valid_char() -> char {
+ // CHECK-LABEL: fn valid_char(
+ // CHECK: _0 = const 'R';
+ unsafe { transmute(0x52_u32) }
+}
+
+// EMIT_MIR transmute.invalid_char.DataflowConstProp.diff
+pub unsafe fn invalid_char() -> char {
+ // CHECK-LABEL: fn invalid_char(
+ // CHECK: _0 = const {transmute(0x7fffffff): char};
+ unsafe { transmute(i32::MAX) }
+}
+
+// EMIT_MIR transmute.invalid_bool.DataflowConstProp.diff
+pub unsafe fn invalid_bool() -> bool {
+ // CHECK-LABEL: fn invalid_bool(
+ // CHECK: _0 = const {transmute(0xff): bool};
+ unsafe { transmute(-1_i8) }
+}
+
+// EMIT_MIR transmute.undef_union_as_integer.DataflowConstProp.diff
+pub unsafe fn undef_union_as_integer() -> u32 {
+ // CHECK-LABEL: fn undef_union_as_integer(
+ // CHECK: _1 = Union32 {
+ // CHECK: _0 = move _1 as u32 (Transmute);
+ union Union32 { value: u32, unit: () }
+ unsafe { transmute(Union32 { unit: () }) }
+}
+
+// EMIT_MIR transmute.unreachable_direct.DataflowConstProp.diff
+pub unsafe fn unreachable_direct() -> ! {
+ // CHECK-LABEL: fn unreachable_direct(
+ // CHECK: = const ();
+ // CHECK: = const ZeroSized: Never;
+ let x: Never = unsafe { transmute(()) };
+ match x {}
+}
+
+// EMIT_MIR transmute.unreachable_ref.DataflowConstProp.diff
+pub unsafe fn unreachable_ref() -> ! {
+ // CHECK-LABEL: fn unreachable_ref(
+ // CHECK: = const {0x1 as &Never};
+ let x: &Never = unsafe { transmute(1_usize) };
+ match *x {}
+}
+
+// EMIT_MIR transmute.unreachable_mut.DataflowConstProp.diff
+pub unsafe fn unreachable_mut() -> ! {
+ // CHECK-LABEL: fn unreachable_mut(
+ // CHECK: = const {0x1 as &mut Never};
+ let x: &mut Never = unsafe { transmute(1_usize) };
+ match *x {}
+}
+
+// EMIT_MIR transmute.unreachable_box.DataflowConstProp.diff
+pub unsafe fn unreachable_box() -> ! {
+ // CHECK-LABEL: fn unreachable_box(
+ // CHECK: = const Box::<Never>(
+ let x: Box<Never> = unsafe { transmute(1_usize) };
+ match *x {}
+}
+
+enum Never {}
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.undef_union_as_integer.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.undef_union_as_integer.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..fb28aa8f6
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.undef_union_as_integer.DataflowConstProp.32bit.diff
@@ -0,0 +1,24 @@
+- // MIR for `undef_union_as_integer` before DataflowConstProp
++ // MIR for `undef_union_as_integer` after DataflowConstProp
+
+ fn undef_union_as_integer() -> u32 {
+ let mut _0: u32;
+ let mut _1: undef_union_as_integer::Union32;
+ let mut _2: ();
+ scope 1 {
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+- _2 = ();
+- _1 = Union32 { value: move _2 };
++ _2 = const ();
++ _1 = Union32 { value: const () };
+ StorageDead(_2);
+ _0 = move _1 as u32 (Transmute);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.undef_union_as_integer.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.undef_union_as_integer.DataflowConstProp.64bit.diff
new file mode 100644
index 000000000..fb28aa8f6
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.undef_union_as_integer.DataflowConstProp.64bit.diff
@@ -0,0 +1,24 @@
+- // MIR for `undef_union_as_integer` before DataflowConstProp
++ // MIR for `undef_union_as_integer` after DataflowConstProp
+
+ fn undef_union_as_integer() -> u32 {
+ let mut _0: u32;
+ let mut _1: undef_union_as_integer::Union32;
+ let mut _2: ();
+ scope 1 {
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+- _2 = ();
+- _1 = Union32 { value: move _2 };
++ _2 = const ();
++ _1 = Union32 { value: const () };
+ StorageDead(_2);
+ _0 = move _1 as u32 (Transmute);
+ StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..5d17c47ae
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.32bit.diff
@@ -0,0 +1,22 @@
+- // MIR for `unreachable_box` before DataflowConstProp
++ // MIR for `unreachable_box` after DataflowConstProp
+
+ fn unreachable_box() -> ! {
+ let mut _0: !;
+ let _1: std::boxed::Box<Never>;
+ let mut _2: *const Never;
+ scope 1 {
+ debug x => _1;
+ }
+ scope 2 {
+ }
+
+ bb0: {
+ StorageLive(_1);
+- _1 = const 1_usize as std::boxed::Box<Never> (Transmute);
++ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
+ _2 = (((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>).0: *const Never);
+ unreachable;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.64bit.diff
new file mode 100644
index 000000000..5d17c47ae
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.64bit.diff
@@ -0,0 +1,22 @@
+- // MIR for `unreachable_box` before DataflowConstProp
++ // MIR for `unreachable_box` after DataflowConstProp
+
+ fn unreachable_box() -> ! {
+ let mut _0: !;
+ let _1: std::boxed::Box<Never>;
+ let mut _2: *const Never;
+ scope 1 {
+ debug x => _1;
+ }
+ scope 2 {
+ }
+
+ bb0: {
+ StorageLive(_1);
+- _1 = const 1_usize as std::boxed::Box<Never> (Transmute);
++ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
+ _2 = (((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>).0: *const Never);
+ unreachable;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.unreachable_direct.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_direct.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..c8d4d6edb
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_direct.DataflowConstProp.32bit.diff
@@ -0,0 +1,24 @@
+- // MIR for `unreachable_direct` before DataflowConstProp
++ // MIR for `unreachable_direct` after DataflowConstProp
+
+ fn unreachable_direct() -> ! {
+ let mut _0: !;
+ let _1: Never;
+ let mut _2: ();
+ scope 1 {
+ debug x => _1;
+ }
+ scope 2 {
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+- _2 = ();
+- _1 = move _2 as Never (Transmute);
++ _2 = const ();
++ _1 = const ZeroSized: Never;
+ unreachable;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.unreachable_direct.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_direct.DataflowConstProp.64bit.diff
new file mode 100644
index 000000000..c8d4d6edb
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_direct.DataflowConstProp.64bit.diff
@@ -0,0 +1,24 @@
+- // MIR for `unreachable_direct` before DataflowConstProp
++ // MIR for `unreachable_direct` after DataflowConstProp
+
+ fn unreachable_direct() -> ! {
+ let mut _0: !;
+ let _1: Never;
+ let mut _2: ();
+ scope 1 {
+ debug x => _1;
+ }
+ scope 2 {
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+- _2 = ();
+- _1 = move _2 as Never (Transmute);
++ _2 = const ();
++ _1 = const ZeroSized: Never;
+ unreachable;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.unreachable_mut.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_mut.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..2ffaeea72
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_mut.DataflowConstProp.32bit.diff
@@ -0,0 +1,24 @@
+- // MIR for `unreachable_mut` before DataflowConstProp
++ // MIR for `unreachable_mut` after DataflowConstProp
+
+ fn unreachable_mut() -> ! {
+ let mut _0: !;
+ let _1: &mut Never;
+ let mut _2: &mut Never;
+ scope 1 {
+ debug x => _1;
+ }
+ scope 2 {
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+- _2 = const 1_usize as &mut Never (Transmute);
++ _2 = const {0x1 as &mut Never};
+ _1 = &mut (*_2);
+ StorageDead(_2);
+ unreachable;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.unreachable_mut.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_mut.DataflowConstProp.64bit.diff
new file mode 100644
index 000000000..2ffaeea72
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_mut.DataflowConstProp.64bit.diff
@@ -0,0 +1,24 @@
+- // MIR for `unreachable_mut` before DataflowConstProp
++ // MIR for `unreachable_mut` after DataflowConstProp
+
+ fn unreachable_mut() -> ! {
+ let mut _0: !;
+ let _1: &mut Never;
+ let mut _2: &mut Never;
+ scope 1 {
+ debug x => _1;
+ }
+ scope 2 {
+ }
+
+ bb0: {
+ StorageLive(_1);
+ StorageLive(_2);
+- _2 = const 1_usize as &mut Never (Transmute);
++ _2 = const {0x1 as &mut Never};
+ _1 = &mut (*_2);
+ StorageDead(_2);
+ unreachable;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.unreachable_ref.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_ref.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..31fcaafc5
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_ref.DataflowConstProp.32bit.diff
@@ -0,0 +1,20 @@
+- // MIR for `unreachable_ref` before DataflowConstProp
++ // MIR for `unreachable_ref` after DataflowConstProp
+
+ fn unreachable_ref() -> ! {
+ let mut _0: !;
+ let _1: &Never;
+ scope 1 {
+ debug x => _1;
+ }
+ scope 2 {
+ }
+
+ bb0: {
+ StorageLive(_1);
+- _1 = const 1_usize as &Never (Transmute);
++ _1 = const {0x1 as &Never};
+ unreachable;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.unreachable_ref.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_ref.DataflowConstProp.64bit.diff
new file mode 100644
index 000000000..31fcaafc5
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_ref.DataflowConstProp.64bit.diff
@@ -0,0 +1,20 @@
+- // MIR for `unreachable_ref` before DataflowConstProp
++ // MIR for `unreachable_ref` after DataflowConstProp
+
+ fn unreachable_ref() -> ! {
+ let mut _0: !;
+ let _1: &Never;
+ scope 1 {
+ debug x => _1;
+ }
+ scope 2 {
+ }
+
+ bb0: {
+ StorageLive(_1);
+- _1 = const 1_usize as &Never (Transmute);
++ _1 = const {0x1 as &Never};
+ unreachable;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.valid_char.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.valid_char.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..402ef754a
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.valid_char.DataflowConstProp.32bit.diff
@@ -0,0 +1,15 @@
+- // MIR for `valid_char` before DataflowConstProp
++ // MIR for `valid_char` after DataflowConstProp
+
+ fn valid_char() -> char {
+ let mut _0: char;
+ scope 1 {
+ }
+
+ bb0: {
+- _0 = const 82_u32 as char (Transmute);
++ _0 = const 'R';
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/transmute.valid_char.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/transmute.valid_char.DataflowConstProp.64bit.diff
new file mode 100644
index 000000000..402ef754a
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.valid_char.DataflowConstProp.64bit.diff
@@ -0,0 +1,15 @@
+- // MIR for `valid_char` before DataflowConstProp
++ // MIR for `valid_char` after DataflowConstProp
+
+ fn valid_char() -> char {
+ let mut _0: char;
+ scope 1 {
+ }
+
+ bb0: {
+- _0 = const 82_u32 as char (Transmute);
++ _0 = const 'R';
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..f5723cac7
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.32bit.diff
@@ -0,0 +1,112 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let mut _1: (i32, i32);
+ let mut _3: i32;
+ let mut _4: i32;
+ let mut _5: i32;
+ let mut _7: i32;
+ let mut _8: i32;
+ let mut _9: i32;
+ let mut _10: i32;
+ let mut _12: i32;
+ let mut _13: (i32, i32);
+ let mut _14: i32;
+ scope 1 {
+ debug a => _1;
+ let _2: i32;
+ scope 2 {
+ debug b => _2;
+ let _6: i32;
+ scope 3 {
+ debug c => _6;
+ let _11: (i32, (i32, i32), i32);
+ scope 4 {
+ debug d => _11;
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+- _1 = (const 1_i32, const 2_i32);
++ _1 = const (1_i32, 2_i32);
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+- _4 = (_1.0: i32);
++ _4 = const 1_i32;
+ StorageLive(_5);
+- _5 = (_1.1: i32);
+- _3 = Add(move _4, move _5);
++ _5 = const 2_i32;
++ _3 = const 3_i32;
+ StorageDead(_5);
+ StorageDead(_4);
+- _2 = Add(move _3, const 3_i32);
++ _2 = const 6_i32;
+ StorageDead(_3);
+- _1 = (const 2_i32, const 3_i32);
++ _1 = const (2_i32, 3_i32);
+ StorageLive(_6);
+ StorageLive(_7);
+ StorageLive(_8);
+- _8 = (_1.0: i32);
++ _8 = const 2_i32;
+ StorageLive(_9);
+- _9 = (_1.1: i32);
+- _7 = Add(move _8, move _9);
++ _9 = const 3_i32;
++ _7 = const 5_i32;
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageLive(_10);
+- _10 = _2;
+- _6 = Add(move _7, move _10);
++ _10 = const 6_i32;
++ _6 = const 11_i32;
+ StorageDead(_10);
+ StorageDead(_7);
+ StorageLive(_11);
+ StorageLive(_12);
+- _12 = _2;
++ _12 = const 6_i32;
+ StorageLive(_13);
+- _13 = _1;
++ _13 = const (2_i32, 3_i32);
+ StorageLive(_14);
+- _14 = _6;
+- _11 = (move _12, move _13, move _14);
++ _14 = const 11_i32;
++ _11 = (const 6_i32, const (2_i32, 3_i32), const 11_i32);
+ StorageDead(_14);
+ StorageDead(_13);
+ StorageDead(_12);
+ _0 = const ();
+ StorageDead(_11);
+ StorageDead(_6);
+ StorageDead(_2);
+ StorageDead(_1);
+ return;
+ }
++ }
++
++ ALLOC0 (size: 8, align: 4) {
++ 02 00 00 00 03 00 00 00 │ ........
++ }
++
++ ALLOC1 (size: 8, align: 4) {
++ 02 00 00 00 03 00 00 00 │ ........
++ }
++
++ ALLOC2 (size: 8, align: 4) {
++ 02 00 00 00 03 00 00 00 │ ........
++ }
++
++ ALLOC3 (size: 8, align: 4) {
++ 01 00 00 00 02 00 00 00 │ ........
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.64bit.diff
new file mode 100644
index 000000000..f5723cac7
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.64bit.diff
@@ -0,0 +1,112 @@
+- // MIR for `main` before DataflowConstProp
++ // MIR for `main` after DataflowConstProp
+
+ fn main() -> () {
+ let mut _0: ();
+ let mut _1: (i32, i32);
+ let mut _3: i32;
+ let mut _4: i32;
+ let mut _5: i32;
+ let mut _7: i32;
+ let mut _8: i32;
+ let mut _9: i32;
+ let mut _10: i32;
+ let mut _12: i32;
+ let mut _13: (i32, i32);
+ let mut _14: i32;
+ scope 1 {
+ debug a => _1;
+ let _2: i32;
+ scope 2 {
+ debug b => _2;
+ let _6: i32;
+ scope 3 {
+ debug c => _6;
+ let _11: (i32, (i32, i32), i32);
+ scope 4 {
+ debug d => _11;
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+- _1 = (const 1_i32, const 2_i32);
++ _1 = const (1_i32, 2_i32);
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+- _4 = (_1.0: i32);
++ _4 = const 1_i32;
+ StorageLive(_5);
+- _5 = (_1.1: i32);
+- _3 = Add(move _4, move _5);
++ _5 = const 2_i32;
++ _3 = const 3_i32;
+ StorageDead(_5);
+ StorageDead(_4);
+- _2 = Add(move _3, const 3_i32);
++ _2 = const 6_i32;
+ StorageDead(_3);
+- _1 = (const 2_i32, const 3_i32);
++ _1 = const (2_i32, 3_i32);
+ StorageLive(_6);
+ StorageLive(_7);
+ StorageLive(_8);
+- _8 = (_1.0: i32);
++ _8 = const 2_i32;
+ StorageLive(_9);
+- _9 = (_1.1: i32);
+- _7 = Add(move _8, move _9);
++ _9 = const 3_i32;
++ _7 = const 5_i32;
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageLive(_10);
+- _10 = _2;
+- _6 = Add(move _7, move _10);
++ _10 = const 6_i32;
++ _6 = const 11_i32;
+ StorageDead(_10);
+ StorageDead(_7);
+ StorageLive(_11);
+ StorageLive(_12);
+- _12 = _2;
++ _12 = const 6_i32;
+ StorageLive(_13);
+- _13 = _1;
++ _13 = const (2_i32, 3_i32);
+ StorageLive(_14);
+- _14 = _6;
+- _11 = (move _12, move _13, move _14);
++ _14 = const 11_i32;
++ _11 = (const 6_i32, const (2_i32, 3_i32), const 11_i32);
+ StorageDead(_14);
+ StorageDead(_13);
+ StorageDead(_12);
+ _0 = const ();
+ StorageDead(_11);
+ StorageDead(_6);
+ StorageDead(_2);
+ StorageDead(_1);
+ return;
+ }
++ }
++
++ ALLOC0 (size: 8, align: 4) {
++ 02 00 00 00 03 00 00 00 │ ........
++ }
++
++ ALLOC1 (size: 8, align: 4) {
++ 02 00 00 00 03 00 00 00 │ ........
++ }
++
++ ALLOC2 (size: 8, align: 4) {
++ 02 00 00 00 03 00 00 00 │ ........
++ }
++
++ ALLOC3 (size: 8, align: 4) {
++ 01 00 00 00 02 00 00 00 │ ........
+ }
+
diff --git a/tests/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.diff
deleted file mode 100644
index 8ce4ce4ba..000000000
--- a/tests/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.diff
+++ /dev/null
@@ -1,71 +0,0 @@
-- // MIR for `main` before DataflowConstProp
-+ // MIR for `main` after DataflowConstProp
-
- fn main() -> () {
- let mut _0: (); // return place in scope 0 at $DIR/tuple.rs:+0:11: +0:11
- let mut _1: (i32, i32); // in scope 0 at $DIR/tuple.rs:+1:9: +1:14
- let mut _3: i32; // in scope 0 at $DIR/tuple.rs:+2:13: +2:22
- let mut _4: i32; // in scope 0 at $DIR/tuple.rs:+2:13: +2:16
- let mut _5: i32; // in scope 0 at $DIR/tuple.rs:+2:19: +2:22
- let mut _7: i32; // in scope 0 at $DIR/tuple.rs:+4:13: +4:22
- let mut _8: i32; // in scope 0 at $DIR/tuple.rs:+4:13: +4:16
- let mut _9: i32; // in scope 0 at $DIR/tuple.rs:+4:19: +4:22
- let mut _10: i32; // in scope 0 at $DIR/tuple.rs:+4:25: +4:26
- scope 1 {
- debug a => _1; // in scope 1 at $DIR/tuple.rs:+1:9: +1:14
- let _2: i32; // in scope 1 at $DIR/tuple.rs:+2:9: +2:10
- scope 2 {
- debug b => _2; // in scope 2 at $DIR/tuple.rs:+2:9: +2:10
- let _6: i32; // in scope 2 at $DIR/tuple.rs:+4:9: +4:10
- scope 3 {
- debug c => _6; // in scope 3 at $DIR/tuple.rs:+4:9: +4:10
- }
- }
- }
-
- bb0: {
- StorageLive(_1); // scope 0 at $DIR/tuple.rs:+1:9: +1:14
- _1 = (const 1_i32, const 2_i32); // scope 0 at $DIR/tuple.rs:+1:17: +1:23
- StorageLive(_2); // scope 1 at $DIR/tuple.rs:+2:9: +2:10
- StorageLive(_3); // scope 1 at $DIR/tuple.rs:+2:13: +2:22
- StorageLive(_4); // scope 1 at $DIR/tuple.rs:+2:13: +2:16
-- _4 = (_1.0: i32); // scope 1 at $DIR/tuple.rs:+2:13: +2:16
-+ _4 = const 1_i32; // scope 1 at $DIR/tuple.rs:+2:13: +2:16
- StorageLive(_5); // scope 1 at $DIR/tuple.rs:+2:19: +2:22
-- _5 = (_1.1: i32); // scope 1 at $DIR/tuple.rs:+2:19: +2:22
-- _3 = Add(move _4, move _5); // scope 1 at $DIR/tuple.rs:+2:13: +2:22
-+ _5 = const 2_i32; // scope 1 at $DIR/tuple.rs:+2:19: +2:22
-+ _3 = const 3_i32; // scope 1 at $DIR/tuple.rs:+2:13: +2:22
- StorageDead(_5); // scope 1 at $DIR/tuple.rs:+2:21: +2:22
- StorageDead(_4); // scope 1 at $DIR/tuple.rs:+2:21: +2:22
-- _2 = Add(move _3, const 3_i32); // scope 1 at $DIR/tuple.rs:+2:13: +2:26
-+ _2 = const 6_i32; // scope 1 at $DIR/tuple.rs:+2:13: +2:26
- StorageDead(_3); // scope 1 at $DIR/tuple.rs:+2:25: +2:26
- _1 = (const 2_i32, const 3_i32); // scope 2 at $DIR/tuple.rs:+3:5: +3:15
- StorageLive(_6); // scope 2 at $DIR/tuple.rs:+4:9: +4:10
- StorageLive(_7); // scope 2 at $DIR/tuple.rs:+4:13: +4:22
- StorageLive(_8); // scope 2 at $DIR/tuple.rs:+4:13: +4:16
-- _8 = (_1.0: i32); // scope 2 at $DIR/tuple.rs:+4:13: +4:16
-+ _8 = const 2_i32; // scope 2 at $DIR/tuple.rs:+4:13: +4:16
- StorageLive(_9); // scope 2 at $DIR/tuple.rs:+4:19: +4:22
-- _9 = (_1.1: i32); // scope 2 at $DIR/tuple.rs:+4:19: +4:22
-- _7 = Add(move _8, move _9); // scope 2 at $DIR/tuple.rs:+4:13: +4:22
-+ _9 = const 3_i32; // scope 2 at $DIR/tuple.rs:+4:19: +4:22
-+ _7 = const 5_i32; // scope 2 at $DIR/tuple.rs:+4:13: +4:22
- StorageDead(_9); // scope 2 at $DIR/tuple.rs:+4:21: +4:22
- StorageDead(_8); // scope 2 at $DIR/tuple.rs:+4:21: +4:22
- StorageLive(_10); // scope 2 at $DIR/tuple.rs:+4:25: +4:26
-- _10 = _2; // scope 2 at $DIR/tuple.rs:+4:25: +4:26
-- _6 = Add(move _7, move _10); // scope 2 at $DIR/tuple.rs:+4:13: +4:26
-+ _10 = const 6_i32; // scope 2 at $DIR/tuple.rs:+4:25: +4:26
-+ _6 = const 11_i32; // scope 2 at $DIR/tuple.rs:+4:13: +4:26
- StorageDead(_10); // scope 2 at $DIR/tuple.rs:+4:25: +4:26
- StorageDead(_7); // scope 2 at $DIR/tuple.rs:+4:25: +4:26
- _0 = const (); // scope 0 at $DIR/tuple.rs:+0:11: +5:2
- StorageDead(_6); // scope 2 at $DIR/tuple.rs:+5:1: +5:2
- StorageDead(_2); // scope 1 at $DIR/tuple.rs:+5:1: +5:2
- StorageDead(_1); // scope 0 at $DIR/tuple.rs:+5:1: +5:2
- return; // scope 0 at $DIR/tuple.rs:+5:2: +5:2
- }
- }
-
diff --git a/tests/mir-opt/dataflow-const-prop/tuple.rs b/tests/mir-opt/dataflow-const-prop/tuple.rs
index 92c70eab0..bb706eafe 100644
--- a/tests/mir-opt/dataflow-const-prop/tuple.rs
+++ b/tests/mir-opt/dataflow-const-prop/tuple.rs
@@ -1,4 +1,6 @@
+// skip-filecheck
// unit-test: DataflowConstProp
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR tuple.main.DataflowConstProp.diff
fn main() {
@@ -6,4 +8,6 @@ fn main() {
let b = a.0 + a.1 + 3;
a = (2, 3);
let c = a.0 + a.1 + b;
+
+ let d = (b, a, c);
}