summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/dataflow-const-prop
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:36 +0000
commite02c5b5930c2c9ba3e5423fe12e2ef0155017297 (patch)
treefd60ebbbb5299e16e5fca8c773ddb74f764760db /tests/mir-opt/dataflow-const-prop
parentAdding debian version 1.73.0+dfsg1-1. (diff)
downloadrustc-e02c5b5930c2c9ba3e5423fe12e2ef0155017297.tar.xz
rustc-e02c5b5930c2c9ba3e5423fe12e2ef0155017297.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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.rs8
-rw-r--r--tests/mir-opt/dataflow-const-prop/boolean_identities.rs10
-rw-r--r--tests/mir-opt/dataflow-const-prop/boolean_identities.test.DataflowConstProp.diff33
-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.rs17
-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.diff (renamed from tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.diff)0
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.64bit.diff82
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.32bit.diff (renamed from tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.diff)0
-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.rs22
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.32bit.diff (renamed from tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.diff)0
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.64bit.diff63
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff126
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff126
-rw-r--r--tests/mir-opt/dataflow-const-prop/if.main.DataflowConstProp.diff10
-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.rs9
-rw-r--r--tests/mir-opt/dataflow-const-prop/mult_by_zero.rs10
-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.rs49
-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.rs8
-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.rs12
-rw-r--r--tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.32bit.diff129
-rw-r--r--tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.64bit.diff129
-rw-r--r--tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.diff51
-rw-r--r--tests/mir-opt/dataflow-const-prop/struct.rs11
-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.rs63
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.undef_union_as_integer.DataflowConstProp.32bit.diff22
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.undef_union_as_integer.DataflowConstProp.64bit.diff22
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.32bit.diff20
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.64bit.diff20
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.unreachable_direct.DataflowConstProp.32bit.diff22
-rw-r--r--tests/mir-opt/dataflow-const-prop/transmute.unreachable_direct.DataflowConstProp.64bit.diff22
-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
75 files changed, 3479 insertions, 55 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..ddb3646ca
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/array_index.rs
@@ -0,0 +1,8 @@
+// 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..9e911e85b
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/boolean_identities.rs
@@ -0,0 +1,10 @@
+// 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/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..b9b46f16a
--- /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 ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) {
+ debug self => _6;
+ let mut _9: *mut u8;
+ scope 15 {
+ scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _9;
+ scope 17 (inlined ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _9;
+ scope 18 {
+ scope 19 (inlined 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: alloc7, 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: alloc10, 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: alloc11, 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;
+ }
++ }
++
++ alloc11 (size: 8, align: 4) {
++ 01 00 00 00 00 00 00 00 │ ........
++ }
++
++ alloc10 (size: 8, align: 4) {
++ 01 00 00 00 00 00 00 00 │ ........
++ }
++
++ alloc7 (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..93b18f23e
--- /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 ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) {
+ debug self => _6;
+ let mut _9: *mut u8;
+ scope 15 {
+ scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _9;
+ scope 17 (inlined ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _9;
+ scope 18 {
+ scope 19 (inlined 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: alloc7, 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: alloc10, 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: alloc11, 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;
+ }
++ }
++
++ alloc11 (size: 8, align: 4) {
++ 01 00 00 00 00 00 00 00 │ ........
++ }
++
++ alloc10 (size: 8, align: 4) {
++ 01 00 00 00 00 00 00 00 │ ........
++ }
++
++ alloc7 (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..3d3af6285
--- /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 ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) {
+ debug self => _6;
+ let mut _9: *mut u8;
+ scope 15 {
+ scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _9;
+ scope 17 (inlined ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _9;
+ scope 18 {
+ scope 19 (inlined 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: alloc7, 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: alloc10, 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: alloc11, 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;
+ }
++ }
++
++ alloc11 (size: 16, align: 8) {
++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
++ }
++
++ alloc10 (size: 16, align: 8) {
++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
++ }
++
++ alloc7 (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..1933f9baf
--- /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 ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) {
+ debug self => _6;
+ let mut _9: *mut u8;
+ scope 15 {
+ scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _9;
+ scope 17 (inlined ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _9;
+ scope 18 {
+ scope 19 (inlined 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: alloc7, 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: alloc10, 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: alloc11, 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;
+ }
++ }
++
++ alloc11 (size: 16, align: 8) {
++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
++ }
++
++ alloc10 (size: 16, align: 8) {
++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
++ }
++
++ alloc7 (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..7862c23da
--- /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 ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) {
+ debug self => _6;
+ let mut _9: *mut u8;
+ scope 15 {
+ scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _9;
+ scope 17 (inlined ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _9;
+ scope 18 {
+ scope 19 (inlined 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: alloc7, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
+ StorageDead(_4);
+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc10, 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: alloc11, 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;
+ }
+ }
+
+ alloc11 (size: 8, align: 4) {
+ 01 00 00 00 00 00 00 00 │ ........
+ }
+
+ alloc10 (size: 8, align: 4) {
+ 01 00 00 00 00 00 00 00 │ ........
+ }
+
+ alloc7 (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..bd4150ebb
--- /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 ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) {
+ debug self => _6;
+ let mut _9: *mut u8;
+ scope 15 {
+ scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _9;
+ scope 17 (inlined ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _9;
+ scope 18 {
+ scope 19 (inlined 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: alloc7, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
+ StorageDead(_4);
+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc10, 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: alloc11, 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;
+ }
+ }
+
+ alloc11 (size: 8, align: 4) {
+ 01 00 00 00 00 00 00 00 │ ........
+ }
+
+ alloc10 (size: 8, align: 4) {
+ 01 00 00 00 00 00 00 00 │ ........
+ }
+
+ alloc7 (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..312fc7b7a
--- /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 ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) {
+ debug self => _6;
+ let mut _9: *mut u8;
+ scope 15 {
+ scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _9;
+ scope 17 (inlined ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _9;
+ scope 18 {
+ scope 19 (inlined 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: alloc7, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
+ StorageDead(_4);
+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc10, 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: alloc11, 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;
+ }
+ }
+
+ alloc11 (size: 16, align: 8) {
+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
+ }
+
+ alloc10 (size: 16, align: 8) {
+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
+ }
+
+ alloc7 (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..3227d8b84
--- /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 ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) {
+ debug self => _6;
+ let mut _9: *mut u8;
+ scope 15 {
+ scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
+ debug ptr => _9;
+ scope 17 (inlined ptr::mut_ptr::<impl *mut u8>::addr) {
+ debug self => _9;
+ scope 18 {
+ scope 19 (inlined 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: alloc7, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
+ StorageDead(_4);
+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: alloc10, 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: alloc11, 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;
+ }
+ }
+
+ alloc11 (size: 16, align: 8) {
+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
+ }
+
+ alloc10 (size: 16, align: 8) {
+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
+ }
+
+ alloc7 (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..dfeccd3eb
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs
@@ -0,0 +1,17 @@
+// 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.diff b/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.32bit.diff
index 775325c4d..775325c4d 100644
--- a/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.diff
+++ b/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.32bit.diff
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.mutate_discriminant.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.32bit.diff
index 960e69ee9..960e69ee9 100644
--- a/tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.diff
+++ b/tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.32bit.diff
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.rs b/tests/mir-opt/dataflow-const-prop/enum.rs
index 79a20d7ef..5a10e9e88 100644
--- a/tests/mir-opt/dataflow-const-prop/enum.rs
+++ b/tests/mir-opt/dataflow-const-prop/enum.rs
@@ -1,9 +1,11 @@
// 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 +17,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 +83,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.diff b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.32bit.diff
index 3946e7c7d..3946e7c7d 100644
--- a/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.diff
+++ b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.32bit.diff
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..3946e7c7d
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.64bit.diff
@@ -0,0 +1,63 @@
+- // 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);
+ 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.statics.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff
new file mode 100644
index 000000000..ae8b44c95
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff
@@ -0,0 +1,126 @@
+- // 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);
+ 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;
+ }
+ }
+
+ alloc2 (static: RC, size: 4, align: 4) {
+ ╾─alloc14─╼ │ ╾──╼
+ }
+
+ alloc14 (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..63799b3ba
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff
@@ -0,0 +1,126 @@
+- // 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);
+ 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;
+ }
+ }
+
+ alloc2 (static: RC, size: 8, align: 8) {
+ ╾───────alloc14───────╼ │ ╾──────╼
+ }
+
+ alloc14 (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 08b599f9f..355f28b03 100644
--- a/tests/mir-opt/dataflow-const-prop/if.main.DataflowConstProp.diff
+++ b/tests/mir-opt/dataflow-const-prop/if.main.DataflowConstProp.diff
@@ -39,19 +39,20 @@
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;
- StorageDead(_4);
-- switchInt(move _3) -> [0: bb2, otherwise: bb1];
+ switchInt(const true) -> [0: bb2, otherwise: bb1];
}
bb1: {
+ StorageDead(_4);
_2 = const 2_i32;
goto -> bb3;
}
bb2: {
+ StorageDead(_4);
_2 = const 3_i32;
goto -> bb3;
}
@@ -70,20 +71,21 @@
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;
- StorageDead(_9);
-- switchInt(move _8) -> [0: bb5, otherwise: bb4];
+ switchInt(const true) -> [0: bb5, otherwise: bb4];
}
bb4: {
+ StorageDead(_9);
- _7 = _1;
+ _7 = const 1_i32;
goto -> bb6;
}
bb5: {
+ StorageDead(_9);
StorageLive(_10);
_10 = _1;
_7 = Add(move _10, const 1_i32);
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..af13c7d10
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/large_array_index.rs
@@ -0,0 +1,9 @@
+// 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..dbea14804
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/mult_by_zero.rs
@@ -0,0 +1,10 @@
+// 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..c61414b65
--- /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]);
+- _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, [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, [2, 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, [2, 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..0c3939a34
--- /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]);
+- _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, [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, [2, 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, [2, 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..d54d46870
--- /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]);
+ _1 = must_use::<usize>(move _2) -> [return: bb1, unwind unreachable];
+ }
+
+ bb1: {
+ StorageDead(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = OffsetOf(Gamma<T>, [1]);
+ _3 = must_use::<usize>(move _4) -> [return: bb2, unwind unreachable];
+ }
+
+ bb2: {
+ StorageDead(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+- _6 = OffsetOf(Delta<T>, [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>, [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..6032a2274
--- /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]);
+ _1 = must_use::<usize>(move _2) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+ StorageDead(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ _4 = OffsetOf(Gamma<T>, [1]);
+ _3 = must_use::<usize>(move _4) -> [return: bb2, unwind continue];
+ }
+
+ bb2: {
+ StorageDead(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+- _6 = OffsetOf(Delta<T>, [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>, [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..ccc90790e
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/offset_of.rs
@@ -0,0 +1,49 @@
+// 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/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..9fa353e44
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/repeat.rs
@@ -0,0 +1,8 @@
+// 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/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..41367e484
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/slice_len.rs
@@ -0,0 +1,12 @@
+// 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..2de6ba307
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.32bit.diff
@@ -0,0 +1,129 @@
+- // 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 _11: BigStruct;
+ let mut _16: &&BigStruct;
+ let mut _17: &BigStruct;
+ let mut _18: &BigStruct;
+ let mut _19: &BigStruct;
+ let mut _20: &BigStruct;
+ let mut _21: &BigStruct;
+ scope 1 {
+ debug s => _1;
+ let _2: i32;
+ scope 2 {
+ debug a => _2;
+ let _4: i32;
+ scope 3 {
+ debug b => _4;
+ let _7: S;
+ let _8: u8;
+ let _9: f32;
+ let _10: S;
+ scope 4 {
+ debug a => _7;
+ debug b => _8;
+ debug c => _9;
+ debug d => _10;
+ let _12: S;
+ let _13: u8;
+ let _14: f32;
+ let _15: S;
+ scope 5 {
+ debug a => _12;
+ debug b => _13;
+ debug c => _14;
+ debug d => _15;
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = S(const 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(_11);
+ _11 = const _;
+ StorageLive(_7);
+- _7 = (_11.0: S);
++ _7 = const S(1_i32);
+ StorageLive(_8);
+- _8 = (_11.1: u8);
++ _8 = const 5_u8;
+ StorageLive(_9);
+- _9 = (_11.2: f32);
++ _9 = const 7f32;
+ StorageLive(_10);
+- _10 = (_11.3: S);
++ _10 = const S(13_i32);
+ StorageDead(_11);
+ StorageLive(_16);
+ _16 = const {alloc1: &&BigStruct};
+ _17 = deref_copy (*_16);
+ StorageLive(_12);
+ _18 = deref_copy (*_16);
+- _12 = ((*_18).0: S);
++ _12 = const S(1_i32);
+ StorageLive(_13);
+ _19 = deref_copy (*_16);
+- _13 = ((*_19).1: u8);
++ _13 = const 5_u8;
+ StorageLive(_14);
+ _20 = deref_copy (*_16);
+- _14 = ((*_20).2: f32);
++ _14 = const 7f32;
+ StorageLive(_15);
+ _21 = deref_copy (*_16);
+- _15 = ((*_21).3: S);
++ _15 = const S(13_i32);
+ StorageDead(_16);
+ _0 = const ();
+ StorageDead(_15);
+ StorageDead(_14);
+ StorageDead(_13);
+ StorageDead(_12);
+ StorageDead(_10);
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageDead(_7);
+ StorageDead(_4);
+ StorageDead(_2);
+ StorageDead(_1);
+ return;
+ }
+ }
+
+ alloc1 (static: STAT, size: 4, align: 4) {
+ ╾─alloc15─╼ │ ╾──╼
+ }
+
+ alloc15 (size: 16, align: 4) {
+ 01 00 00 00 00 00 e0 40 0d 00 00 00 05 __ __ __ │ .......@.....░░░
+ }
+
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..71a28f216
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.64bit.diff
@@ -0,0 +1,129 @@
+- // 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 _11: BigStruct;
+ let mut _16: &&BigStruct;
+ let mut _17: &BigStruct;
+ let mut _18: &BigStruct;
+ let mut _19: &BigStruct;
+ let mut _20: &BigStruct;
+ let mut _21: &BigStruct;
+ scope 1 {
+ debug s => _1;
+ let _2: i32;
+ scope 2 {
+ debug a => _2;
+ let _4: i32;
+ scope 3 {
+ debug b => _4;
+ let _7: S;
+ let _8: u8;
+ let _9: f32;
+ let _10: S;
+ scope 4 {
+ debug a => _7;
+ debug b => _8;
+ debug c => _9;
+ debug d => _10;
+ let _12: S;
+ let _13: u8;
+ let _14: f32;
+ let _15: S;
+ scope 5 {
+ debug a => _12;
+ debug b => _13;
+ debug c => _14;
+ debug d => _15;
+ }
+ }
+ }
+ }
+ }
+
+ bb0: {
+ StorageLive(_1);
+ _1 = S(const 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(_11);
+ _11 = const _;
+ StorageLive(_7);
+- _7 = (_11.0: S);
++ _7 = const S(1_i32);
+ StorageLive(_8);
+- _8 = (_11.1: u8);
++ _8 = const 5_u8;
+ StorageLive(_9);
+- _9 = (_11.2: f32);
++ _9 = const 7f32;
+ StorageLive(_10);
+- _10 = (_11.3: S);
++ _10 = const S(13_i32);
+ StorageDead(_11);
+ StorageLive(_16);
+ _16 = const {alloc1: &&BigStruct};
+ _17 = deref_copy (*_16);
+ StorageLive(_12);
+ _18 = deref_copy (*_16);
+- _12 = ((*_18).0: S);
++ _12 = const S(1_i32);
+ StorageLive(_13);
+ _19 = deref_copy (*_16);
+- _13 = ((*_19).1: u8);
++ _13 = const 5_u8;
+ StorageLive(_14);
+ _20 = deref_copy (*_16);
+- _14 = ((*_20).2: f32);
++ _14 = const 7f32;
+ StorageLive(_15);
+ _21 = deref_copy (*_16);
+- _15 = ((*_21).3: S);
++ _15 = const S(13_i32);
+ StorageDead(_16);
+ _0 = const ();
+ StorageDead(_15);
+ StorageDead(_14);
+ StorageDead(_13);
+ StorageDead(_12);
+ StorageDead(_10);
+ StorageDead(_9);
+ StorageDead(_8);
+ StorageDead(_7);
+ StorageDead(_4);
+ StorageDead(_2);
+ StorageDead(_1);
+ return;
+ }
+ }
+
+ alloc1 (static: STAT, size: 8, align: 8) {
+ ╾───────alloc15───────╼ │ ╾──────╼
+ }
+
+ alloc15 (size: 16, align: 4) {
+ 01 00 00 00 00 00 e0 40 0d 00 00 00 05 __ __ __ │ .......@.....░░░
+ }
+
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 914bc8ac4..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: ();
- let mut _1: S;
- let mut _3: i32;
- let mut _5: i32;
- let mut _6: i32;
- scope 1 {
- debug s => _1;
- let _2: i32;
- scope 2 {
- debug a => _2;
- let _4: i32;
- scope 3 {
- debug b => _4;
- }
- }
- }
-
- bb0: {
- StorageLive(_1);
- _1 = S(const 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);
- _0 = const ();
- StorageDead(_4);
- StorageDead(_2);
- StorageDead(_1);
- return;
- }
- }
-
diff --git a/tests/mir-opt/dataflow-const-prop/struct.rs b/tests/mir-opt/dataflow-const-prop/struct.rs
index 841b279e0..e92a1676d 100644
--- a/tests/mir-opt/dataflow-const-prop/struct.rs
+++ b/tests/mir-opt/dataflow-const-prop/struct.rs
@@ -1,11 +1,22 @@
// unit-test: DataflowConstProp
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
+#[derive(Copy, Clone)]
struct S(i32);
+#[derive(Copy, Clone)]
+struct BigStruct(S, u8, f32, S);
+
// 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 VAL: BigStruct = BigStruct(S(1), 5, 7., S(13));
+ let BigStruct(a, b, c, d) = VAL;
+
+ static STAT: &BigStruct = &BigStruct(S(1), 5, 7., S(13));
+ let BigStruct(a, b, c, d) = *STAT;
}
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..c25e33ab0
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.rs
@@ -0,0 +1,63 @@
+// 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 {
+ unsafe { transmute(std::cmp::Ordering::Less) }
+}
+
+// EMIT_MIR transmute.from_char.DataflowConstProp.diff
+pub fn from_char() -> i32 {
+ unsafe { transmute('R') }
+}
+
+// EMIT_MIR transmute.valid_char.DataflowConstProp.diff
+pub fn valid_char() -> char {
+ unsafe { transmute(0x52_u32) }
+}
+
+// EMIT_MIR transmute.invalid_char.DataflowConstProp.diff
+pub unsafe fn invalid_char() -> char {
+ unsafe { transmute(i32::MAX) }
+}
+
+// EMIT_MIR transmute.invalid_bool.DataflowConstProp.diff
+pub unsafe fn invalid_bool() -> bool {
+ unsafe { transmute(-1_i8) }
+}
+
+// EMIT_MIR transmute.undef_union_as_integer.DataflowConstProp.diff
+pub unsafe fn undef_union_as_integer() -> u32 {
+ union Union32 { value: u32, unit: () }
+ unsafe { transmute(Union32 { unit: () }) }
+}
+
+// EMIT_MIR transmute.unreachable_direct.DataflowConstProp.diff
+pub unsafe fn unreachable_direct() -> ! {
+ let x: Never = unsafe { transmute(()) };
+ match x {}
+}
+
+// EMIT_MIR transmute.unreachable_ref.DataflowConstProp.diff
+pub unsafe fn unreachable_ref() -> ! {
+ let x: &Never = unsafe { transmute(1_usize) };
+ match *x {}
+}
+
+// EMIT_MIR transmute.unreachable_mut.DataflowConstProp.diff
+pub unsafe fn unreachable_mut() -> ! {
+ let x: &mut Never = unsafe { transmute(1_usize) };
+ match *x {}
+}
+
+// EMIT_MIR transmute.unreachable_box.DataflowConstProp.diff
+pub unsafe fn unreachable_box() -> ! {
+ 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..fc0634b1f
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.undef_union_as_integer.DataflowConstProp.32bit.diff
@@ -0,0 +1,22 @@
+- // 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 };
+ 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..fc0634b1f
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.undef_union_as_integer.DataflowConstProp.64bit.diff
@@ -0,0 +1,22 @@
+- // 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 };
+ 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..d0c298ba2
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.32bit.diff
@@ -0,0 +1,20 @@
+- // MIR for `unreachable_box` before DataflowConstProp
++ // MIR for `unreachable_box` after DataflowConstProp
+
+ fn unreachable_box() -> ! {
+ let mut _0: !;
+ let _1: std::boxed::Box<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);
+ 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..d0c298ba2
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.64bit.diff
@@ -0,0 +1,20 @@
+- // MIR for `unreachable_box` before DataflowConstProp
++ // MIR for `unreachable_box` after DataflowConstProp
+
+ fn unreachable_box() -> ! {
+ let mut _0: !;
+ let _1: std::boxed::Box<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);
+ 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..acbb5cd1b
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_direct.DataflowConstProp.32bit.diff
@@ -0,0 +1,22 @@
+- // 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);
+ 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..acbb5cd1b
--- /dev/null
+++ b/tests/mir-opt/dataflow-const-prop/transmute.unreachable_direct.DataflowConstProp.64bit.diff
@@ -0,0 +1,22 @@
+- // 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);
+ 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;
+ }
+ }
+