diff options
| author | bors <bors@rust-lang.org> | 2024-02-12 13:38:31 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-12 13:38:31 +0000 |
| commit | d2e446d39e2390093042a7fd8676cc85f2b573d7 (patch) | |
| tree | 2ded1e3a7beab4afadc95bb8cc2f88102effca4c /tests | |
| parent | cad872a70cb80b429d2eee8085d62310dec339ba (diff) | |
| parent | 781190f5b7bf0e8bd462dd5b7f5eba574a06fa08 (diff) | |
| download | rust-d2e446d39e2390093042a7fd8676cc85f2b573d7.tar.gz rust-d2e446d39e2390093042a7fd8676cc85f2b573d7.zip | |
Auto merge of #3296 - RalfJung:rustup, r=RalfJung
Rustup, more pthread tests
Diffstat (limited to 'tests')
71 files changed, 2478 insertions, 1495 deletions
diff --git a/tests/codegen/comparison-operators-2-tuple.rs b/tests/codegen/comparison-operators-2-tuple.rs index 7a2a3fc93f8..633cfe3a8ac 100644 --- a/tests/codegen/comparison-operators-2-tuple.rs +++ b/tests/codegen/comparison-operators-2-tuple.rs @@ -10,8 +10,10 @@ type TwoTuple = (i16, u16); // // The operators are all overridden directly, so should optimize easily. // -// Yes, the `s[lg]t` is correct for the `[lg]e` version because it's only used -// in the side of the select where we know the values are *not* equal. +// slt-vs-sle and sgt-vs-sge don't matter because they're only used in the side +// of the select where we know the values are not equal, and thus the tests +// use a regex to allow either, since unimportant changes to the implementation +// sometimes result in changing what LLVM decides to emit for this. // // CHECK-LABEL: @check_lt_direct @@ -19,7 +21,7 @@ type TwoTuple = (i16, u16); #[no_mangle] pub fn check_lt_direct(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] - // CHECK-DAG: %[[CMP0:.+]] = icmp slt i16 %[[A0]], %[[B0]] + // CHECK-DAG: %[[CMP0:.+]] = icmp {{slt|sle}} i16 %[[A0]], %[[B0]] // CHECK-DAG: %[[CMP1:.+]] = icmp ult i16 %[[A1]], %[[B1]] // CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[CMP1]], i1 %[[CMP0]] // CHECK: ret i1 %[[R]] @@ -31,7 +33,7 @@ pub fn check_lt_direct(a: TwoTuple, b: TwoTuple) -> bool { #[no_mangle] pub fn check_le_direct(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] - // CHECK-DAG: %[[CMP0:.+]] = icmp slt i16 %[[A0]], %[[B0]] + // CHECK-DAG: %[[CMP0:.+]] = icmp {{slt|sle}} i16 %[[A0]], %[[B0]] // CHECK-DAG: %[[CMP1:.+]] = icmp ule i16 %[[A1]], %[[B1]] // CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[CMP1]], i1 %[[CMP0]] // CHECK: ret i1 %[[R]] @@ -43,7 +45,7 @@ pub fn check_le_direct(a: TwoTuple, b: TwoTuple) -> bool { #[no_mangle] pub fn check_gt_direct(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] - // CHECK-DAG: %[[CMP0:.+]] = icmp sgt i16 %[[A0]], %[[B0]] + // CHECK-DAG: %[[CMP0:.+]] = icmp {{sgt|sge}} i16 %[[A0]], %[[B0]] // CHECK-DAG: %[[CMP1:.+]] = icmp ugt i16 %[[A1]], %[[B1]] // CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[CMP1]], i1 %[[CMP0]] // CHECK: ret i1 %[[R]] @@ -55,7 +57,7 @@ pub fn check_gt_direct(a: TwoTuple, b: TwoTuple) -> bool { #[no_mangle] pub fn check_ge_direct(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] - // CHECK-DAG: %[[CMP0:.+]] = icmp sgt i16 %[[A0]], %[[B0]] + // CHECK-DAG: %[[CMP0:.+]] = icmp {{sgt|sge}} i16 %[[A0]], %[[B0]] // CHECK-DAG: %[[CMP1:.+]] = icmp uge i16 %[[A1]], %[[B1]] // CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[CMP1]], i1 %[[CMP0]] // CHECK: ret i1 %[[R]] diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-abort.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-abort.mir index 7df4eb49260..21a9f6f8721 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-abort.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-abort.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}::{closure#0}` 0 coroutine_closure_by_move -fn main::{closure#0}::{closure#0}(_1: {coroutine-closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { +fn main::{closure#0}::{closure#0}(_1: {async closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { let mut _0: {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10}; bb0: { diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-unwind.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-unwind.mir index 7df4eb49260..21a9f6f8721 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-unwind.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-unwind.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}::{closure#0}` 0 coroutine_closure_by_move -fn main::{closure#0}::{closure#0}(_1: {coroutine-closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { +fn main::{closure#0}::{closure#0}(_1: {async closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { let mut _0: {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10}; bb0: { diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-abort.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-abort.mir index 517b8d0dd88..1cfb6c2f3ea 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-abort.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-abort.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}::{closure#0}` 0 coroutine_closure_by_mut -fn main::{closure#0}::{closure#0}(_1: &mut {coroutine-closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { +fn main::{closure#0}::{closure#0}(_1: &mut {async closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { debug a => _2; debug b => ((*_1).0: i32); let mut _0: {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10}; diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-unwind.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-unwind.mir index 517b8d0dd88..1cfb6c2f3ea 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-unwind.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-unwind.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}::{closure#0}` 0 coroutine_closure_by_mut -fn main::{closure#0}::{closure#0}(_1: &mut {coroutine-closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { +fn main::{closure#0}::{closure#0}(_1: &mut {async closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { debug a => _2; debug b => ((*_1).0: i32); let mut _0: {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10}; diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff index 803be994d9a..5c21c628f85 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff @@ -31,16 +31,17 @@ StorageDead(_3); StorageLive(_6); _6 = const 1_usize; - _7 = Len((*_2)); +- _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]; -+ _8 = Lt(const 1_usize, _7); -+ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [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]; ++ _1 = const 2_u32; StorageDead(_6); StorageDead(_4); StorageDead(_2); diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff index 2a20e3eca59..470cd9c9d8f 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff @@ -31,16 +31,17 @@ StorageDead(_3); StorageLive(_6); _6 = const 1_usize; - _7 = Len((*_2)); +- _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]; -+ _8 = Lt(const 1_usize, _7); -+ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [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]; ++ _1 = const 2_u32; StorageDead(_6); StorageDead(_4); StorageDead(_2); diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff index 803be994d9a..5c21c628f85 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff @@ -31,16 +31,17 @@ StorageDead(_3); StorageLive(_6); _6 = const 1_usize; - _7 = Len((*_2)); +- _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]; -+ _8 = Lt(const 1_usize, _7); -+ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [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]; ++ _1 = const 2_u32; StorageDead(_6); StorageDead(_4); StorageDead(_2); diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff index 2a20e3eca59..470cd9c9d8f 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff @@ -31,16 +31,17 @@ StorageDead(_3); StorageLive(_6); _6 = const 1_usize; - _7 = Len((*_2)); +- _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]; -+ _8 = Lt(const 1_usize, _7); -+ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [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]; ++ _1 = const 2_u32; StorageDead(_6); StorageDead(_4); StorageDead(_2); diff --git a/tests/mir-opt/const_prop/slice_len.rs b/tests/mir-opt/const_prop/slice_len.rs index 79cd926df21..a4973c099cd 100644 --- a/tests/mir-opt/const_prop/slice_len.rs +++ b/tests/mir-opt/const_prop/slice_len.rs @@ -8,9 +8,7 @@ fn main() { // CHECK-LABEL: fn main( // CHECK: debug a => [[a:_.*]]; // CHECK: [[slice:_.*]] = const {{.*}} as &[u32] (PointerCoercion(Unsize)); - // FIXME(cjgillot) simplify Len and projection into unsized slice. - // CHECK-NOT: assert(const true, - // CHECK: [[a]] = (*[[slice]])[1 of 2]; - // CHECK-NOT: [[a]] = const 2_u32; + // CHECK: assert(const true, + // CHECK: [[a]] = const 2_u32; let a = (&[1u32, 2, 3] as &[u32])[1]; } 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 index 94cfb4e63fc..80191a21f4f 100644 --- 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 @@ -69,28 +69,40 @@ } bb2: { - _10 = const {0x1 as *mut [bool; 0]} as *mut () (PtrToPtr); - _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb3, unwind unreachable]; + _10 = const {0x1 as *mut ()}; + _9 = NonNull::<T>::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb3, unwind unreachable]; } bb3: { StorageDead(_8); - _11 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); - _5 = NonNull::<[bool; 0]> { pointer: _11 }; + _11 = const {0x1 as *const [bool; 0]}; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; StorageDead(_11); StorageDead(_10); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; + _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); + _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_9); StorageDead(_3); - _1 = A { foo: move _2 }; + _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; } } + ALLOC2 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ + } + + ALLOC1 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ + } + + ALLOC0 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ + } + diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff index ee85287882b..ed878978e4b 100644 --- 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 @@ -73,28 +73,40 @@ } bb3: { - _10 = const {0x1 as *mut [bool; 0]} as *mut () (PtrToPtr); - _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb4, unwind unreachable]; + _10 = const {0x1 as *mut ()}; + _9 = NonNull::<T>::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb4, unwind unreachable]; } bb4: { StorageDead(_8); - _11 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); - _5 = NonNull::<[bool; 0]> { pointer: _11 }; + _11 = const {0x1 as *const [bool; 0]}; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; StorageDead(_11); StorageDead(_10); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; + _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); + _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_9); StorageDead(_3); - _1 = A { foo: move _2 }; + _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; } } + ALLOC2 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ + } + + ALLOC1 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ + } + + ALLOC0 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ + } + diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff index 94cfb4e63fc..a61902501bf 100644 --- 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 @@ -69,28 +69,40 @@ } bb2: { - _10 = const {0x1 as *mut [bool; 0]} as *mut () (PtrToPtr); - _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb3, unwind unreachable]; + _10 = const {0x1 as *mut ()}; + _9 = NonNull::<T>::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb3, unwind unreachable]; } bb3: { StorageDead(_8); - _11 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); - _5 = NonNull::<[bool; 0]> { pointer: _11 }; + _11 = const {0x1 as *const [bool; 0]}; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; StorageDead(_11); StorageDead(_10); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; + _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); + _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_9); StorageDead(_3); - _1 = A { foo: move _2 }; + _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; } } + ALLOC2 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ + } + + ALLOC1 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ + } + + ALLOC0 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ + } + diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff index ee85287882b..fca7fe89b4a 100644 --- 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 @@ -73,28 +73,40 @@ } bb3: { - _10 = const {0x1 as *mut [bool; 0]} as *mut () (PtrToPtr); - _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb4, unwind unreachable]; + _10 = const {0x1 as *mut ()}; + _9 = NonNull::<T>::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb4, unwind unreachable]; } bb4: { StorageDead(_8); - _11 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); - _5 = NonNull::<[bool; 0]> { pointer: _11 }; + _11 = const {0x1 as *const [bool; 0]}; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; StorageDead(_11); StorageDead(_10); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; + _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); + _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_9); StorageDead(_3); - _1 = A { foo: move _2 }; + _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; } } + ALLOC2 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ + } + + ALLOC1 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ + } + + ALLOC0 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ + } + diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff index 4df38d6e61b..0ced2e4deed 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff @@ -72,29 +72,47 @@ bb2: { - _10 = _6 as *mut () (PtrToPtr); -+ _10 = const {0x1 as *mut [bool; 0]} as *mut () (PtrToPtr); - _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb3, unwind unreachable]; +- _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb3, unwind unreachable]; ++ _10 = const {0x1 as *mut ()}; ++ _9 = NonNull::<T>::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb3, unwind unreachable]; } bb3: { StorageDead(_8); - _11 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); -+ _11 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); - _5 = NonNull::<[bool; 0]> { pointer: _11 }; +- _5 = NonNull::<[bool; 0]> { pointer: _11 }; ++ _11 = const {0x1 as *const [bool; 0]}; ++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; StorageDead(_11); StorageDead(_10); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; +- _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 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); ++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); +- _2 = Box::<[bool]>(_3, const std::alloc::Global); ++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_9); StorageDead(_3); - _1 = A { foo: move _2 }; +- _1 = A { foo: move _2 }; ++ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; } ++ } ++ ++ ALLOC2 (size: 8, align: 4) { ++ 01 00 00 00 00 00 00 00 │ ........ ++ } ++ ++ ALLOC1 (size: 8, align: 4) { ++ 01 00 00 00 00 00 00 00 │ ........ ++ } ++ ++ ALLOC0 (size: 8, align: 4) { ++ 01 00 00 00 00 00 00 00 │ ........ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff index 6aac30bcd17..e17d76a6d95 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff @@ -76,29 +76,47 @@ bb3: { - _10 = _6 as *mut () (PtrToPtr); -+ _10 = const {0x1 as *mut [bool; 0]} as *mut () (PtrToPtr); - _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb4, unwind unreachable]; +- _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb4, unwind unreachable]; ++ _10 = const {0x1 as *mut ()}; ++ _9 = NonNull::<T>::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb4, unwind unreachable]; } bb4: { StorageDead(_8); - _11 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); -+ _11 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); - _5 = NonNull::<[bool; 0]> { pointer: _11 }; +- _5 = NonNull::<[bool; 0]> { pointer: _11 }; ++ _11 = const {0x1 as *const [bool; 0]}; ++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; StorageDead(_11); StorageDead(_10); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; +- _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 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); ++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); +- _2 = Box::<[bool]>(_3, const std::alloc::Global); ++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_9); StorageDead(_3); - _1 = A { foo: move _2 }; +- _1 = A { foo: move _2 }; ++ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; } ++ } ++ ++ ALLOC2 (size: 8, align: 4) { ++ 01 00 00 00 00 00 00 00 │ ........ ++ } ++ ++ ALLOC1 (size: 8, align: 4) { ++ 01 00 00 00 00 00 00 00 │ ........ ++ } ++ ++ ALLOC0 (size: 8, align: 4) { ++ 01 00 00 00 00 00 00 00 │ ........ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff index 4df38d6e61b..ff68b3c2d55 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff @@ -72,29 +72,47 @@ bb2: { - _10 = _6 as *mut () (PtrToPtr); -+ _10 = const {0x1 as *mut [bool; 0]} as *mut () (PtrToPtr); - _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb3, unwind unreachable]; +- _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb3, unwind unreachable]; ++ _10 = const {0x1 as *mut ()}; ++ _9 = NonNull::<T>::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb3, unwind unreachable]; } bb3: { StorageDead(_8); - _11 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); -+ _11 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); - _5 = NonNull::<[bool; 0]> { pointer: _11 }; +- _5 = NonNull::<[bool; 0]> { pointer: _11 }; ++ _11 = const {0x1 as *const [bool; 0]}; ++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; StorageDead(_11); StorageDead(_10); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; +- _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 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); ++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); +- _2 = Box::<[bool]>(_3, const std::alloc::Global); ++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_9); StorageDead(_3); - _1 = A { foo: move _2 }; +- _1 = A { foo: move _2 }; ++ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; } ++ } ++ ++ ALLOC2 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ ++ } ++ ++ ALLOC1 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ ++ } ++ ++ ALLOC0 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff index 6aac30bcd17..de951e57fb9 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff @@ -76,29 +76,47 @@ bb3: { - _10 = _6 as *mut () (PtrToPtr); -+ _10 = const {0x1 as *mut [bool; 0]} as *mut () (PtrToPtr); - _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb4, unwind unreachable]; +- _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb4, unwind unreachable]; ++ _10 = const {0x1 as *mut ()}; ++ _9 = NonNull::<T>::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb4, unwind unreachable]; } bb4: { StorageDead(_8); - _11 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); -+ _11 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); - _5 = NonNull::<[bool; 0]> { pointer: _11 }; +- _5 = NonNull::<[bool; 0]> { pointer: _11 }; ++ _11 = const {0x1 as *const [bool; 0]}; ++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; StorageDead(_11); StorageDead(_10); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; +- _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 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); ++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); +- _2 = Box::<[bool]>(_3, const std::alloc::Global); ++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_9); StorageDead(_3); - _1 = A { foo: move _2 }; +- _1 = A { foo: move _2 }; ++ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; } ++ } ++ ++ ALLOC2 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ ++ } ++ ++ ALLOC1 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ ++ } ++ ++ ALLOC0 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs index fb708e5084b..6c1aafcfa5d 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs @@ -16,14 +16,11 @@ struct A { // CHECK-LABEL: fn main( fn main() { // ConstProp will create a constant of type `Box<[bool]>`. - // FIXME: it is not yet a constant. - // Verify that `DataflowConstProp` does not ICE trying to dereference it directly. // CHECK: debug a => [[a:_.*]]; // We may check other inlined functions as well... - // CHECK: {{_.*}} = Box::<[bool]>( - // FIXME: should be `{{_.*}} = const Box::<[bool]>` + // CHECK: {{_.*}} = const Box::<[bool]>( let a: A = A { foo: Box::default() }; } diff --git a/tests/mir-opt/gvn.rs b/tests/mir-opt/gvn.rs index 31ea237cbec..fccd4484a29 100644 --- a/tests/mir-opt/gvn.rs +++ b/tests/mir-opt/gvn.rs @@ -644,25 +644,80 @@ fn constant_index_overflow<T: Copy>(x: &[T]) { opaque(b) } -fn wide_ptr_ops() { +/// Check that we do not attempt to simplify anything when there is provenance. +fn wide_ptr_provenance() { + // CHECK-LABEL: fn wide_ptr_provenance( let a: *const dyn Send = &1 as &dyn Send; let b: *const dyn Send = &1 as &dyn Send; - let _val = a == b; - let _val = a != b; - let _val = a < b; - let _val = a <= b; - let _val = a > b; - let _val = a >= b; + + // CHECK: [[eqp:_.*]] = Eq([[a:_.*]], [[b:_.*]]); + // CHECK: opaque::<bool>(move [[eqp]]) + opaque(a == b); + // CHECK: [[nep:_.*]] = Ne([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[nep]]) + opaque(a != b); + // CHECK: [[ltp:_.*]] = Lt([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[ltp]]) + opaque(a < b); + // CHECK: [[lep:_.*]] = Le([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[lep]]) + opaque(a <= b); + // CHECK: [[gtp:_.*]] = Gt([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[gtp]]) + opaque(a > b); + // CHECK: [[gep:_.*]] = Ge([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[gep]]) + opaque(a >= b); +} + +/// Both pointers come form the same allocation, so we could probably fold the comparisons. +fn wide_ptr_same_provenance() { + // CHECK-LABEL: fn wide_ptr_same_provenance( + let slice = &[1, 2]; + let a: *const dyn Send = &slice[0] as &dyn Send; + let b: *const dyn Send = &slice[1] as &dyn Send; + + // CHECK: [[eqp:_.*]] = Eq([[a:_.*]], [[b:_.*]]); + // CHECK: opaque::<bool>(move [[eqp]]) + opaque(a == b); + // CHECK: [[nep:_.*]] = Ne([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[nep]]) + opaque(a != b); + // CHECK: [[ltp:_.*]] = Lt([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[ltp]]) + opaque(a < b); + // CHECK: [[lep:_.*]] = Le([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[lep]]) + opaque(a <= b); + // CHECK: [[gtp:_.*]] = Gt([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[gtp]]) + opaque(a > b); + // CHECK: [[gep:_.*]] = Ge([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[gep]]) + opaque(a >= b); +} + +/// Check that we do simplify when there is no provenance, and do not ICE. +fn wide_ptr_integer() { + // CHECK-LABEL: fn wide_ptr_integer( + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug b => [[b:_.*]]; let a: *const [u8] = unsafe { transmute((1usize, 1usize)) }; let b: *const [u8] = unsafe { transmute((1usize, 2usize)) }; - opaque(!(a == b)); + // CHECK: opaque::<bool>(const false) + opaque(a == b); + // CHECK: opaque::<bool>(const true) opaque(a != b); - opaque(a <= b); + // CHECK: opaque::<bool>(const true) opaque(a < b); - opaque(!(a >= b)); - opaque(!(a > b)); + // CHECK: opaque::<bool>(const true) + opaque(a <= b); + // CHECK: opaque::<bool>(const false) + opaque(a > b); + // CHECK: opaque::<bool>(const false) + opaque(a >= b); } fn main() { @@ -685,7 +740,8 @@ fn main() { fn_pointers(); indirect_static(); constant_index_overflow(&[5, 3]); - wide_ptr_ops(); + wide_ptr_provenance(); + wide_ptr_integer(); } #[inline(never)] @@ -714,4 +770,6 @@ fn identity<T>(x: T) -> T { // EMIT_MIR gvn.fn_pointers.GVN.diff // EMIT_MIR gvn.indirect_static.GVN.diff // EMIT_MIR gvn.constant_index_overflow.GVN.diff -// EMIT_MIR gvn.wide_ptr_ops.GVN.diff +// EMIT_MIR gvn.wide_ptr_provenance.GVN.diff +// EMIT_MIR gvn.wide_ptr_same_provenance.GVN.diff +// EMIT_MIR gvn.wide_ptr_integer.GVN.diff diff --git a/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-abort.diff b/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-abort.diff new file mode 100644 index 00000000000..11cd43fc0e0 --- /dev/null +++ b/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-abort.diff @@ -0,0 +1,192 @@ +- // MIR for `wide_ptr_integer` before GVN ++ // MIR for `wide_ptr_integer` after GVN + + fn wide_ptr_integer() -> () { + let mut _0: (); + let _1: *const [u8]; + let mut _2: (usize, usize); + let mut _4: (usize, usize); + let _5: (); + let mut _6: bool; + let mut _7: *const [u8]; + let mut _8: *const [u8]; + let _9: (); + let mut _10: bool; + let mut _11: *const [u8]; + let mut _12: *const [u8]; + let _13: (); + let mut _14: bool; + let mut _15: *const [u8]; + let mut _16: *const [u8]; + let _17: (); + let mut _18: bool; + let mut _19: *const [u8]; + let mut _20: *const [u8]; + let _21: (); + let mut _22: bool; + let mut _23: *const [u8]; + let mut _24: *const [u8]; + let _25: (); + let mut _26: bool; + let mut _27: *const [u8]; + let mut _28: *const [u8]; + scope 1 { + debug a => _1; + let _3: *const [u8]; + scope 3 { + debug b => _3; + } + scope 4 { + } + } + scope 2 { + } + + bb0: { +- StorageLive(_1); ++ nop; + StorageLive(_2); +- _2 = (const 1_usize, const 1_usize); +- _1 = move _2 as *const [u8] (Transmute); ++ _2 = const (1_usize, 1_usize); ++ _1 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageDead(_2); +- StorageLive(_3); ++ nop; + StorageLive(_4); +- _4 = (const 1_usize, const 2_usize); +- _3 = move _4 as *const [u8] (Transmute); ++ _4 = const (1_usize, 2_usize); ++ _3 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; + StorageDead(_4); + StorageLive(_5); + StorageLive(_6); + StorageLive(_7); +- _7 = _1; ++ _7 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_8); +- _8 = _3; +- _6 = Eq(move _7, move _8); ++ _8 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _6 = const false; + StorageDead(_8); + StorageDead(_7); +- _5 = opaque::<bool>(move _6) -> [return: bb1, unwind unreachable]; ++ _5 = opaque::<bool>(const false) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_6); + StorageDead(_5); + StorageLive(_9); + StorageLive(_10); + StorageLive(_11); +- _11 = _1; ++ _11 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_12); +- _12 = _3; +- _10 = Ne(move _11, move _12); ++ _12 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _10 = const true; + StorageDead(_12); + StorageDead(_11); +- _9 = opaque::<bool>(move _10) -> [return: bb2, unwind unreachable]; ++ _9 = opaque::<bool>(const true) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_10); + StorageDead(_9); + StorageLive(_13); + StorageLive(_14); + StorageLive(_15); +- _15 = _1; ++ _15 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_16); +- _16 = _3; +- _14 = Lt(move _15, move _16); ++ _16 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _14 = const true; + StorageDead(_16); + StorageDead(_15); +- _13 = opaque::<bool>(move _14) -> [return: bb3, unwind unreachable]; ++ _13 = opaque::<bool>(const true) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_14); + StorageDead(_13); + StorageLive(_17); + StorageLive(_18); + StorageLive(_19); +- _19 = _1; ++ _19 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_20); +- _20 = _3; +- _18 = Le(move _19, move _20); ++ _20 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _18 = const true; + StorageDead(_20); + StorageDead(_19); +- _17 = opaque::<bool>(move _18) -> [return: bb4, unwind unreachable]; ++ _17 = opaque::<bool>(const true) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_18); + StorageDead(_17); + StorageLive(_21); + StorageLive(_22); + StorageLive(_23); +- _23 = _1; ++ _23 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_24); +- _24 = _3; +- _22 = Gt(move _23, move _24); ++ _24 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _22 = const false; + StorageDead(_24); + StorageDead(_23); +- _21 = opaque::<bool>(move _22) -> [return: bb5, unwind unreachable]; ++ _21 = opaque::<bool>(const false) -> [return: bb5, unwind unreachable]; + } + + bb5: { + StorageDead(_22); + StorageDead(_21); + StorageLive(_25); + StorageLive(_26); + StorageLive(_27); +- _27 = _1; ++ _27 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_28); +- _28 = _3; +- _26 = Ge(move _27, move _28); ++ _28 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _26 = const false; + StorageDead(_28); + StorageDead(_27); +- _25 = opaque::<bool>(move _26) -> [return: bb6, unwind unreachable]; ++ _25 = opaque::<bool>(const false) -> [return: bb6, unwind unreachable]; + } + + bb6: { + StorageDead(_26); + StorageDead(_25); + _0 = const (); +- StorageDead(_3); +- StorageDead(_1); ++ nop; ++ nop; + return; + } ++ } ++ ++ ALLOC1 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 │ ................ ++ } ++ ++ ALLOC0 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 │ ................ + } + diff --git a/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-unwind.diff b/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-unwind.diff new file mode 100644 index 00000000000..c77cd07c60c --- /dev/null +++ b/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-unwind.diff @@ -0,0 +1,192 @@ +- // MIR for `wide_ptr_integer` before GVN ++ // MIR for `wide_ptr_integer` after GVN + + fn wide_ptr_integer() -> () { + let mut _0: (); + let _1: *const [u8]; + let mut _2: (usize, usize); + let mut _4: (usize, usize); + let _5: (); + let mut _6: bool; + let mut _7: *const [u8]; + let mut _8: *const [u8]; + let _9: (); + let mut _10: bool; + let mut _11: *const [u8]; + let mut _12: *const [u8]; + let _13: (); + let mut _14: bool; + let mut _15: *const [u8]; + let mut _16: *const [u8]; + let _17: (); + let mut _18: bool; + let mut _19: *const [u8]; + let mut _20: *const [u8]; + let _21: (); + let mut _22: bool; + let mut _23: *const [u8]; + let mut _24: *const [u8]; + let _25: (); + let mut _26: bool; + let mut _27: *const [u8]; + let mut _28: *const [u8]; + scope 1 { + debug a => _1; + let _3: *const [u8]; + scope 3 { + debug b => _3; + } + scope 4 { + } + } + scope 2 { + } + + bb0: { +- StorageLive(_1); ++ nop; + StorageLive(_2); +- _2 = (const 1_usize, const 1_usize); +- _1 = move _2 as *const [u8] (Transmute); ++ _2 = const (1_usize, 1_usize); ++ _1 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageDead(_2); +- StorageLive(_3); ++ nop; + StorageLive(_4); +- _4 = (const 1_usize, const 2_usize); +- _3 = move _4 as *const [u8] (Transmute); ++ _4 = const (1_usize, 2_usize); ++ _3 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; + StorageDead(_4); + StorageLive(_5); + StorageLive(_6); + StorageLive(_7); +- _7 = _1; ++ _7 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_8); +- _8 = _3; +- _6 = Eq(move _7, move _8); ++ _8 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _6 = const false; + StorageDead(_8); + StorageDead(_7); +- _5 = opaque::<bool>(move _6) -> [return: bb1, unwind continue]; ++ _5 = opaque::<bool>(const false) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_6); + StorageDead(_5); + StorageLive(_9); + StorageLive(_10); + StorageLive(_11); +- _11 = _1; ++ _11 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_12); +- _12 = _3; +- _10 = Ne(move _11, move _12); ++ _12 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _10 = const true; + StorageDead(_12); + StorageDead(_11); +- _9 = opaque::<bool>(move _10) -> [return: bb2, unwind continue]; ++ _9 = opaque::<bool>(const true) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_10); + StorageDead(_9); + StorageLive(_13); + StorageLive(_14); + StorageLive(_15); +- _15 = _1; ++ _15 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_16); +- _16 = _3; +- _14 = Lt(move _15, move _16); ++ _16 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _14 = const true; + StorageDead(_16); + StorageDead(_15); +- _13 = opaque::<bool>(move _14) -> [return: bb3, unwind continue]; ++ _13 = opaque::<bool>(const true) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_14); + StorageDead(_13); + StorageLive(_17); + StorageLive(_18); + StorageLive(_19); +- _19 = _1; ++ _19 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_20); +- _20 = _3; +- _18 = Le(move _19, move _20); ++ _20 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _18 = const true; + StorageDead(_20); + StorageDead(_19); +- _17 = opaque::<bool>(move _18) -> [return: bb4, unwind continue]; ++ _17 = opaque::<bool>(const true) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_18); + StorageDead(_17); + StorageLive(_21); + StorageLive(_22); + StorageLive(_23); +- _23 = _1; ++ _23 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_24); +- _24 = _3; +- _22 = Gt(move _23, move _24); ++ _24 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _22 = const false; + StorageDead(_24); + StorageDead(_23); +- _21 = opaque::<bool>(move _22) -> [return: bb5, unwind continue]; ++ _21 = opaque::<bool>(const false) -> [return: bb5, unwind continue]; + } + + bb5: { + StorageDead(_22); + StorageDead(_21); + StorageLive(_25); + StorageLive(_26); + StorageLive(_27); +- _27 = _1; ++ _27 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_28); +- _28 = _3; +- _26 = Ge(move _27, move _28); ++ _28 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _26 = const false; + StorageDead(_28); + StorageDead(_27); +- _25 = opaque::<bool>(move _26) -> [return: bb6, unwind continue]; ++ _25 = opaque::<bool>(const false) -> [return: bb6, unwind continue]; + } + + bb6: { + StorageDead(_26); + StorageDead(_25); + _0 = const (); +- StorageDead(_3); +- StorageDead(_1); ++ nop; ++ nop; + return; + } ++ } ++ ++ ALLOC1 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 │ ................ ++ } ++ ++ ALLOC0 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 │ ................ + } + diff --git a/tests/mir-opt/gvn.wide_ptr_ops.GVN.panic-abort.diff b/tests/mir-opt/gvn.wide_ptr_ops.GVN.panic-abort.diff deleted file mode 100644 index e49d759b8fc..00000000000 --- a/tests/mir-opt/gvn.wide_ptr_ops.GVN.panic-abort.diff +++ /dev/null @@ -1,386 +0,0 @@ -- // MIR for `wide_ptr_ops` before GVN -+ // MIR for `wide_ptr_ops` after GVN - - fn wide_ptr_ops() -> () { - let mut _0: (); - let _1: *const dyn std::marker::Send; - let mut _2: *const dyn std::marker::Send; - let _3: &dyn std::marker::Send; - let mut _4: &i32; - let _5: &i32; - let _6: i32; - let mut _8: *const dyn std::marker::Send; - let _9: &dyn std::marker::Send; - let mut _10: &i32; - let _11: &i32; - let _12: i32; - let mut _14: *const dyn std::marker::Send; - let mut _15: *const dyn std::marker::Send; - let mut _16: *const dyn std::marker::Send; - let mut _18: *const dyn std::marker::Send; - let mut _19: *const dyn std::marker::Send; - let mut _20: *const dyn std::marker::Send; - let mut _22: *const dyn std::marker::Send; - let mut _23: *const dyn std::marker::Send; - let mut _24: *const dyn std::marker::Send; - let mut _26: *const dyn std::marker::Send; - let mut _27: *const dyn std::marker::Send; - let mut _28: *const dyn std::marker::Send; - let mut _30: *const dyn std::marker::Send; - let mut _31: *const dyn std::marker::Send; - let mut _32: *const dyn std::marker::Send; - let mut _34: *const dyn std::marker::Send; - let mut _35: *const dyn std::marker::Send; - let mut _36: *const dyn std::marker::Send; - let mut _38: (usize, usize); - let mut _40: (usize, usize); - let _41: (); - let mut _42: bool; - let mut _43: bool; - let mut _44: *const [u8]; - let mut _45: *const [u8]; - let _46: (); - let mut _47: bool; - let mut _48: *const [u8]; - let mut _49: *const [u8]; - let _50: (); - let mut _51: bool; - let mut _52: *const [u8]; - let mut _53: *const [u8]; - let _54: (); - let mut _55: bool; - let mut _56: *const [u8]; - let mut _57: *const [u8]; - let _58: (); - let mut _59: bool; - let mut _60: bool; - let mut _61: *const [u8]; - let mut _62: *const [u8]; - let _63: (); - let mut _64: bool; - let mut _65: bool; - let mut _66: *const [u8]; - let mut _67: *const [u8]; - let mut _69: &i32; - scope 1 { - debug a => _1; - let _7: *const dyn std::marker::Send; - let mut _68: &i32; - scope 2 { - debug b => _7; - let _13: bool; - scope 3 { - debug _val => _13; - let _17: bool; - scope 4 { - debug _val => _17; - let _21: bool; - scope 5 { - debug _val => _21; - let _25: bool; - scope 6 { - debug _val => _25; - let _29: bool; - scope 7 { - debug _val => _29; - let _33: bool; - scope 8 { - debug _val => _33; - let _37: *const [u8]; - scope 9 { - debug a => _37; - let _39: *const [u8]; - scope 11 { - debug b => _39; - } - scope 12 { - } - } - scope 10 { - } - } - } - } - } - } - } - } - } - - bb0: { -- StorageLive(_1); -+ nop; - StorageLive(_2); - StorageLive(_3); - StorageLive(_4); - StorageLive(_5); - _69 = const _; - _5 = &(*_69); - _4 = &(*_5); - _3 = move _4 as &dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_4); - _2 = &raw const (*_3); - _1 = move _2 as *const dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_2); - StorageDead(_5); - StorageDead(_3); -- StorageLive(_7); -+ nop; - StorageLive(_8); - StorageLive(_9); - StorageLive(_10); - StorageLive(_11); - _68 = const _; - _11 = &(*_68); - _10 = &(*_11); - _9 = move _10 as &dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_10); - _8 = &raw const (*_9); - _7 = move _8 as *const dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_8); - StorageDead(_11); - StorageDead(_9); - StorageLive(_13); - StorageLive(_14); - _14 = _1; -- StorageLive(_15); -+ nop; - StorageLive(_16); - _16 = _7; -- _15 = move _16 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _15 = _7 as *const dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_16); -- _13 = Eq(move _14, move _15); -- StorageDead(_15); -+ _13 = Eq(_1, _15); -+ nop; - StorageDead(_14); - StorageLive(_17); - StorageLive(_18); - _18 = _1; - StorageLive(_19); - StorageLive(_20); - _20 = _7; -- _19 = move _20 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _19 = _15; - StorageDead(_20); -- _17 = Ne(move _18, move _19); -+ _17 = Ne(_1, _15); - StorageDead(_19); - StorageDead(_18); - StorageLive(_21); - StorageLive(_22); - _22 = _1; - StorageLive(_23); - StorageLive(_24); - _24 = _7; -- _23 = move _24 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _23 = _15; - StorageDead(_24); -- _21 = Lt(move _22, move _23); -+ _21 = Lt(_1, _15); - StorageDead(_23); - StorageDead(_22); - StorageLive(_25); - StorageLive(_26); - _26 = _1; - StorageLive(_27); - StorageLive(_28); - _28 = _7; -- _27 = move _28 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _27 = _15; - StorageDead(_28); -- _25 = Le(move _26, move _27); -+ _25 = Le(_1, _15); - StorageDead(_27); - StorageDead(_26); - StorageLive(_29); - StorageLive(_30); - _30 = _1; - StorageLive(_31); - StorageLive(_32); - _32 = _7; -- _31 = move _32 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _31 = _15; - StorageDead(_32); -- _29 = Gt(move _30, move _31); -+ _29 = Gt(_1, _15); - StorageDead(_31); - StorageDead(_30); - StorageLive(_33); - StorageLive(_34); - _34 = _1; - StorageLive(_35); - StorageLive(_36); - _36 = _7; -- _35 = move _36 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _35 = _15; - StorageDead(_36); -- _33 = Ge(move _34, move _35); -+ _33 = Ge(_1, _15); - StorageDead(_35); - StorageDead(_34); -- StorageLive(_37); -+ nop; - StorageLive(_38); -- _38 = (const 1_usize, const 1_usize); -- _37 = move _38 as *const [u8] (Transmute); -+ _38 = const (1_usize, 1_usize); -+ _37 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageDead(_38); -- StorageLive(_39); -+ nop; - StorageLive(_40); -- _40 = (const 1_usize, const 2_usize); -- _39 = move _40 as *const [u8] (Transmute); -+ _40 = const (1_usize, 2_usize); -+ _39 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; - StorageDead(_40); - StorageLive(_41); -- StorageLive(_42); -+ nop; - StorageLive(_43); - StorageLive(_44); -- _44 = _37; -+ _44 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_45); -- _45 = _39; -- _43 = Eq(move _44, move _45); -+ _45 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _43 = Eq(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_45); - StorageDead(_44); - _42 = Not(move _43); - StorageDead(_43); -- _41 = opaque::<bool>(move _42) -> [return: bb1, unwind unreachable]; -+ _41 = opaque::<bool>(_42) -> [return: bb1, unwind unreachable]; - } - - bb1: { -- StorageDead(_42); -+ nop; - StorageDead(_41); - StorageLive(_46); - StorageLive(_47); - StorageLive(_48); -- _48 = _37; -+ _48 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_49); -- _49 = _39; -- _47 = Ne(move _48, move _49); -+ _49 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _47 = _42; - StorageDead(_49); - StorageDead(_48); -- _46 = opaque::<bool>(move _47) -> [return: bb2, unwind unreachable]; -+ _46 = opaque::<bool>(_42) -> [return: bb2, unwind unreachable]; - } - - bb2: { - StorageDead(_47); - StorageDead(_46); - StorageLive(_50); - StorageLive(_51); - StorageLive(_52); -- _52 = _37; -+ _52 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_53); -- _53 = _39; -- _51 = Le(move _52, move _53); -+ _53 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _51 = Le(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_53); - StorageDead(_52); - _50 = opaque::<bool>(move _51) -> [return: bb3, unwind unreachable]; - } - - bb3: { - StorageDead(_51); - StorageDead(_50); - StorageLive(_54); - StorageLive(_55); - StorageLive(_56); -- _56 = _37; -+ _56 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_57); -- _57 = _39; -- _55 = Lt(move _56, move _57); -+ _57 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _55 = Lt(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_57); - StorageDead(_56); - _54 = opaque::<bool>(move _55) -> [return: bb4, unwind unreachable]; - } - - bb4: { - StorageDead(_55); - StorageDead(_54); - StorageLive(_58); - StorageLive(_59); - StorageLive(_60); - StorageLive(_61); -- _61 = _37; -+ _61 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_62); -- _62 = _39; -- _60 = Ge(move _61, move _62); -+ _62 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _60 = Ge(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_62); - StorageDead(_61); - _59 = Not(move _60); - StorageDead(_60); - _58 = opaque::<bool>(move _59) -> [return: bb5, unwind unreachable]; - } - - bb5: { - StorageDead(_59); - StorageDead(_58); - StorageLive(_63); - StorageLive(_64); - StorageLive(_65); - StorageLive(_66); -- _66 = _37; -+ _66 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_67); -- _67 = _39; -- _65 = Gt(move _66, move _67); -+ _67 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _65 = Gt(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_67); - StorageDead(_66); - _64 = Not(move _65); - StorageDead(_65); - _63 = opaque::<bool>(move _64) -> [return: bb6, unwind unreachable]; - } - - bb6: { - StorageDead(_64); - StorageDead(_63); - _0 = const (); -- StorageDead(_39); -- StorageDead(_37); -+ nop; -+ nop; - StorageDead(_33); - StorageDead(_29); - StorageDead(_25); - StorageDead(_21); - StorageDead(_17); - StorageDead(_13); -- StorageDead(_7); -- StorageDead(_1); -+ nop; -+ nop; - return; - } -+ } -+ -+ ALLOC1 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 │ ................ -+ } -+ -+ ALLOC0 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 │ ................ - } - diff --git a/tests/mir-opt/gvn.wide_ptr_ops.GVN.panic-unwind.diff b/tests/mir-opt/gvn.wide_ptr_ops.GVN.panic-unwind.diff deleted file mode 100644 index 4e5608a4425..00000000000 --- a/tests/mir-opt/gvn.wide_ptr_ops.GVN.panic-unwind.diff +++ /dev/null @@ -1,386 +0,0 @@ -- // MIR for `wide_ptr_ops` before GVN -+ // MIR for `wide_ptr_ops` after GVN - - fn wide_ptr_ops() -> () { - let mut _0: (); - let _1: *const dyn std::marker::Send; - let mut _2: *const dyn std::marker::Send; - let _3: &dyn std::marker::Send; - let mut _4: &i32; - let _5: &i32; - let _6: i32; - let mut _8: *const dyn std::marker::Send; - let _9: &dyn std::marker::Send; - let mut _10: &i32; - let _11: &i32; - let _12: i32; - let mut _14: *const dyn std::marker::Send; - let mut _15: *const dyn std::marker::Send; - let mut _16: *const dyn std::marker::Send; - let mut _18: *const dyn std::marker::Send; - let mut _19: *const dyn std::marker::Send; - let mut _20: *const dyn std::marker::Send; - let mut _22: *const dyn std::marker::Send; - let mut _23: *const dyn std::marker::Send; - let mut _24: *const dyn std::marker::Send; - let mut _26: *const dyn std::marker::Send; - let mut _27: *const dyn std::marker::Send; - let mut _28: *const dyn std::marker::Send; - let mut _30: *const dyn std::marker::Send; - let mut _31: *const dyn std::marker::Send; - let mut _32: *const dyn std::marker::Send; - let mut _34: *const dyn std::marker::Send; - let mut _35: *const dyn std::marker::Send; - let mut _36: *const dyn std::marker::Send; - let mut _38: (usize, usize); - let mut _40: (usize, usize); - let _41: (); - let mut _42: bool; - let mut _43: bool; - let mut _44: *const [u8]; - let mut _45: *const [u8]; - let _46: (); - let mut _47: bool; - let mut _48: *const [u8]; - let mut _49: *const [u8]; - let _50: (); - let mut _51: bool; - let mut _52: *const [u8]; - let mut _53: *const [u8]; - let _54: (); - let mut _55: bool; - let mut _56: *const [u8]; - let mut _57: *const [u8]; - let _58: (); - let mut _59: bool; - let mut _60: bool; - let mut _61: *const [u8]; - let mut _62: *const [u8]; - let _63: (); - let mut _64: bool; - let mut _65: bool; - let mut _66: *const [u8]; - let mut _67: *const [u8]; - let mut _69: &i32; - scope 1 { - debug a => _1; - let _7: *const dyn std::marker::Send; - let mut _68: &i32; - scope 2 { - debug b => _7; - let _13: bool; - scope 3 { - debug _val => _13; - let _17: bool; - scope 4 { - debug _val => _17; - let _21: bool; - scope 5 { - debug _val => _21; - let _25: bool; - scope 6 { - debug _val => _25; - let _29: bool; - scope 7 { - debug _val => _29; - let _33: bool; - scope 8 { - debug _val => _33; - let _37: *const [u8]; - scope 9 { - debug a => _37; - let _39: *const [u8]; - scope 11 { - debug b => _39; - } - scope 12 { - } - } - scope 10 { - } - } - } - } - } - } - } - } - } - - bb0: { -- StorageLive(_1); -+ nop; - StorageLive(_2); - StorageLive(_3); - StorageLive(_4); - StorageLive(_5); - _69 = const _; - _5 = &(*_69); - _4 = &(*_5); - _3 = move _4 as &dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_4); - _2 = &raw const (*_3); - _1 = move _2 as *const dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_2); - StorageDead(_5); - StorageDead(_3); -- StorageLive(_7); -+ nop; - StorageLive(_8); - StorageLive(_9); - StorageLive(_10); - StorageLive(_11); - _68 = const _; - _11 = &(*_68); - _10 = &(*_11); - _9 = move _10 as &dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_10); - _8 = &raw const (*_9); - _7 = move _8 as *const dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_8); - StorageDead(_11); - StorageDead(_9); - StorageLive(_13); - StorageLive(_14); - _14 = _1; -- StorageLive(_15); -+ nop; - StorageLive(_16); - _16 = _7; -- _15 = move _16 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _15 = _7 as *const dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_16); -- _13 = Eq(move _14, move _15); -- StorageDead(_15); -+ _13 = Eq(_1, _15); -+ nop; - StorageDead(_14); - StorageLive(_17); - StorageLive(_18); - _18 = _1; - StorageLive(_19); - StorageLive(_20); - _20 = _7; -- _19 = move _20 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _19 = _15; - StorageDead(_20); -- _17 = Ne(move _18, move _19); -+ _17 = Ne(_1, _15); - StorageDead(_19); - StorageDead(_18); - StorageLive(_21); - StorageLive(_22); - _22 = _1; - StorageLive(_23); - StorageLive(_24); - _24 = _7; -- _23 = move _24 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _23 = _15; - StorageDead(_24); -- _21 = Lt(move _22, move _23); -+ _21 = Lt(_1, _15); - StorageDead(_23); - StorageDead(_22); - StorageLive(_25); - StorageLive(_26); - _26 = _1; - StorageLive(_27); - StorageLive(_28); - _28 = _7; -- _27 = move _28 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _27 = _15; - StorageDead(_28); -- _25 = Le(move _26, move _27); -+ _25 = Le(_1, _15); - StorageDead(_27); - StorageDead(_26); - StorageLive(_29); - StorageLive(_30); - _30 = _1; - StorageLive(_31); - StorageLive(_32); - _32 = _7; -- _31 = move _32 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _31 = _15; - StorageDead(_32); -- _29 = Gt(move _30, move _31); -+ _29 = Gt(_1, _15); - StorageDead(_31); - StorageDead(_30); - StorageLive(_33); - StorageLive(_34); - _34 = _1; - StorageLive(_35); - StorageLive(_36); - _36 = _7; -- _35 = move _36 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _35 = _15; - StorageDead(_36); -- _33 = Ge(move _34, move _35); -+ _33 = Ge(_1, _15); - StorageDead(_35); - StorageDead(_34); -- StorageLive(_37); -+ nop; - StorageLive(_38); -- _38 = (const 1_usize, const 1_usize); -- _37 = move _38 as *const [u8] (Transmute); -+ _38 = const (1_usize, 1_usize); -+ _37 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageDead(_38); -- StorageLive(_39); -+ nop; - StorageLive(_40); -- _40 = (const 1_usize, const 2_usize); -- _39 = move _40 as *const [u8] (Transmute); -+ _40 = const (1_usize, 2_usize); -+ _39 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; - StorageDead(_40); - StorageLive(_41); -- StorageLive(_42); -+ nop; - StorageLive(_43); - StorageLive(_44); -- _44 = _37; -+ _44 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_45); -- _45 = _39; -- _43 = Eq(move _44, move _45); -+ _45 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _43 = Eq(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_45); - StorageDead(_44); - _42 = Not(move _43); - StorageDead(_43); -- _41 = opaque::<bool>(move _42) -> [return: bb1, unwind continue]; -+ _41 = opaque::<bool>(_42) -> [return: bb1, unwind continue]; - } - - bb1: { -- StorageDead(_42); -+ nop; - StorageDead(_41); - StorageLive(_46); - StorageLive(_47); - StorageLive(_48); -- _48 = _37; -+ _48 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_49); -- _49 = _39; -- _47 = Ne(move _48, move _49); -+ _49 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _47 = _42; - StorageDead(_49); - StorageDead(_48); -- _46 = opaque::<bool>(move _47) -> [return: bb2, unwind continue]; -+ _46 = opaque::<bool>(_42) -> [return: bb2, unwind continue]; - } - - bb2: { - StorageDead(_47); - StorageDead(_46); - StorageLive(_50); - StorageLive(_51); - StorageLive(_52); -- _52 = _37; -+ _52 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_53); -- _53 = _39; -- _51 = Le(move _52, move _53); -+ _53 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _51 = Le(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_53); - StorageDead(_52); - _50 = opaque::<bool>(move _51) -> [return: bb3, unwind continue]; - } - - bb3: { - StorageDead(_51); - StorageDead(_50); - StorageLive(_54); - StorageLive(_55); - StorageLive(_56); -- _56 = _37; -+ _56 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_57); -- _57 = _39; -- _55 = Lt(move _56, move _57); -+ _57 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _55 = Lt(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_57); - StorageDead(_56); - _54 = opaque::<bool>(move _55) -> [return: bb4, unwind continue]; - } - - bb4: { - StorageDead(_55); - StorageDead(_54); - StorageLive(_58); - StorageLive(_59); - StorageLive(_60); - StorageLive(_61); -- _61 = _37; -+ _61 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_62); -- _62 = _39; -- _60 = Ge(move _61, move _62); -+ _62 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _60 = Ge(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_62); - StorageDead(_61); - _59 = Not(move _60); - StorageDead(_60); - _58 = opaque::<bool>(move _59) -> [return: bb5, unwind continue]; - } - - bb5: { - StorageDead(_59); - StorageDead(_58); - StorageLive(_63); - StorageLive(_64); - StorageLive(_65); - StorageLive(_66); -- _66 = _37; -+ _66 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_67); -- _67 = _39; -- _65 = Gt(move _66, move _67); -+ _67 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _65 = Gt(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_67); - StorageDead(_66); - _64 = Not(move _65); - StorageDead(_65); - _63 = opaque::<bool>(move _64) -> [return: bb6, unwind continue]; - } - - bb6: { - StorageDead(_64); - StorageDead(_63); - _0 = const (); -- StorageDead(_39); -- StorageDead(_37); -+ nop; -+ nop; - StorageDead(_33); - StorageDead(_29); - StorageDead(_25); - StorageDead(_21); - StorageDead(_17); - StorageDead(_13); -- StorageDead(_7); -- StorageDead(_1); -+ nop; -+ nop; - return; - } -+ } -+ -+ ALLOC1 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 │ ................ -+ } -+ -+ ALLOC0 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 │ ................ - } - diff --git a/tests/mir-opt/gvn.wide_ptr_provenance.GVN.panic-abort.diff b/tests/mir-opt/gvn.wide_ptr_provenance.GVN.panic-abort.diff new file mode 100644 index 00000000000..efb3dbec6f2 --- /dev/null +++ b/tests/mir-opt/gvn.wide_ptr_provenance.GVN.panic-abort.diff @@ -0,0 +1,232 @@ +- // MIR for `wide_ptr_provenance` before GVN ++ // MIR for `wide_ptr_provenance` after GVN + + fn wide_ptr_provenance() -> () { + let mut _0: (); + let _1: *const dyn std::marker::Send; + let mut _2: *const dyn std::marker::Send; + let _3: &dyn std::marker::Send; + let mut _4: &i32; + let _5: &i32; + let _6: i32; + let mut _8: *const dyn std::marker::Send; + let _9: &dyn std::marker::Send; + let mut _10: &i32; + let _11: &i32; + let _12: i32; + let _13: (); + let mut _14: bool; + let mut _15: *const dyn std::marker::Send; + let mut _16: *const dyn std::marker::Send; + let mut _17: *const dyn std::marker::Send; + let _18: (); + let mut _19: bool; + let mut _20: *const dyn std::marker::Send; + let mut _21: *const dyn std::marker::Send; + let mut _22: *const dyn std::marker::Send; + let _23: (); + let mut _24: bool; + let mut _25: *const dyn std::marker::Send; + let mut _26: *const dyn std::marker::Send; + let mut _27: *const dyn std::marker::Send; + let _28: (); + let mut _29: bool; + let mut _30: *const dyn std::marker::Send; + let mut _31: *const dyn std::marker::Send; + let mut _32: *const dyn std::marker::Send; + let _33: (); + let mut _34: bool; + let mut _35: *const dyn std::marker::Send; + let mut _36: *const dyn std::marker::Send; + let mut _37: *const dyn std::marker::Send; + let _38: (); + let mut _39: bool; + let mut _40: *const dyn std::marker::Send; + let mut _41: *const dyn std::marker::Send; + let mut _42: *const dyn std::marker::Send; + let mut _44: &i32; + scope 1 { + debug a => _1; + let _7: *const dyn std::marker::Send; + let mut _43: &i32; + scope 2 { + debug b => _7; + } + } + + bb0: { + StorageLive(_1); +- StorageLive(_2); ++ nop; + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); + _44 = const _; + _5 = &(*_44); + _4 = &(*_5); + _3 = move _4 as &dyn std::marker::Send (PointerCoercion(Unsize)); + StorageDead(_4); + _2 = &raw const (*_3); +- _1 = move _2 as *const dyn std::marker::Send (PointerCoercion(Unsize)); +- StorageDead(_2); ++ _1 = _2; ++ nop; + StorageDead(_5); + StorageDead(_3); + StorageLive(_7); +- StorageLive(_8); ++ nop; + StorageLive(_9); + StorageLive(_10); + StorageLive(_11); + _43 = const _; + _11 = &(*_43); + _10 = &(*_11); + _9 = move _10 as &dyn std::marker::Send (PointerCoercion(Unsize)); + StorageDead(_10); + _8 = &raw const (*_9); +- _7 = move _8 as *const dyn std::marker::Send (PointerCoercion(Unsize)); +- StorageDead(_8); ++ _7 = _8; ++ nop; + StorageDead(_11); + StorageDead(_9); + StorageLive(_13); + StorageLive(_14); + StorageLive(_15); +- _15 = _1; ++ _15 = _2; + StorageLive(_16); + StorageLive(_17); +- _17 = _7; +- _16 = move _17 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _17 = _8; ++ _16 = _8; + StorageDead(_17); +- _14 = Eq(move _15, move _16); ++ _14 = Eq(_2, _8); + StorageDead(_16); + StorageDead(_15); + _13 = opaque::<bool>(move _14) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_14); + StorageDead(_13); + StorageLive(_18); + StorageLive(_19); + StorageLive(_20); +- _20 = _1; ++ _20 = _2; + StorageLive(_21); + StorageLive(_22); +- _22 = _7; +- _21 = move _22 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _22 = _8; ++ _21 = _8; + StorageDead(_22); +- _19 = Ne(move _20, move _21); ++ _19 = Ne(_2, _8); + StorageDead(_21); + StorageDead(_20); + _18 = opaque::<bool>(move _19) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_19); + StorageDead(_18); + StorageLive(_23); + StorageLive(_24); + StorageLive(_25); +- _25 = _1; ++ _25 = _2; + StorageLive(_26); + StorageLive(_27); +- _27 = _7; +- _26 = move _27 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _27 = _8; ++ _26 = _8; + StorageDead(_27); +- _24 = Lt(move _25, move _26); ++ _24 = Lt(_2, _8); + StorageDead(_26); + StorageDead(_25); + _23 = opaque::<bool>(move _24) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_24); + StorageDead(_23); + StorageLive(_28); + StorageLive(_29); + StorageLive(_30); +- _30 = _1; ++ _30 = _2; + StorageLive(_31); + StorageLive(_32); +- _32 = _7; +- _31 = move _32 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _32 = _8; ++ _31 = _8; + StorageDead(_32); +- _29 = Le(move _30, move _31); ++ _29 = Le(_2, _8); + StorageDead(_31); + StorageDead(_30); + _28 = opaque::<bool>(move _29) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_29); + StorageDead(_28); + StorageLive(_33); + StorageLive(_34); + StorageLive(_35); +- _35 = _1; ++ _35 = _2; + StorageLive(_36); + StorageLive(_37); +- _37 = _7; +- _36 = move _37 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _37 = _8; ++ _36 = _8; + StorageDead(_37); +- _34 = Gt(move _35, move _36); ++ _34 = Gt(_2, _8); + StorageDead(_36); + StorageDead(_35); + _33 = opaque::<bool>(move _34) -> [return: bb5, unwind unreachable]; + } + + bb5: { + StorageDead(_34); + StorageDead(_33); + StorageLive(_38); + StorageLive(_39); + StorageLive(_40); +- _40 = _1; ++ _40 = _2; + StorageLive(_41); + StorageLive(_42); +- _42 = _7; +- _41 = move _42 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _42 = _8; ++ _41 = _8; + StorageDead(_42); +- _39 = Ge(move _40, move _41); ++ _39 = Ge(_2, _8); + StorageDead(_41); + StorageDead(_40); + _38 = opaque::<bool>(move _39) -> [return: bb6, unwind unreachable]; + } + + bb6: { + StorageDead(_39); + StorageDead(_38); + _0 = const (); + StorageDead(_7); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/gvn.wide_ptr_provenance.GVN.panic-unwind.diff b/tests/mir-opt/gvn.wide_ptr_provenance.GVN.panic-unwind.diff new file mode 100644 index 00000000000..ce8415e75ea --- /dev/null +++ b/tests/mir-opt/gvn.wide_ptr_provenance.GVN.panic-unwind.diff @@ -0,0 +1,232 @@ +- // MIR for `wide_ptr_provenance` before GVN ++ // MIR for `wide_ptr_provenance` after GVN + + fn wide_ptr_provenance() -> () { + let mut _0: (); + let _1: *const dyn std::marker::Send; + let mut _2: *const dyn std::marker::Send; + let _3: &dyn std::marker::Send; + let mut _4: &i32; + let _5: &i32; + let _6: i32; + let mut _8: *const dyn std::marker::Send; + let _9: &dyn std::marker::Send; + let mut _10: &i32; + let _11: &i32; + let _12: i32; + let _13: (); + let mut _14: bool; + let mut _15: *const dyn std::marker::Send; + let mut _16: *const dyn std::marker::Send; + let mut _17: *const dyn std::marker::Send; + let _18: (); + let mut _19: bool; + let mut _20: *const dyn std::marker::Send; + let mut _21: *const dyn std::marker::Send; + let mut _22: *const dyn std::marker::Send; + let _23: (); + let mut _24: bool; + let mut _25: *const dyn std::marker::Send; + let mut _26: *const dyn std::marker::Send; + let mut _27: *const dyn std::marker::Send; + let _28: (); + let mut _29: bool; + let mut _30: *const dyn std::marker::Send; + let mut _31: *const dyn std::marker::Send; + let mut _32: *const dyn std::marker::Send; + let _33: (); + let mut _34: bool; + let mut _35: *const dyn std::marker::Send; + let mut _36: *const dyn std::marker::Send; + let mut _37: *const dyn std::marker::Send; + let _38: (); + let mut _39: bool; + let mut _40: *const dyn std::marker::Send; + let mut _41: *const dyn std::marker::Send; + let mut _42: *const dyn std::marker::Send; + let mut _44: &i32; + scope 1 { + debug a => _1; + let _7: *const dyn std::marker::Send; + let mut _43: &i32; + scope 2 { + debug b => _7; + } + } + + bb0: { + StorageLive(_1); +- StorageLive(_2); ++ nop; + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); + _44 = const _; + _5 = &(*_44); + _4 = &(*_5); + _3 = move _4 as &dyn std::marker::Send (PointerCoercion(Unsize)); + StorageDead(_4); + _2 = &raw const (*_3); +- _1 = move _2 as *const dyn std::marker::Send (PointerCoercion(Unsize)); +- StorageDead(_2); ++ _1 = _2; ++ nop; + StorageDead(_5); + StorageDead(_3); + StorageLive(_7); +- StorageLive(_8); ++ nop; + StorageLive(_9); + StorageLive(_10); + StorageLive(_11); + _43 = const _; + _11 = &(*_43); + _10 = &(*_11); + _9 = move _10 as &dyn std::marker::Send (PointerCoercion(Unsize)); + StorageDead(_10); + _8 = &raw const (*_9); +- _7 = move _8 as *const dyn std::marker::Send (PointerCoercion(Unsize)); +- StorageDead(_8); ++ _7 = _8; ++ nop; + StorageDead(_11); + StorageDead(_9); + StorageLive(_13); + StorageLive(_14); + StorageLive(_15); +- _15 = _1; ++ _15 = _2; + StorageLive(_16); + StorageLive(_17); +- _17 = _7; +- _16 = move _17 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _17 = _8; ++ _16 = _8; + StorageDead(_17); +- _14 = Eq(move _15, move _16); ++ _14 = Eq(_2, _8); + StorageDead(_16); + StorageDead(_15); + _13 = opaque::<bool>(move _14) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_14); + StorageDead(_13); + StorageLive(_18); + StorageLive(_19); + StorageLive(_20); +- _20 = _1; ++ _20 = _2; + StorageLive(_21); + StorageLive(_22); +- _22 = _7; +- _21 = move _22 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _22 = _8; ++ _21 = _8; + StorageDead(_22); +- _19 = Ne(move _20, move _21); ++ _19 = Ne(_2, _8); + StorageDead(_21); + StorageDead(_20); + _18 = opaque::<bool>(move _19) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_19); + StorageDead(_18); + StorageLive(_23); + StorageLive(_24); + StorageLive(_25); +- _25 = _1; ++ _25 = _2; + StorageLive(_26); + StorageLive(_27); +- _27 = _7; +- _26 = move _27 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _27 = _8; ++ _26 = _8; + StorageDead(_27); +- _24 = Lt(move _25, move _26); ++ _24 = Lt(_2, _8); + StorageDead(_26); + StorageDead(_25); + _23 = opaque::<bool>(move _24) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_24); + StorageDead(_23); + StorageLive(_28); + StorageLive(_29); + StorageLive(_30); +- _30 = _1; ++ _30 = _2; + StorageLive(_31); + StorageLive(_32); +- _32 = _7; +- _31 = move _32 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _32 = _8; ++ _31 = _8; + StorageDead(_32); +- _29 = Le(move _30, move _31); ++ _29 = Le(_2, _8); + StorageDead(_31); + StorageDead(_30); + _28 = opaque::<bool>(move _29) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_29); + StorageDead(_28); + StorageLive(_33); + StorageLive(_34); + StorageLive(_35); +- _35 = _1; ++ _35 = _2; + StorageLive(_36); + StorageLive(_37); +- _37 = _7; +- _36 = move _37 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _37 = _8; ++ _36 = _8; + StorageDead(_37); +- _34 = Gt(move _35, move _36); ++ _34 = Gt(_2, _8); + StorageDead(_36); + StorageDead(_35); + _33 = opaque::<bool>(move _34) -> [return: bb5, unwind continue]; + } + + bb5: { + StorageDead(_34); + StorageDead(_33); + StorageLive(_38); + StorageLive(_39); + StorageLive(_40); +- _40 = _1; ++ _40 = _2; + StorageLive(_41); + StorageLive(_42); +- _42 = _7; +- _41 = move _42 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _42 = _8; ++ _41 = _8; + StorageDead(_42); +- _39 = Ge(move _40, move _41); ++ _39 = Ge(_2, _8); + StorageDead(_41); + StorageDead(_40); + _38 = opaque::<bool>(move _39) -> [return: bb6, unwind continue]; + } + + bb6: { + StorageDead(_39); + StorageDead(_38); + _0 = const (); + StorageDead(_7); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/gvn.wide_ptr_same_provenance.GVN.panic-abort.diff b/tests/mir-opt/gvn.wide_ptr_same_provenance.GVN.panic-abort.diff new file mode 100644 index 00000000000..ef211ce3da2 --- /dev/null +++ b/tests/mir-opt/gvn.wide_ptr_same_provenance.GVN.panic-abort.diff @@ -0,0 +1,268 @@ +- // MIR for `wide_ptr_same_provenance` before GVN ++ // MIR for `wide_ptr_same_provenance` after GVN + + fn wide_ptr_same_provenance() -> () { + let mut _0: (); + let _1: &[i32; 2]; + let _2: [i32; 2]; + let mut _4: *const dyn std::marker::Send; + let _5: &dyn std::marker::Send; + let mut _6: &i32; + let _7: &i32; + let _8: usize; + let mut _9: usize; + let mut _10: bool; + let mut _12: *const dyn std::marker::Send; + let _13: &dyn std::marker::Send; + let mut _14: &i32; + let _15: &i32; + let _16: usize; + let mut _17: usize; + let mut _18: bool; + let _19: (); + let mut _20: bool; + let mut _21: *const dyn std::marker::Send; + let mut _22: *const dyn std::marker::Send; + let mut _23: *const dyn std::marker::Send; + let _24: (); + let mut _25: bool; + let mut _26: *const dyn std::marker::Send; + let mut _27: *const dyn std::marker::Send; + let mut _28: *const dyn std::marker::Send; + let _29: (); + let mut _30: bool; + let mut _31: *const dyn std::marker::Send; + let mut _32: *const dyn std::marker::Send; + let mut _33: *const dyn std::marker::Send; + let _34: (); + let mut _35: bool; + let mut _36: *const dyn std::marker::Send; + let mut _37: *const dyn std::marker::Send; + let mut _38: *const dyn std::marker::Send; + let _39: (); + let mut _40: bool; + let mut _41: *const dyn std::marker::Send; + let mut _42: *const dyn std::marker::Send; + let mut _43: *const dyn std::marker::Send; + let _44: (); + let mut _45: bool; + let mut _46: *const dyn std::marker::Send; + let mut _47: *const dyn std::marker::Send; + let mut _48: *const dyn std::marker::Send; + let mut _49: &[i32; 2]; + scope 1 { + debug slice => _1; + let _3: *const dyn std::marker::Send; + scope 2 { + debug a => _3; + let _11: *const dyn std::marker::Send; + scope 3 { + debug b => _11; + } + } + } + + bb0: { + StorageLive(_1); + _49 = const _; + _1 = &(*_49); + StorageLive(_3); +- StorageLive(_4); ++ nop; + StorageLive(_5); + StorageLive(_6); + StorageLive(_7); + StorageLive(_8); + _8 = const 0_usize; +- _9 = Len((*_1)); +- _10 = Lt(_8, _9); +- assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> [success: bb1, unwind unreachable]; ++ _9 = const 2_usize; ++ _10 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 2_usize, const 0_usize) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _7 = &(*_1)[_8]; ++ _7 = &(*_1)[0 of 1]; + _6 = &(*_7); + _5 = move _6 as &dyn std::marker::Send (PointerCoercion(Unsize)); + StorageDead(_6); + _4 = &raw const (*_5); +- _3 = move _4 as *const dyn std::marker::Send (PointerCoercion(Unsize)); +- StorageDead(_4); ++ _3 = _4; ++ nop; + StorageDead(_7); + StorageDead(_5); + StorageLive(_11); +- StorageLive(_12); ++ nop; + StorageLive(_13); + StorageLive(_14); + StorageLive(_15); + StorageLive(_16); + _16 = const 1_usize; +- _17 = Len((*_1)); +- _18 = Lt(_16, _17); +- assert(move _18, "index out of bounds: the length is {} but the index is {}", move _17, _16) -> [success: bb2, unwind unreachable]; ++ _17 = const 2_usize; ++ _18 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 2_usize, const 1_usize) -> [success: bb2, unwind unreachable]; + } + + bb2: { +- _15 = &(*_1)[_16]; ++ _15 = &(*_1)[1 of 2]; + _14 = &(*_15); + _13 = move _14 as &dyn std::marker::Send (PointerCoercion(Unsize)); + StorageDead(_14); + _12 = &raw const (*_13); +- _11 = move _12 as *const dyn std::marker::Send (PointerCoercion(Unsize)); +- StorageDead(_12); ++ _11 = _12; ++ nop; + StorageDead(_15); + StorageDead(_13); + StorageLive(_19); + StorageLive(_20); + StorageLive(_21); +- _21 = _3; ++ _21 = _4; + StorageLive(_22); + StorageLive(_23); +- _23 = _11; +- _22 = move _23 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _23 = _12; ++ _22 = _12; + StorageDead(_23); +- _20 = Eq(move _21, move _22); ++ _20 = Eq(_4, _12); + StorageDead(_22); + StorageDead(_21); + _19 = opaque::<bool>(move _20) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_20); + StorageDead(_19); + StorageLive(_24); + StorageLive(_25); + StorageLive(_26); +- _26 = _3; ++ _26 = _4; + StorageLive(_27); + StorageLive(_28); +- _28 = _11; +- _27 = move _28 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _28 = _12; ++ _27 = _12; + StorageDead(_28); +- _25 = Ne(move _26, move _27); ++ _25 = Ne(_4, _12); + StorageDead(_27); + StorageDead(_26); + _24 = opaque::<bool>(move _25) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_25); + StorageDead(_24); + StorageLive(_29); + StorageLive(_30); + StorageLive(_31); +- _31 = _3; ++ _31 = _4; + StorageLive(_32); + StorageLive(_33); +- _33 = _11; +- _32 = move _33 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _33 = _12; ++ _32 = _12; + StorageDead(_33); +- _30 = Lt(move _31, move _32); ++ _30 = Lt(_4, _12); + StorageDead(_32); + StorageDead(_31); + _29 = opaque::<bool>(move _30) -> [return: bb5, unwind unreachable]; + } + + bb5: { + StorageDead(_30); + StorageDead(_29); + StorageLive(_34); + StorageLive(_35); + StorageLive(_36); +- _36 = _3; ++ _36 = _4; + StorageLive(_37); + StorageLive(_38); +- _38 = _11; +- _37 = move _38 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _38 = _12; ++ _37 = _12; + StorageDead(_38); +- _35 = Le(move _36, move _37); ++ _35 = Le(_4, _12); + StorageDead(_37); + StorageDead(_36); + _34 = opaque::<bool>(move _35) -> [return: bb6, unwind unreachable]; + } + + bb6: { + StorageDead(_35); + StorageDead(_34); + StorageLive(_39); + StorageLive(_40); + StorageLive(_41); +- _41 = _3; ++ _41 = _4; + StorageLive(_42); + StorageLive(_43); +- _43 = _11; +- _42 = move _43 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _43 = _12; ++ _42 = _12; + StorageDead(_43); +- _40 = Gt(move _41, move _42); ++ _40 = Gt(_4, _12); + StorageDead(_42); + StorageDead(_41); + _39 = opaque::<bool>(move _40) -> [return: bb7, unwind unreachable]; + } + + bb7: { + StorageDead(_40); + StorageDead(_39); + StorageLive(_44); + StorageLive(_45); + StorageLive(_46); +- _46 = _3; ++ _46 = _4; + StorageLive(_47); + StorageLive(_48); +- _48 = _11; +- _47 = move _48 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _48 = _12; ++ _47 = _12; + StorageDead(_48); +- _45 = Ge(move _46, move _47); ++ _45 = Ge(_4, _12); + StorageDead(_47); + StorageDead(_46); + _44 = opaque::<bool>(move _45) -> [return: bb8, unwind unreachable]; + } + + bb8: { + StorageDead(_45); + StorageDead(_44); + _0 = const (); + StorageDead(_16); + StorageDead(_11); + StorageDead(_8); + StorageDead(_3); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/gvn.wide_ptr_same_provenance.GVN.panic-unwind.diff b/tests/mir-opt/gvn.wide_ptr_same_provenance.GVN.panic-unwind.diff new file mode 100644 index 00000000000..31f7371ac33 --- /dev/null +++ b/tests/mir-opt/gvn.wide_ptr_same_provenance.GVN.panic-unwind.diff @@ -0,0 +1,268 @@ +- // MIR for `wide_ptr_same_provenance` before GVN ++ // MIR for `wide_ptr_same_provenance` after GVN + + fn wide_ptr_same_provenance() -> () { + let mut _0: (); + let _1: &[i32; 2]; + let _2: [i32; 2]; + let mut _4: *const dyn std::marker::Send; + let _5: &dyn std::marker::Send; + let mut _6: &i32; + let _7: &i32; + let _8: usize; + let mut _9: usize; + let mut _10: bool; + let mut _12: *const dyn std::marker::Send; + let _13: &dyn std::marker::Send; + let mut _14: &i32; + let _15: &i32; + let _16: usize; + let mut _17: usize; + let mut _18: bool; + let _19: (); + let mut _20: bool; + let mut _21: *const dyn std::marker::Send; + let mut _22: *const dyn std::marker::Send; + let mut _23: *const dyn std::marker::Send; + let _24: (); + let mut _25: bool; + let mut _26: *const dyn std::marker::Send; + let mut _27: *const dyn std::marker::Send; + let mut _28: *const dyn std::marker::Send; + let _29: (); + let mut _30: bool; + let mut _31: *const dyn std::marker::Send; + let mut _32: *const dyn std::marker::Send; + let mut _33: *const dyn std::marker::Send; + let _34: (); + let mut _35: bool; + let mut _36: *const dyn std::marker::Send; + let mut _37: *const dyn std::marker::Send; + let mut _38: *const dyn std::marker::Send; + let _39: (); + let mut _40: bool; + let mut _41: *const dyn std::marker::Send; + let mut _42: *const dyn std::marker::Send; + let mut _43: *const dyn std::marker::Send; + let _44: (); + let mut _45: bool; + let mut _46: *const dyn std::marker::Send; + let mut _47: *const dyn std::marker::Send; + let mut _48: *const dyn std::marker::Send; + let mut _49: &[i32; 2]; + scope 1 { + debug slice => _1; + let _3: *const dyn std::marker::Send; + scope 2 { + debug a => _3; + let _11: *const dyn std::marker::Send; + scope 3 { + debug b => _11; + } + } + } + + bb0: { + StorageLive(_1); + _49 = const _; + _1 = &(*_49); + StorageLive(_3); +- StorageLive(_4); ++ nop; + StorageLive(_5); + StorageLive(_6); + StorageLive(_7); + StorageLive(_8); + _8 = const 0_usize; +- _9 = Len((*_1)); +- _10 = Lt(_8, _9); +- assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> [success: bb1, unwind continue]; ++ _9 = const 2_usize; ++ _10 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 2_usize, const 0_usize) -> [success: bb1, unwind continue]; + } + + bb1: { +- _7 = &(*_1)[_8]; ++ _7 = &(*_1)[0 of 1]; + _6 = &(*_7); + _5 = move _6 as &dyn std::marker::Send (PointerCoercion(Unsize)); + StorageDead(_6); + _4 = &raw const (*_5); +- _3 = move _4 as *const dyn std::marker::Send (PointerCoercion(Unsize)); +- StorageDead(_4); ++ _3 = _4; ++ nop; + StorageDead(_7); + StorageDead(_5); + StorageLive(_11); +- StorageLive(_12); ++ nop; + StorageLive(_13); + StorageLive(_14); + StorageLive(_15); + StorageLive(_16); + _16 = const 1_usize; +- _17 = Len((*_1)); +- _18 = Lt(_16, _17); +- assert(move _18, "index out of bounds: the length is {} but the index is {}", move _17, _16) -> [success: bb2, unwind continue]; ++ _17 = const 2_usize; ++ _18 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 2_usize, const 1_usize) -> [success: bb2, unwind continue]; + } + + bb2: { +- _15 = &(*_1)[_16]; ++ _15 = &(*_1)[1 of 2]; + _14 = &(*_15); + _13 = move _14 as &dyn std::marker::Send (PointerCoercion(Unsize)); + StorageDead(_14); + _12 = &raw const (*_13); +- _11 = move _12 as *const dyn std::marker::Send (PointerCoercion(Unsize)); +- StorageDead(_12); ++ _11 = _12; ++ nop; + StorageDead(_15); + StorageDead(_13); + StorageLive(_19); + StorageLive(_20); + StorageLive(_21); +- _21 = _3; ++ _21 = _4; + StorageLive(_22); + StorageLive(_23); +- _23 = _11; +- _22 = move _23 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _23 = _12; ++ _22 = _12; + StorageDead(_23); +- _20 = Eq(move _21, move _22); ++ _20 = Eq(_4, _12); + StorageDead(_22); + StorageDead(_21); + _19 = opaque::<bool>(move _20) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_20); + StorageDead(_19); + StorageLive(_24); + StorageLive(_25); + StorageLive(_26); +- _26 = _3; ++ _26 = _4; + StorageLive(_27); + StorageLive(_28); +- _28 = _11; +- _27 = move _28 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _28 = _12; ++ _27 = _12; + StorageDead(_28); +- _25 = Ne(move _26, move _27); ++ _25 = Ne(_4, _12); + StorageDead(_27); + StorageDead(_26); + _24 = opaque::<bool>(move _25) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_25); + StorageDead(_24); + StorageLive(_29); + StorageLive(_30); + StorageLive(_31); +- _31 = _3; ++ _31 = _4; + StorageLive(_32); + StorageLive(_33); +- _33 = _11; +- _32 = move _33 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _33 = _12; ++ _32 = _12; + StorageDead(_33); +- _30 = Lt(move _31, move _32); ++ _30 = Lt(_4, _12); + StorageDead(_32); + StorageDead(_31); + _29 = opaque::<bool>(move _30) -> [return: bb5, unwind continue]; + } + + bb5: { + StorageDead(_30); + StorageDead(_29); + StorageLive(_34); + StorageLive(_35); + StorageLive(_36); +- _36 = _3; ++ _36 = _4; + StorageLive(_37); + StorageLive(_38); +- _38 = _11; +- _37 = move _38 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _38 = _12; ++ _37 = _12; + StorageDead(_38); +- _35 = Le(move _36, move _37); ++ _35 = Le(_4, _12); + StorageDead(_37); + StorageDead(_36); + _34 = opaque::<bool>(move _35) -> [return: bb6, unwind continue]; + } + + bb6: { + StorageDead(_35); + StorageDead(_34); + StorageLive(_39); + StorageLive(_40); + StorageLive(_41); +- _41 = _3; ++ _41 = _4; + StorageLive(_42); + StorageLive(_43); +- _43 = _11; +- _42 = move _43 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _43 = _12; ++ _42 = _12; + StorageDead(_43); +- _40 = Gt(move _41, move _42); ++ _40 = Gt(_4, _12); + StorageDead(_42); + StorageDead(_41); + _39 = opaque::<bool>(move _40) -> [return: bb7, unwind continue]; + } + + bb7: { + StorageDead(_40); + StorageDead(_39); + StorageLive(_44); + StorageLive(_45); + StorageLive(_46); +- _46 = _3; ++ _46 = _4; + StorageLive(_47); + StorageLive(_48); +- _48 = _11; +- _47 = move _48 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _48 = _12; ++ _47 = _12; + StorageDead(_48); +- _45 = Ge(move _46, move _47); ++ _45 = Ge(_4, _12); + StorageDead(_47); + StorageDead(_46); + _44 = opaque::<bool>(move _45) -> [return: bb8, unwind continue]; + } + + bb8: { + StorageDead(_45); + StorageDead(_44); + _0 = const (); + StorageDead(_16); + StorageDead(_11); + StorageDead(_8); + StorageDead(_3); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff index de9a1a075ad..4c71a4358e7 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff @@ -111,12 +111,16 @@ StorageDead(_15); StorageDead(_12); StorageDead(_6); - StorageLive(_18); +- StorageLive(_18); ++ nop; _18 = (_5.0: *const [u8]); - _4 = move _18 as *mut [u8] (PtrToPtr); - StorageDead(_18); +- _4 = move _18 as *mut [u8] (PtrToPtr); +- StorageDead(_18); ++ _4 = _18 as *mut [u8] (PtrToPtr); ++ nop; StorageDead(_5); - _3 = move _4 as *mut u8 (PtrToPtr); +- _3 = move _4 as *mut u8 (PtrToPtr); ++ _3 = _18 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); - StorageDead(_1); diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff index f784db0f409..44de4f8e98a 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff @@ -50,12 +50,16 @@ bb1: { StorageDead(_6); - StorageLive(_12); +- StorageLive(_12); ++ nop; _12 = (_5.0: *const [u8]); - _4 = move _12 as *mut [u8] (PtrToPtr); - StorageDead(_12); +- _4 = move _12 as *mut [u8] (PtrToPtr); +- StorageDead(_12); ++ _4 = _12 as *mut [u8] (PtrToPtr); ++ nop; StorageDead(_5); - _3 = move _4 as *mut u8 (PtrToPtr); +- _3 = move _4 as *mut u8 (PtrToPtr); ++ _3 = _12 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); - StorageDead(_1); diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff index 162b7fa4618..e27a96a4018 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff @@ -111,12 +111,16 @@ StorageDead(_15); StorageDead(_12); StorageDead(_6); - StorageLive(_18); +- StorageLive(_18); ++ nop; _18 = (_5.0: *const [u8]); - _4 = move _18 as *mut [u8] (PtrToPtr); - StorageDead(_18); +- _4 = move _18 as *mut [u8] (PtrToPtr); +- StorageDead(_18); ++ _4 = _18 as *mut [u8] (PtrToPtr); ++ nop; StorageDead(_5); - _3 = move _4 as *mut u8 (PtrToPtr); +- _3 = move _4 as *mut u8 (PtrToPtr); ++ _3 = _18 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); - StorageDead(_1); diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff index 400aac6d64b..6145f92a075 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff @@ -50,12 +50,16 @@ bb1: { StorageDead(_6); - StorageLive(_12); +- StorageLive(_12); ++ nop; _12 = (_5.0: *const [u8]); - _4 = move _12 as *mut [u8] (PtrToPtr); - StorageDead(_12); +- _4 = move _12 as *mut [u8] (PtrToPtr); +- StorageDead(_12); ++ _4 = _12 as *mut [u8] (PtrToPtr); ++ nop; StorageDead(_5); - _3 = move _4 as *mut u8 (PtrToPtr); +- _3 = move _4 as *mut u8 (PtrToPtr); ++ _3 = _12 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); - StorageDead(_1); diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir index dc37c1b4cbf..2fdc21d636f 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir @@ -89,7 +89,7 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> StorageLive(_12); StorageLive(_11); StorageLive(_10); - _10 = _9 as *const () (PointerCoercion(MutToConstPointer)); + _10 = _8 as *const () (PtrToPtr); _11 = std::ptr::metadata::PtrComponents::<[u32]> { data_pointer: move _10, metadata: _6 }; StorageDead(_10); _12 = std::ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _11 }; diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir index dc37c1b4cbf..2fdc21d636f 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir @@ -89,7 +89,7 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> StorageLive(_12); StorageLive(_11); StorageLive(_10); - _10 = _9 as *const () (PointerCoercion(MutToConstPointer)); + _10 = _8 as *const () (PtrToPtr); _11 = std::ptr::metadata::PtrComponents::<[u32]> { data_pointer: move _10, metadata: _6 }; StorageDead(_10); _12 = std::ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _11 }; diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir index 4906c86f8ed..05b01404b69 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir @@ -4,22 +4,22 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _15: std::slice::Iter<'_, T>; - let mut _16: std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _17: std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _18: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _19: std::option::Option<(usize, &T)>; - let mut _20: isize; - let mut _23: &impl Fn(usize, &T); - let mut _24: (usize, &T); - let _25: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::iter::Enumerate<std::slice::Iter<'_, T>>; + let mut _15: std::iter::Enumerate<std::slice::Iter<'_, T>>; + let mut _16: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>; + let mut _17: std::option::Option<(usize, &T)>; + let mut _18: isize; + let mut _21: &impl Fn(usize, &T); + let mut _22: (usize, &T); + let _23: (); scope 1 { - debug iter => _17; - let _21: usize; - let _22: &T; + debug iter => _15; + let _19: usize; + let _20: &T; scope 2 { - debug i => _21; - debug x => _22; + debug i => _19; + debug x => _20; } } scope 3 (inlined core::slice::<impl [T]>::iter) { @@ -28,19 +28,19 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug slice => _1; let _3: usize; let mut _5: std::ptr::NonNull<[T]>; - let mut _10: bool; - let mut _11: *mut T; - let mut _12: *mut T; - let mut _14: *const T; + let mut _8: bool; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { debug len => _3; - let _9: std::ptr::NonNull<T>; + let _7: std::ptr::NonNull<T>; scope 6 { - debug ptr => _9; + debug ptr => _7; scope 7 { - let _13: *const T; + let _11: *const T; scope 8 { - debug end_or_len => _13; + debug end_or_len => _11; } scope 14 (inlined invalid::<T>) { debug addr => _3; @@ -48,10 +48,10 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 16 (inlined NonNull::<T>::as_ptr) { - debug self => _9; + debug self => _7; } scope 17 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _11; + debug self => _9; debug count => _3; scope 18 { } @@ -66,9 +66,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } scope 11 (inlined NonNull::<[T]>::cast::<T>) { debug self => _5; - let mut _6: *mut [T]; - let mut _7: *mut T; - let mut _8: *const T; + let mut _6: *const T; scope 12 { scope 13 (inlined NonNull::<[T]>::as_ptr) { debug self => _5; @@ -79,90 +77,84 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 19 (inlined <std::slice::Iter<'_, T> as Iterator>::enumerate) { - debug self => _15; + debug self => _13; scope 20 (inlined Enumerate::<std::slice::Iter<'_, T>>::new) { - debug iter => _15; + debug iter => _13; } } scope 21 (inlined <Enumerate<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) { - debug self => _16; + debug self => _14; } bb0: { - StorageLive(_15); + StorageLive(_13); StorageLive(_3); - StorageLive(_9); + StorageLive(_7); StorageLive(_4); - StorageLive(_8); + StorageLive(_6); _3 = Len((*_1)); StorageLive(_5); _4 = &raw const (*_1); _5 = NonNull::<[T]> { pointer: _4 }; - StorageLive(_7); - StorageLive(_6); - _6 = _4 as *mut [T] (PtrToPtr); - _7 = move _6 as *mut T (PtrToPtr); - _8 = move _7 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_6); - StorageDead(_7); - _9 = NonNull::<T> { pointer: _8 }; + _6 = _4 as *const T (PtrToPtr); + _7 = NonNull::<T> { pointer: _6 }; StorageDead(_5); - StorageLive(_13); - StorageLive(_10); - _10 = const _; - switchInt(move _10) -> [0: bb1, otherwise: bb2]; + StorageLive(_11); + StorageLive(_8); + _8 = const _; + switchInt(move _8) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_12); - StorageLive(_11); - _11 = _8 as *mut T (PtrToPtr); - _12 = Offset(_11, _3); - StorageDead(_11); - _13 = move _12 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_12); + StorageLive(_10); + StorageLive(_9); + _9 = _4 as *mut T (PtrToPtr); + _10 = Offset(_9, _3); + StorageDead(_9); + _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); + StorageDead(_10); goto -> bb3; } bb2: { - _13 = _3 as *const T (Transmute); + _11 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_10); - StorageLive(_14); - _14 = _13; - _15 = std::slice::Iter::<'_, T> { ptr: _9, end_or_len: move _14, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_14); - StorageDead(_13); StorageDead(_8); + StorageLive(_12); + _12 = _11; + _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); + StorageDead(_11); + StorageDead(_6); StorageDead(_4); - StorageDead(_9); + StorageDead(_7); StorageDead(_3); - _16 = Enumerate::<std::slice::Iter<'_, T>> { iter: _15, count: const 0_usize }; - StorageDead(_15); - StorageLive(_17); - _17 = _16; + _14 = Enumerate::<std::slice::Iter<'_, T>> { iter: _13, count: const 0_usize }; + StorageDead(_13); + StorageLive(_15); + _15 = _14; goto -> bb4; } bb4: { - StorageLive(_19); - StorageLive(_18); - _18 = &mut _17; - _19 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _18) -> [return: bb5, unwind unreachable]; + StorageLive(_17); + StorageLive(_16); + _16 = &mut _15; + _17 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _16) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_18); - _20 = discriminant(_19); - switchInt(move _20) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_16); + _18 = discriminant(_17); + switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_19); StorageDead(_17); + StorageDead(_15); drop(_2) -> [return: bb7, unwind unreachable]; } @@ -171,19 +163,19 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb8: { - _21 = (((_19 as Some).0: (usize, &T)).0: usize); - _22 = (((_19 as Some).0: (usize, &T)).1: &T); - StorageLive(_23); - _23 = &_2; - StorageLive(_24); - _24 = (_21, _22); - _25 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _23, move _24) -> [return: bb9, unwind unreachable]; + _19 = (((_17 as Some).0: (usize, &T)).0: usize); + _20 = (((_17 as Some).0: (usize, &T)).1: &T); + StorageLive(_21); + _21 = &_2; + StorageLive(_22); + _22 = (_19, _20); + _23 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _21, move _22) -> [return: bb9, unwind unreachable]; } bb9: { - StorageDead(_24); - StorageDead(_23); - StorageDead(_19); + StorageDead(_22); + StorageDead(_21); + StorageDead(_17); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir index 25a5ecdc6c3..1fb29f5c662 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir @@ -4,22 +4,22 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _15: std::slice::Iter<'_, T>; - let mut _16: std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _17: std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _18: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _19: std::option::Option<(usize, &T)>; - let mut _20: isize; - let mut _23: &impl Fn(usize, &T); - let mut _24: (usize, &T); - let _25: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::iter::Enumerate<std::slice::Iter<'_, T>>; + let mut _15: std::iter::Enumerate<std::slice::Iter<'_, T>>; + let mut _16: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>; + let mut _17: std::option::Option<(usize, &T)>; + let mut _18: isize; + let mut _21: &impl Fn(usize, &T); + let mut _22: (usize, &T); + let _23: (); scope 1 { - debug iter => _17; - let _21: usize; - let _22: &T; + debug iter => _15; + let _19: usize; + let _20: &T; scope 2 { - debug i => _21; - debug x => _22; + debug i => _19; + debug x => _20; } } scope 3 (inlined core::slice::<impl [T]>::iter) { @@ -28,19 +28,19 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug slice => _1; let _3: usize; let mut _5: std::ptr::NonNull<[T]>; - let mut _10: bool; - let mut _11: *mut T; - let mut _12: *mut T; - let mut _14: *const T; + let mut _8: bool; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { debug len => _3; - let _9: std::ptr::NonNull<T>; + let _7: std::ptr::NonNull<T>; scope 6 { - debug ptr => _9; + debug ptr => _7; scope 7 { - let _13: *const T; + let _11: *const T; scope 8 { - debug end_or_len => _13; + debug end_or_len => _11; } scope 14 (inlined invalid::<T>) { debug addr => _3; @@ -48,10 +48,10 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 16 (inlined NonNull::<T>::as_ptr) { - debug self => _9; + debug self => _7; } scope 17 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _11; + debug self => _9; debug count => _3; scope 18 { } @@ -66,9 +66,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } scope 11 (inlined NonNull::<[T]>::cast::<T>) { debug self => _5; - let mut _6: *mut [T]; - let mut _7: *mut T; - let mut _8: *const T; + let mut _6: *const T; scope 12 { scope 13 (inlined NonNull::<[T]>::as_ptr) { debug self => _5; @@ -79,90 +77,84 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 19 (inlined <std::slice::Iter<'_, T> as Iterator>::enumerate) { - debug self => _15; + debug self => _13; scope 20 (inlined Enumerate::<std::slice::Iter<'_, T>>::new) { - debug iter => _15; + debug iter => _13; } } scope 21 (inlined <Enumerate<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) { - debug self => _16; + debug self => _14; } bb0: { - StorageLive(_15); + StorageLive(_13); StorageLive(_3); - StorageLive(_9); + StorageLive(_7); StorageLive(_4); - StorageLive(_8); + StorageLive(_6); _3 = Len((*_1)); StorageLive(_5); _4 = &raw const (*_1); _5 = NonNull::<[T]> { pointer: _4 }; - StorageLive(_7); - StorageLive(_6); - _6 = _4 as *mut [T] (PtrToPtr); - _7 = move _6 as *mut T (PtrToPtr); - _8 = move _7 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_6); - StorageDead(_7); - _9 = NonNull::<T> { pointer: _8 }; + _6 = _4 as *const T (PtrToPtr); + _7 = NonNull::<T> { pointer: _6 }; StorageDead(_5); - StorageLive(_13); - StorageLive(_10); - _10 = const _; - switchInt(move _10) -> [0: bb1, otherwise: bb2]; + StorageLive(_11); + StorageLive(_8); + _8 = const _; + switchInt(move _8) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_12); - StorageLive(_11); - _11 = _8 as *mut T (PtrToPtr); - _12 = Offset(_11, _3); - StorageDead(_11); - _13 = move _12 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_12); + StorageLive(_10); + StorageLive(_9); + _9 = _4 as *mut T (PtrToPtr); + _10 = Offset(_9, _3); + StorageDead(_9); + _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); + StorageDead(_10); goto -> bb3; } bb2: { - _13 = _3 as *const T (Transmute); + _11 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_10); - StorageLive(_14); - _14 = _13; - _15 = std::slice::Iter::<'_, T> { ptr: _9, end_or_len: move _14, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_14); - StorageDead(_13); StorageDead(_8); + StorageLive(_12); + _12 = _11; + _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); + StorageDead(_11); + StorageDead(_6); StorageDead(_4); - StorageDead(_9); + StorageDead(_7); StorageDead(_3); - _16 = Enumerate::<std::slice::Iter<'_, T>> { iter: _15, count: const 0_usize }; - StorageDead(_15); - StorageLive(_17); - _17 = _16; + _14 = Enumerate::<std::slice::Iter<'_, T>> { iter: _13, count: const 0_usize }; + StorageDead(_13); + StorageLive(_15); + _15 = _14; goto -> bb4; } bb4: { - StorageLive(_19); - StorageLive(_18); - _18 = &mut _17; - _19 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _18) -> [return: bb5, unwind: bb11]; + StorageLive(_17); + StorageLive(_16); + _16 = &mut _15; + _17 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _16) -> [return: bb5, unwind: bb11]; } bb5: { - StorageDead(_18); - _20 = discriminant(_19); - switchInt(move _20) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_16); + _18 = discriminant(_17); + switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_19); StorageDead(_17); + StorageDead(_15); drop(_2) -> [return: bb7, unwind continue]; } @@ -171,19 +163,19 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb8: { - _21 = (((_19 as Some).0: (usize, &T)).0: usize); - _22 = (((_19 as Some).0: (usize, &T)).1: &T); - StorageLive(_23); - _23 = &_2; - StorageLive(_24); - _24 = (_21, _22); - _25 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _23, move _24) -> [return: bb9, unwind: bb11]; + _19 = (((_17 as Some).0: (usize, &T)).0: usize); + _20 = (((_17 as Some).0: (usize, &T)).1: &T); + StorageLive(_21); + _21 = &_2; + StorageLive(_22); + _22 = (_19, _20); + _23 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _21, move _22) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_24); - StorageDead(_23); - StorageDead(_19); + StorageDead(_22); + StorageDead(_21); + StorageDead(_17); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir index 133d6f53fce..2e63030aa5e 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -4,19 +4,19 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _15: std::slice::Iter<'_, T>; - let mut _16: std::slice::Iter<'_, T>; - let mut _17: &mut std::slice::Iter<'_, T>; - let mut _18: std::option::Option<&T>; - let mut _19: isize; - let mut _21: &impl Fn(&T); - let mut _22: (&T,); - let _23: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::slice::Iter<'_, T>; + let mut _15: &mut std::slice::Iter<'_, T>; + let mut _16: std::option::Option<&T>; + let mut _17: isize; + let mut _19: &impl Fn(&T); + let mut _20: (&T,); + let _21: (); scope 1 { - debug iter => _16; - let _20: &T; + debug iter => _14; + let _18: &T; scope 2 { - debug x => _20; + debug x => _18; } } scope 3 (inlined core::slice::<impl [T]>::iter) { @@ -25,19 +25,19 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; let _3: usize; let mut _5: std::ptr::NonNull<[T]>; - let mut _10: bool; - let mut _11: *mut T; - let mut _12: *mut T; - let mut _14: *const T; + let mut _8: bool; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { debug len => _3; - let _9: std::ptr::NonNull<T>; + let _7: std::ptr::NonNull<T>; scope 6 { - debug ptr => _9; + debug ptr => _7; scope 7 { - let _13: *const T; + let _11: *const T; scope 8 { - debug end_or_len => _13; + debug end_or_len => _11; } scope 14 (inlined invalid::<T>) { debug addr => _3; @@ -45,10 +45,10 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 16 (inlined NonNull::<T>::as_ptr) { - debug self => _9; + debug self => _7; } scope 17 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _11; + debug self => _9; debug count => _3; scope 18 { } @@ -63,9 +63,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } scope 11 (inlined NonNull::<[T]>::cast::<T>) { debug self => _5; - let mut _6: *mut [T]; - let mut _7: *mut T; - let mut _8: *const T; + let mut _6: *const T; scope 12 { scope 13 (inlined NonNull::<[T]>::as_ptr) { debug self => _5; @@ -76,81 +74,75 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 19 (inlined <std::slice::Iter<'_, T> as IntoIterator>::into_iter) { - debug self => _15; + debug self => _13; } bb0: { StorageLive(_3); - StorageLive(_9); + StorageLive(_7); StorageLive(_4); - StorageLive(_8); + StorageLive(_6); _3 = Len((*_1)); StorageLive(_5); _4 = &raw const (*_1); _5 = NonNull::<[T]> { pointer: _4 }; - StorageLive(_7); - StorageLive(_6); - _6 = _4 as *mut [T] (PtrToPtr); - _7 = move _6 as *mut T (PtrToPtr); - _8 = move _7 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_6); - StorageDead(_7); - _9 = NonNull::<T> { pointer: _8 }; + _6 = _4 as *const T (PtrToPtr); + _7 = NonNull::<T> { pointer: _6 }; StorageDead(_5); - StorageLive(_13); - StorageLive(_10); - _10 = const _; - switchInt(move _10) -> [0: bb1, otherwise: bb2]; + StorageLive(_11); + StorageLive(_8); + _8 = const _; + switchInt(move _8) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_12); - StorageLive(_11); - _11 = _8 as *mut T (PtrToPtr); - _12 = Offset(_11, _3); - StorageDead(_11); - _13 = move _12 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_12); + StorageLive(_10); + StorageLive(_9); + _9 = _4 as *mut T (PtrToPtr); + _10 = Offset(_9, _3); + StorageDead(_9); + _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); + StorageDead(_10); goto -> bb3; } bb2: { - _13 = _3 as *const T (Transmute); + _11 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_10); - StorageLive(_14); - _14 = _13; - _15 = std::slice::Iter::<'_, T> { ptr: _9, end_or_len: move _14, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_14); - StorageDead(_13); StorageDead(_8); + StorageLive(_12); + _12 = _11; + _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); + StorageDead(_11); + StorageDead(_6); StorageDead(_4); - StorageDead(_9); + StorageDead(_7); StorageDead(_3); - StorageLive(_16); - _16 = _15; + StorageLive(_14); + _14 = _13; goto -> bb4; } bb4: { - StorageLive(_18); - StorageLive(_17); - _17 = &mut _16; - _18 = <std::slice::Iter<'_, T> as Iterator>::next(move _17) -> [return: bb5, unwind unreachable]; + StorageLive(_16); + StorageLive(_15); + _15 = &mut _14; + _16 = <std::slice::Iter<'_, T> as Iterator>::next(move _15) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_17); - _19 = discriminant(_18); - switchInt(move _19) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_15); + _17 = discriminant(_16); + switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_18); StorageDead(_16); + StorageDead(_14); drop(_2) -> [return: bb7, unwind unreachable]; } @@ -159,18 +151,18 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _20 = ((_18 as Some).0: &T); - StorageLive(_21); - _21 = &_2; - StorageLive(_22); - _22 = (_20,); - _23 = <impl Fn(&T) as Fn<(&T,)>>::call(move _21, move _22) -> [return: bb9, unwind unreachable]; + _18 = ((_16 as Some).0: &T); + StorageLive(_19); + _19 = &_2; + StorageLive(_20); + _20 = (_18,); + _21 = <impl Fn(&T) as Fn<(&T,)>>::call(move _19, move _20) -> [return: bb9, unwind unreachable]; } bb9: { - StorageDead(_22); - StorageDead(_21); - StorageDead(_18); + StorageDead(_20); + StorageDead(_19); + StorageDead(_16); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir index 4e74253e541..b6b6b6972e9 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -4,19 +4,19 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _15: std::slice::Iter<'_, T>; - let mut _16: std::slice::Iter<'_, T>; - let mut _17: &mut std::slice::Iter<'_, T>; - let mut _18: std::option::Option<&T>; - let mut _19: isize; - let mut _21: &impl Fn(&T); - let mut _22: (&T,); - let _23: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::slice::Iter<'_, T>; + let mut _15: &mut std::slice::Iter<'_, T>; + let mut _16: std::option::Option<&T>; + let mut _17: isize; + let mut _19: &impl Fn(&T); + let mut _20: (&T,); + let _21: (); scope 1 { - debug iter => _16; - let _20: &T; + debug iter => _14; + let _18: &T; scope 2 { - debug x => _20; + debug x => _18; } } scope 3 (inlined core::slice::<impl [T]>::iter) { @@ -25,19 +25,19 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; let _3: usize; let mut _5: std::ptr::NonNull<[T]>; - let mut _10: bool; - let mut _11: *mut T; - let mut _12: *mut T; - let mut _14: *const T; + let mut _8: bool; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { debug len => _3; - let _9: std::ptr::NonNull<T>; + let _7: std::ptr::NonNull<T>; scope 6 { - debug ptr => _9; + debug ptr => _7; scope 7 { - let _13: *const T; + let _11: *const T; scope 8 { - debug end_or_len => _13; + debug end_or_len => _11; } scope 14 (inlined invalid::<T>) { debug addr => _3; @@ -45,10 +45,10 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 16 (inlined NonNull::<T>::as_ptr) { - debug self => _9; + debug self => _7; } scope 17 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _11; + debug self => _9; debug count => _3; scope 18 { } @@ -63,9 +63,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } scope 11 (inlined NonNull::<[T]>::cast::<T>) { debug self => _5; - let mut _6: *mut [T]; - let mut _7: *mut T; - let mut _8: *const T; + let mut _6: *const T; scope 12 { scope 13 (inlined NonNull::<[T]>::as_ptr) { debug self => _5; @@ -76,81 +74,75 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 19 (inlined <std::slice::Iter<'_, T> as IntoIterator>::into_iter) { - debug self => _15; + debug self => _13; } bb0: { StorageLive(_3); - StorageLive(_9); + StorageLive(_7); StorageLive(_4); - StorageLive(_8); + StorageLive(_6); _3 = Len((*_1)); StorageLive(_5); _4 = &raw const (*_1); _5 = NonNull::<[T]> { pointer: _4 }; - StorageLive(_7); - StorageLive(_6); - _6 = _4 as *mut [T] (PtrToPtr); - _7 = move _6 as *mut T (PtrToPtr); - _8 = move _7 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_6); - StorageDead(_7); - _9 = NonNull::<T> { pointer: _8 }; + _6 = _4 as *const T (PtrToPtr); + _7 = NonNull::<T> { pointer: _6 }; StorageDead(_5); - StorageLive(_13); - StorageLive(_10); - _10 = const _; - switchInt(move _10) -> [0: bb1, otherwise: bb2]; + StorageLive(_11); + StorageLive(_8); + _8 = const _; + switchInt(move _8) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_12); - StorageLive(_11); - _11 = _8 as *mut T (PtrToPtr); - _12 = Offset(_11, _3); - StorageDead(_11); - _13 = move _12 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_12); + StorageLive(_10); + StorageLive(_9); + _9 = _4 as *mut T (PtrToPtr); + _10 = Offset(_9, _3); + StorageDead(_9); + _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); + StorageDead(_10); goto -> bb3; } bb2: { - _13 = _3 as *const T (Transmute); + _11 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_10); - StorageLive(_14); - _14 = _13; - _15 = std::slice::Iter::<'_, T> { ptr: _9, end_or_len: move _14, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_14); - StorageDead(_13); StorageDead(_8); + StorageLive(_12); + _12 = _11; + _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); + StorageDead(_11); + StorageDead(_6); StorageDead(_4); - StorageDead(_9); + StorageDead(_7); StorageDead(_3); - StorageLive(_16); - _16 = _15; + StorageLive(_14); + _14 = _13; goto -> bb4; } bb4: { - StorageLive(_18); - StorageLive(_17); - _17 = &mut _16; - _18 = <std::slice::Iter<'_, T> as Iterator>::next(move _17) -> [return: bb5, unwind: bb11]; + StorageLive(_16); + StorageLive(_15); + _15 = &mut _14; + _16 = <std::slice::Iter<'_, T> as Iterator>::next(move _15) -> [return: bb5, unwind: bb11]; } bb5: { - StorageDead(_17); - _19 = discriminant(_18); - switchInt(move _19) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_15); + _17 = discriminant(_16); + switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_18); StorageDead(_16); + StorageDead(_14); drop(_2) -> [return: bb7, unwind continue]; } @@ -159,18 +151,18 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _20 = ((_18 as Some).0: &T); - StorageLive(_21); - _21 = &_2; - StorageLive(_22); - _22 = (_20,); - _23 = <impl Fn(&T) as Fn<(&T,)>>::call(move _21, move _22) -> [return: bb9, unwind: bb11]; + _18 = ((_16 as Some).0: &T); + StorageLive(_19); + _19 = &_2; + StorageLive(_20); + _20 = (_18,); + _21 = <impl Fn(&T) as Fn<(&T,)>>::call(move _19, move _20) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_22); - StorageDead(_21); - StorageDead(_18); + StorageDead(_20); + StorageDead(_19); + StorageDead(_16); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir index 639e1a51430..a78e46a0b78 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir @@ -4,24 +4,24 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _15: std::slice::Iter<'_, T>; - let mut _16: std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _17: std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _18: &mut std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _20: std::option::Option<&T>; - let mut _21: isize; - let mut _23: &impl Fn(&T); - let mut _24: (&T,); - let _25: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::iter::Rev<std::slice::Iter<'_, T>>; + let mut _15: std::iter::Rev<std::slice::Iter<'_, T>>; + let mut _16: &mut std::iter::Rev<std::slice::Iter<'_, T>>; + let mut _18: std::option::Option<&T>; + let mut _19: isize; + let mut _21: &impl Fn(&T); + let mut _22: (&T,); + let _23: (); scope 1 { - debug iter => _17; - let _22: &T; + debug iter => _15; + let _20: &T; scope 2 { - debug x => _22; + debug x => _20; } scope 22 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) { - debug self => _18; - let mut _19: &mut std::slice::Iter<'_, T>; + debug self => _16; + let mut _17: &mut std::slice::Iter<'_, T>; } } scope 3 (inlined core::slice::<impl [T]>::iter) { @@ -30,19 +30,19 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; let _3: usize; let mut _5: std::ptr::NonNull<[T]>; - let mut _10: bool; - let mut _11: *mut T; - let mut _12: *mut T; - let mut _14: *const T; + let mut _8: bool; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { debug len => _3; - let _9: std::ptr::NonNull<T>; + let _7: std::ptr::NonNull<T>; scope 6 { - debug ptr => _9; + debug ptr => _7; scope 7 { - let _13: *const T; + let _11: *const T; scope 8 { - debug end_or_len => _13; + debug end_or_len => _11; } scope 14 (inlined invalid::<T>) { debug addr => _3; @@ -50,10 +50,10 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 16 (inlined NonNull::<T>::as_ptr) { - debug self => _9; + debug self => _7; } scope 17 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _11; + debug self => _9; debug count => _3; scope 18 { } @@ -68,9 +68,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } scope 11 (inlined NonNull::<[T]>::cast::<T>) { debug self => _5; - let mut _6: *mut [T]; - let mut _7: *mut T; - let mut _8: *const T; + let mut _6: *const T; scope 12 { scope 13 (inlined NonNull::<[T]>::as_ptr) { debug self => _5; @@ -81,91 +79,85 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 19 (inlined <std::slice::Iter<'_, T> as Iterator>::rev) { - debug self => _15; + debug self => _13; scope 20 (inlined Rev::<std::slice::Iter<'_, T>>::new) { - debug iter => _15; + debug iter => _13; } } scope 21 (inlined <Rev<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) { - debug self => _16; + debug self => _14; } bb0: { - StorageLive(_15); + StorageLive(_13); StorageLive(_3); - StorageLive(_9); + StorageLive(_7); StorageLive(_4); - StorageLive(_8); + StorageLive(_6); _3 = Len((*_1)); StorageLive(_5); _4 = &raw const (*_1); _5 = NonNull::<[T]> { pointer: _4 }; - StorageLive(_7); - StorageLive(_6); - _6 = _4 as *mut [T] (PtrToPtr); - _7 = move _6 as *mut T (PtrToPtr); - _8 = move _7 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_6); - StorageDead(_7); - _9 = NonNull::<T> { pointer: _8 }; + _6 = _4 as *const T (PtrToPtr); + _7 = NonNull::<T> { pointer: _6 }; StorageDead(_5); - StorageLive(_13); - StorageLive(_10); - _10 = const _; - switchInt(move _10) -> [0: bb1, otherwise: bb2]; + StorageLive(_11); + StorageLive(_8); + _8 = const _; + switchInt(move _8) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_12); - StorageLive(_11); - _11 = _8 as *mut T (PtrToPtr); - _12 = Offset(_11, _3); - StorageDead(_11); - _13 = move _12 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_12); + StorageLive(_10); + StorageLive(_9); + _9 = _4 as *mut T (PtrToPtr); + _10 = Offset(_9, _3); + StorageDead(_9); + _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); + StorageDead(_10); goto -> bb3; } bb2: { - _13 = _3 as *const T (Transmute); + _11 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_10); - StorageLive(_14); - _14 = _13; - _15 = std::slice::Iter::<'_, T> { ptr: _9, end_or_len: move _14, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_14); - StorageDead(_13); StorageDead(_8); + StorageLive(_12); + _12 = _11; + _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); + StorageDead(_11); + StorageDead(_6); StorageDead(_4); - StorageDead(_9); + StorageDead(_7); StorageDead(_3); - _16 = Rev::<std::slice::Iter<'_, T>> { iter: _15 }; - StorageDead(_15); - StorageLive(_17); - _17 = _16; + _14 = Rev::<std::slice::Iter<'_, T>> { iter: _13 }; + StorageDead(_13); + StorageLive(_15); + _15 = _14; goto -> bb4; } bb4: { - StorageLive(_20); - _18 = &mut _17; - StorageLive(_19); - _19 = &mut (_17.0: std::slice::Iter<'_, T>); - _20 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _19) -> [return: bb5, unwind unreachable]; + StorageLive(_18); + _16 = &mut _15; + StorageLive(_17); + _17 = &mut (_15.0: std::slice::Iter<'_, T>); + _18 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _17) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_19); - _21 = discriminant(_20); - switchInt(move _21) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_17); + _19 = discriminant(_18); + switchInt(move _19) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_20); - StorageDead(_17); + StorageDead(_18); + StorageDead(_15); drop(_2) -> [return: bb7, unwind unreachable]; } @@ -174,18 +166,18 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _22 = ((_20 as Some).0: &T); - StorageLive(_23); - _23 = &_2; - StorageLive(_24); - _24 = (_22,); - _25 = <impl Fn(&T) as Fn<(&T,)>>::call(move _23, move _24) -> [return: bb9, unwind unreachable]; + _20 = ((_18 as Some).0: &T); + StorageLive(_21); + _21 = &_2; + StorageLive(_22); + _22 = (_20,); + _23 = <impl Fn(&T) as Fn<(&T,)>>::call(move _21, move _22) -> [return: bb9, unwind unreachable]; } bb9: { - StorageDead(_24); - StorageDead(_23); - StorageDead(_20); + StorageDead(_22); + StorageDead(_21); + StorageDead(_18); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir index 2237fd7dbd1..4e54a23e819 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir @@ -4,24 +4,24 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _15: std::slice::Iter<'_, T>; - let mut _16: std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _17: std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _18: &mut std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _20: std::option::Option<&T>; - let mut _21: isize; - let mut _23: &impl Fn(&T); - let mut _24: (&T,); - let _25: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::iter::Rev<std::slice::Iter<'_, T>>; + let mut _15: std::iter::Rev<std::slice::Iter<'_, T>>; + let mut _16: &mut std::iter::Rev<std::slice::Iter<'_, T>>; + let mut _18: std::option::Option<&T>; + let mut _19: isize; + let mut _21: &impl Fn(&T); + let mut _22: (&T,); + let _23: (); scope 1 { - debug iter => _17; - let _22: &T; + debug iter => _15; + let _20: &T; scope 2 { - debug x => _22; + debug x => _20; } scope 22 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) { - debug self => _18; - let mut _19: &mut std::slice::Iter<'_, T>; + debug self => _16; + let mut _17: &mut std::slice::Iter<'_, T>; } } scope 3 (inlined core::slice::<impl [T]>::iter) { @@ -30,19 +30,19 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; let _3: usize; let mut _5: std::ptr::NonNull<[T]>; - let mut _10: bool; - let mut _11: *mut T; - let mut _12: *mut T; - let mut _14: *const T; + let mut _8: bool; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { debug len => _3; - let _9: std::ptr::NonNull<T>; + let _7: std::ptr::NonNull<T>; scope 6 { - debug ptr => _9; + debug ptr => _7; scope 7 { - let _13: *const T; + let _11: *const T; scope 8 { - debug end_or_len => _13; + debug end_or_len => _11; } scope 14 (inlined invalid::<T>) { debug addr => _3; @@ -50,10 +50,10 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 16 (inlined NonNull::<T>::as_ptr) { - debug self => _9; + debug self => _7; } scope 17 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _11; + debug self => _9; debug count => _3; scope 18 { } @@ -68,9 +68,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } scope 11 (inlined NonNull::<[T]>::cast::<T>) { debug self => _5; - let mut _6: *mut [T]; - let mut _7: *mut T; - let mut _8: *const T; + let mut _6: *const T; scope 12 { scope 13 (inlined NonNull::<[T]>::as_ptr) { debug self => _5; @@ -81,91 +79,85 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 19 (inlined <std::slice::Iter<'_, T> as Iterator>::rev) { - debug self => _15; + debug self => _13; scope 20 (inlined Rev::<std::slice::Iter<'_, T>>::new) { - debug iter => _15; + debug iter => _13; } } scope 21 (inlined <Rev<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) { - debug self => _16; + debug self => _14; } bb0: { - StorageLive(_15); + StorageLive(_13); StorageLive(_3); - StorageLive(_9); + StorageLive(_7); StorageLive(_4); - StorageLive(_8); + StorageLive(_6); _3 = Len((*_1)); StorageLive(_5); _4 = &raw const (*_1); _5 = NonNull::<[T]> { pointer: _4 }; - StorageLive(_7); - StorageLive(_6); - _6 = _4 as *mut [T] (PtrToPtr); - _7 = move _6 as *mut T (PtrToPtr); - _8 = move _7 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_6); - StorageDead(_7); - _9 = NonNull::<T> { pointer: _8 }; + _6 = _4 as *const T (PtrToPtr); + _7 = NonNull::<T> { pointer: _6 }; StorageDead(_5); - StorageLive(_13); - StorageLive(_10); - _10 = const _; - switchInt(move _10) -> [0: bb1, otherwise: bb2]; + StorageLive(_11); + StorageLive(_8); + _8 = const _; + switchInt(move _8) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_12); - StorageLive(_11); - _11 = _8 as *mut T (PtrToPtr); - _12 = Offset(_11, _3); - StorageDead(_11); - _13 = move _12 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_12); + StorageLive(_10); + StorageLive(_9); + _9 = _4 as *mut T (PtrToPtr); + _10 = Offset(_9, _3); + StorageDead(_9); + _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); + StorageDead(_10); goto -> bb3; } bb2: { - _13 = _3 as *const T (Transmute); + _11 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_10); - StorageLive(_14); - _14 = _13; - _15 = std::slice::Iter::<'_, T> { ptr: _9, end_or_len: move _14, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_14); - StorageDead(_13); StorageDead(_8); + StorageLive(_12); + _12 = _11; + _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); + StorageDead(_11); + StorageDead(_6); StorageDead(_4); - StorageDead(_9); + StorageDead(_7); StorageDead(_3); - _16 = Rev::<std::slice::Iter<'_, T>> { iter: _15 }; - StorageDead(_15); - StorageLive(_17); - _17 = _16; + _14 = Rev::<std::slice::Iter<'_, T>> { iter: _13 }; + StorageDead(_13); + StorageLive(_15); + _15 = _14; goto -> bb4; } bb4: { - StorageLive(_20); - _18 = &mut _17; - StorageLive(_19); - _19 = &mut (_17.0: std::slice::Iter<'_, T>); - _20 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _19) -> [return: bb5, unwind: bb11]; + StorageLive(_18); + _16 = &mut _15; + StorageLive(_17); + _17 = &mut (_15.0: std::slice::Iter<'_, T>); + _18 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _17) -> [return: bb5, unwind: bb11]; } bb5: { - StorageDead(_19); - _21 = discriminant(_20); - switchInt(move _21) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_17); + _19 = discriminant(_18); + switchInt(move _19) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_20); - StorageDead(_17); + StorageDead(_18); + StorageDead(_15); drop(_2) -> [return: bb7, unwind continue]; } @@ -174,18 +166,18 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _22 = ((_20 as Some).0: &T); - StorageLive(_23); - _23 = &_2; - StorageLive(_24); - _24 = (_22,); - _25 = <impl Fn(&T) as Fn<(&T,)>>::call(move _23, move _24) -> [return: bb9, unwind: bb11]; + _20 = ((_18 as Some).0: &T); + StorageLive(_21); + _21 = &_2; + StorageLive(_22); + _22 = (_20,); + _23 = <impl Fn(&T) as Fn<(&T,)>>::call(move _21, move _22) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_24); - StorageDead(_23); - StorageDead(_20); + StorageDead(_22); + StorageDead(_21); + StorageDead(_18); goto -> bb4; } diff --git a/tests/ui/async-await/async-closures/auxiliary/foreign.rs b/tests/ui/async-await/async-closures/auxiliary/foreign.rs new file mode 100644 index 00000000000..e11dfc22213 --- /dev/null +++ b/tests/ui/async-await/async-closures/auxiliary/foreign.rs @@ -0,0 +1,7 @@ +// edition:2021 + +#![feature(async_closure)] + +pub fn closure() -> impl async Fn() { + async || { /* Don't really need to do anything here. */ } +} diff --git a/tests/ui/async-await/async-closures/foreign.rs b/tests/ui/async-await/async-closures/foreign.rs new file mode 100644 index 00000000000..60fea909801 --- /dev/null +++ b/tests/ui/async-await/async-closures/foreign.rs @@ -0,0 +1,19 @@ +// aux-build:block-on.rs +// aux-build:foreign.rs +// edition:2021 +// build-pass + +#![feature(async_closure)] + +use std::future::Future; + +extern crate block_on; +extern crate foreign; + +struct NoCopy; + +fn main() { + block_on::block_on(async { + foreign::closure()().await; + }); +} diff --git a/tests/ui/async-await/async-closures/is-not-fn.rs b/tests/ui/async-await/async-closures/is-not-fn.rs index 40b0febbf06..81666cada31 100644 --- a/tests/ui/async-await/async-closures/is-not-fn.rs +++ b/tests/ui/async-await/async-closures/is-not-fn.rs @@ -5,5 +5,5 @@ fn main() { fn needs_fn(x: impl FnOnce()) {} needs_fn(async || {}); - //~^ ERROR expected `{coroutine-closure@is-not-fn.rs:7:14}` to be a closure that returns `()` + //~^ ERROR expected `{async closure@is-not-fn.rs:7:14}` to be a closure that returns `()` } diff --git a/tests/ui/async-await/async-closures/is-not-fn.stderr b/tests/ui/async-await/async-closures/is-not-fn.stderr index 6169cee85fd..130746ece67 100644 --- a/tests/ui/async-await/async-closures/is-not-fn.stderr +++ b/tests/ui/async-await/async-closures/is-not-fn.stderr @@ -1,4 +1,4 @@ -error[E0271]: expected `{coroutine-closure@is-not-fn.rs:7:14}` to be a closure that returns `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:7:23: 7:25}` +error[E0271]: expected `{async closure@is-not-fn.rs:7:14}` to be a closure that returns `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:7:23: 7:25}` --> $DIR/is-not-fn.rs:7:14 | LL | needs_fn(async || {}); diff --git a/tests/ui/async-await/async-closures/move-consuming-capture.stderr b/tests/ui/async-await/async-closures/move-consuming-capture.stderr index 2c2a0d1162d..45c1eac8f8f 100644 --- a/tests/ui/async-await/async-closures/move-consuming-capture.stderr +++ b/tests/ui/async-await/async-closures/move-consuming-capture.stderr @@ -2,7 +2,7 @@ error[E0382]: use of moved value: `x` --> $DIR/move-consuming-capture.rs:17:9 | LL | let x = async move || { - | - move occurs because `x` has type `{coroutine-closure@$DIR/move-consuming-capture.rs:13:17: 13:30}`, which does not implement the `Copy` trait + | - move occurs because `x` has type `{async closure@$DIR/move-consuming-capture.rs:13:17: 13:30}`, which does not implement the `Copy` trait ... LL | x().await; | --- `x` moved due to this method call diff --git a/tests/ui/coercion/type-errors.rs b/tests/ui/coercion/type-errors.rs new file mode 100644 index 00000000000..a2f0e55f1b9 --- /dev/null +++ b/tests/ui/coercion/type-errors.rs @@ -0,0 +1,15 @@ +// Regression test for an ICE: https://github.com/rust-lang/rust/issues/120884 +// We still need to properly go through coercions between types with errors instead of +// shortcutting and returning success, because we need the adjustments for building the MIR. + +pub fn has_error() -> TypeError {} +//~^ ERROR cannot find type `TypeError` in this scope + +pub fn cast() -> *const u8 { + // Casting a function item to a data pointer in valid in HIR, but invalid in MIR. + // We need an adjustment (ReifyFnPointer) to insert a cast from the function item + // to a function pointer as a separate MIR statement. + has_error as *const u8 +} + +fn main() {} diff --git a/tests/ui/coercion/type-errors.stderr b/tests/ui/coercion/type-errors.stderr new file mode 100644 index 00000000000..489cd9ddf13 --- /dev/null +++ b/tests/ui/coercion/type-errors.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `TypeError` in this scope + --> $DIR/type-errors.rs:5:23 + | +LL | pub fn has_error() -> TypeError {} + | ^^^^^^^^^ not found in this scope + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/coherence/coherence-impls-copy.stderr b/tests/ui/coherence/coherence-impls-copy.stderr index 21dbc606321..2d2c5064043 100644 --- a/tests/ui/coherence/coherence-impls-copy.stderr +++ b/tests/ui/coherence/coherence-impls-copy.stderr @@ -30,6 +30,12 @@ LL | impl Copy for &'static [NotSync] {} | = note: define and implement a trait or new type instead +error[E0206]: the trait `Copy` cannot be implemented for this type + --> $DIR/coherence-impls-copy.rs:21:15 + | +LL | impl Copy for &'static mut MyType {} + | ^^^^^^^^^^^^^^^^^^^ type is not a structure or enumeration + error[E0117]: only traits defined in the current crate can be implemented for arbitrary types --> $DIR/coherence-impls-copy.rs:25:1 | @@ -41,6 +47,12 @@ LL | impl Copy for (MyType, MyType) {} | = note: define and implement a trait or new type instead +error[E0206]: the trait `Copy` cannot be implemented for this type + --> $DIR/coherence-impls-copy.rs:25:15 + | +LL | impl Copy for (MyType, MyType) {} + | ^^^^^^^^^^^^^^^^ type is not a structure or enumeration + error[E0117]: only traits defined in the current crate can be implemented for arbitrary types --> $DIR/coherence-impls-copy.rs:30:1 | @@ -53,18 +65,6 @@ LL | impl Copy for [MyType] {} = note: define and implement a trait or new type instead error[E0206]: the trait `Copy` cannot be implemented for this type - --> $DIR/coherence-impls-copy.rs:21:15 - | -LL | impl Copy for &'static mut MyType {} - | ^^^^^^^^^^^^^^^^^^^ type is not a structure or enumeration - -error[E0206]: the trait `Copy` cannot be implemented for this type - --> $DIR/coherence-impls-copy.rs:25:15 - | -LL | impl Copy for (MyType, MyType) {} - | ^^^^^^^^^^^^^^^^ type is not a structure or enumeration - -error[E0206]: the trait `Copy` cannot be implemented for this type --> $DIR/coherence-impls-copy.rs:30:15 | LL | impl Copy for [MyType] {} diff --git a/tests/ui/consts/miri_unleashed/extern-static.rs b/tests/ui/consts/miri_unleashed/extern-static.rs new file mode 100644 index 00000000000..81176b3d4e9 --- /dev/null +++ b/tests/ui/consts/miri_unleashed/extern-static.rs @@ -0,0 +1,24 @@ +// compile-flags: -Zunleash-the-miri-inside-of-you +#![feature(thread_local)] +#![allow(static_mut_ref)] + +extern "C" { + static mut DATA: u8; +} + +// Make sure we catch accessing extern static. +static TEST_READ: () = { + unsafe { let _val = DATA; } + //~^ ERROR could not evaluate static initializer + //~| NOTE cannot access extern static +}; +static TEST_WRITE: () = { + unsafe { DATA = 0; } + //~^ ERROR could not evaluate static initializer + //~| NOTE cannot access extern static +}; + +// Just creating a reference is fine, as long as we are not reading or writing. +static TEST_REF: &u8 = unsafe { &DATA }; + +fn main() {} diff --git a/tests/ui/consts/miri_unleashed/extern-static.stderr b/tests/ui/consts/miri_unleashed/extern-static.stderr new file mode 100644 index 00000000000..0979a5e4fb1 --- /dev/null +++ b/tests/ui/consts/miri_unleashed/extern-static.stderr @@ -0,0 +1,15 @@ +error[E0080]: could not evaluate static initializer + --> $DIR/extern-static.rs:11:25 + | +LL | unsafe { let _val = DATA; } + | ^^^^ cannot access extern static (DefId(0:4 ~ extern_static[c41e]::{extern#0}::DATA)) + +error[E0080]: could not evaluate static initializer + --> $DIR/extern-static.rs:16:14 + | +LL | unsafe { DATA = 0; } + | ^^^^^^^^ cannot access extern static (DefId(0:4 ~ extern_static[c41e]::{extern#0}::DATA)) + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/miri_unleashed/tls.rs b/tests/ui/consts/miri_unleashed/tls.rs index d06d7cf19f7..7319a5135d3 100644 --- a/tests/ui/consts/miri_unleashed/tls.rs +++ b/tests/ui/consts/miri_unleashed/tls.rs @@ -14,6 +14,8 @@ static TEST_BAD: () = { }; // Make sure we catch taking a reference to thread-local storage. +// The actual pointer depends on the thread, so even just taking a reference already does not make +// sense at compile-time. static TEST_BAD_REF: () = { unsafe { let _val = &A; } //~^ ERROR could not evaluate static initializer diff --git a/tests/ui/consts/miri_unleashed/tls.stderr b/tests/ui/consts/miri_unleashed/tls.stderr index ec24527d6c0..a00b7eb1312 100644 --- a/tests/ui/consts/miri_unleashed/tls.stderr +++ b/tests/ui/consts/miri_unleashed/tls.stderr @@ -5,7 +5,7 @@ LL | unsafe { let _val = A; } | ^ cannot access thread local static (DefId(0:4 ~ tls[ca29]::A)) error[E0080]: could not evaluate static initializer - --> $DIR/tls.rs:18:26 + --> $DIR/tls.rs:20:26 | LL | unsafe { let _val = &A; } | ^ cannot access thread local static (DefId(0:4 ~ tls[ca29]::A)) @@ -18,7 +18,7 @@ help: skipping check that does not even have a feature gate LL | unsafe { let _val = A; } | ^ help: skipping check that does not even have a feature gate - --> $DIR/tls.rs:18:26 + --> $DIR/tls.rs:20:26 | LL | unsafe { let _val = &A; } | ^ diff --git a/tests/ui/error-codes/E0401.rs b/tests/ui/error-codes/E0401.rs index 8f8d6b87ef2..a120198b728 100644 --- a/tests/ui/error-codes/E0401.rs +++ b/tests/ui/error-codes/E0401.rs @@ -9,8 +9,6 @@ fn foo<T>(x: T) { (y: T) { //~ ERROR E0401 } bfnr(x); - //~^ ERROR type annotations needed - //~| ERROR type annotations needed } diff --git a/tests/ui/error-codes/E0401.stderr b/tests/ui/error-codes/E0401.stderr index 754867061c7..5d6878620c8 100644 --- a/tests/ui/error-codes/E0401.stderr +++ b/tests/ui/error-codes/E0401.stderr @@ -21,7 +21,7 @@ LL | (y: T) { | ^ use of generic parameter from outer item error[E0401]: can't use `Self` from outer item - --> $DIR/E0401.rs:24:25 + --> $DIR/E0401.rs:22:25 | LL | impl<T> Iterator for A<T> { | ---- `Self` type implicitly declared here, by this `impl` @@ -32,45 +32,6 @@ LL | fn helper(sel: &Self) -> u8 { | use of `Self` from outer item | refer to the type directly here instead -error[E0283]: type annotations needed - --> $DIR/E0401.rs:11:5 - | -LL | bfnr(x); - | ^^^^ cannot infer type of the type parameter `V` declared on the function `bfnr` - | - = note: cannot satisfy `_: Baz<_>` -note: required by a bound in `bfnr` - --> $DIR/E0401.rs:4:19 - | -LL | fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) { - | ^^^^^^ required by this bound in `bfnr` -help: consider specifying the generic arguments - | -LL | bfnr::<U, V, W>(x); - | +++++++++++ - -error[E0283]: type annotations needed - --> $DIR/E0401.rs:11:5 - | -LL | bfnr(x); - | ^^^^ cannot infer type of the type parameter `W` declared on the function `bfnr` - | - = note: multiple `impl`s satisfying `_: Fn()` found in the following crates: `alloc`, `core`: - - impl<A, F> Fn<A> for &F - where A: Tuple, F: Fn<A>, F: ?Sized; - - impl<Args, F, A> Fn<Args> for Box<F, A> - where Args: Tuple, F: Fn<Args>, A: Allocator, F: ?Sized; -note: required by a bound in `bfnr` - --> $DIR/E0401.rs:4:30 - | -LL | fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) { - | ^^^^ required by this bound in `bfnr` -help: consider specifying the generic arguments - | -LL | bfnr::<U, V, W>(x); - | +++++++++++ - -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0283, E0401. -For more information about an error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0401`. diff --git a/tests/ui/lint/large_assignments/box_rc_arc_allowed.rs b/tests/ui/lint/large_assignments/box_rc_arc_allowed.rs deleted file mode 100644 index 33113642023..00000000000 --- a/tests/ui/lint/large_assignments/box_rc_arc_allowed.rs +++ /dev/null @@ -1,29 +0,0 @@ -#![deny(large_assignments)] -#![feature(large_assignments)] -#![move_size_limit = "1000"] -// build-fail -// only-x86_64 - -// edition:2018 -// compile-flags: -Zmir-opt-level=0 - -use std::{sync::Arc, rc::Rc}; - -fn main() { - let _ = Arc::new([0; 9999]); // OK! - let _ = Box::new([0; 9999]); // OK! - let _ = Rc::new([0; 9999]); // OK! - let _ = NotBox::new([0; 9999]); //~ ERROR large_assignments -} - -struct NotBox { - data: [u8; 9999], -} - -impl NotBox { - fn new(data: [u8; 9999]) -> Self { - Self { - data, //~ ERROR large_assignments - } - } -} diff --git a/tests/ui/lint/large_assignments/copy_into_box_rc_arc.rs b/tests/ui/lint/large_assignments/copy_into_box_rc_arc.rs new file mode 100644 index 00000000000..866a4d10ff5 --- /dev/null +++ b/tests/ui/lint/large_assignments/copy_into_box_rc_arc.rs @@ -0,0 +1,38 @@ +#![deny(large_assignments)] +#![feature(large_assignments)] +#![move_size_limit = "1000"] +// build-fail +// only-64bit + +// edition:2018 +// compile-flags: -Zmir-opt-level=1 + +use std::{sync::Arc, rc::Rc}; + +fn main() { + let data = [0; 9999]; + + // Looking at --emit mir, we can see that all parameters below are passed by + // copy. But it requires at least mir-opt-level=1. + let _ = Arc::new(data); // OK! + let _ = Box::new(data); // OK! + let _ = Rc::new(data); // OK! + + // Looking at --emit llvm-ir, we can see that a memcpy is involved in the + // parameter passing. So we want the lint to trigger here. + let _ = NotBox::new(data); //~ ERROR large_assignments +} + +struct NotBox { + data: [u8; 9999], +} + +impl NotBox { + fn new(data: [u8; 9999]) -> Self { + // Looking at --emit llvm-ir, we can see that a memcpy is involved. + // So we want the lint to trigger here. + Self { //~ ERROR large_assignments + data, + } + } +} diff --git a/tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr b/tests/ui/lint/large_assignments/copy_into_box_rc_arc.stderr index fefb3a9621b..6e42328a111 100644 --- a/tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr +++ b/tests/ui/lint/large_assignments/copy_into_box_rc_arc.stderr @@ -1,21 +1,23 @@ error: moving 9999 bytes - --> $DIR/box_rc_arc_allowed.rs:16:25 + --> $DIR/copy_into_box_rc_arc.rs:23:25 | -LL | let _ = NotBox::new([0; 9999]); - | ^^^^^^^^^ value moved from here +LL | let _ = NotBox::new(data); + | ^^^^ value moved from here | = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` note: the lint level is defined here - --> $DIR/box_rc_arc_allowed.rs:1:9 + --> $DIR/copy_into_box_rc_arc.rs:1:9 | LL | #![deny(large_assignments)] | ^^^^^^^^^^^^^^^^^ error: moving 9999 bytes - --> $DIR/box_rc_arc_allowed.rs:26:13 + --> $DIR/copy_into_box_rc_arc.rs:34:9 | -LL | data, - | ^^^^ value moved from here +LL | / Self { +LL | | data, +LL | | } + | |_________^ value moved from here | = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` diff --git a/tests/ui/lint/large_assignments/large_future.rs b/tests/ui/lint/large_assignments/large_future.rs index 834746fa97e..a69ff356c6b 100644 --- a/tests/ui/lint/large_assignments/large_future.rs +++ b/tests/ui/lint/large_assignments/large_future.rs @@ -2,7 +2,7 @@ #![cfg_attr(attribute, feature(large_assignments))] #![cfg_attr(attribute, move_size_limit = "1000")] // build-fail -// only-x86_64 +// only-64bit // revisions: attribute option // [option]compile-flags: -Zmove-size-limit=1000 diff --git a/tests/ui/lint/large_assignments/move_into_box_rc_arc.rs b/tests/ui/lint/large_assignments/move_into_box_rc_arc.rs new file mode 100644 index 00000000000..b7a70dfdda0 --- /dev/null +++ b/tests/ui/lint/large_assignments/move_into_box_rc_arc.rs @@ -0,0 +1,38 @@ +#![deny(large_assignments)] +#![feature(large_assignments)] +#![move_size_limit = "1000"] +// build-fail +// only-64bit + +// edition:2018 +// compile-flags: -Zmir-opt-level=0 + +use std::{sync::Arc, rc::Rc}; + +fn main() { + // Looking at --emit mir, we can see that all parameters below are passed + // by move. + let _ = Arc::new([0; 9999]); // OK! + let _ = Box::new([0; 9999]); // OK! + let _ = Rc::new([0; 9999]); // OK! + + // Looking at --emit llvm-ir, we can see that no memcpy is involved in the + // parameter passing. Instead, a pointer is passed. This is typically what + // we get when moving parameter into functions. So we don't want the lint to + // trigger here. + let _ = NotBox::new([0; 9999]); // OK (compare with copy_into_box_rc_arc.rs) +} + +struct NotBox { + data: [u8; 9999], +} + +impl NotBox { + fn new(data: [u8; 9999]) -> Self { + Self { + // Looking at --emit llvm-ir, we can see that a memcpy is involved. + // So we want the lint to trigger here. + data, //~ ERROR large_assignments + } + } +} diff --git a/tests/ui/lint/large_assignments/move_into_box_rc_arc.stderr b/tests/ui/lint/large_assignments/move_into_box_rc_arc.stderr new file mode 100644 index 00000000000..a386de5e5e8 --- /dev/null +++ b/tests/ui/lint/large_assignments/move_into_box_rc_arc.stderr @@ -0,0 +1,15 @@ +error: moving 9999 bytes + --> $DIR/move_into_box_rc_arc.rs:35:13 + | +LL | data, + | ^^^^ value moved from here + | + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` +note: the lint level is defined here + --> $DIR/move_into_box_rc_arc.rs:1:9 + | +LL | #![deny(large_assignments)] + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/lint/large_assignments/move_into_fn.rs b/tests/ui/lint/large_assignments/move_into_fn.rs new file mode 100644 index 00000000000..359705bfc03 --- /dev/null +++ b/tests/ui/lint/large_assignments/move_into_fn.rs @@ -0,0 +1,22 @@ +// build-fail + +#![feature(large_assignments)] +#![move_size_limit = "1000"] +#![deny(large_assignments)] +#![allow(unused)] + +// Note: This type does not implement Copy. +struct Data([u8; 9999]); + +fn main() { + // Looking at llvm-ir output, we can see a memcpy'd into Data, so we want + // the lint to trigger here. + let data = Data([100; 9999]); //~ ERROR large_assignments + + // Looking at llvm-ir output, we can see that there is no memcpy involved in + // this function call. Instead, just a pointer is passed to the function. So + // the lint shall not trigger here. + take_data(data); +} + +fn take_data(data: Data) {} diff --git a/tests/ui/lint/large_assignments/move_into_fn.stderr b/tests/ui/lint/large_assignments/move_into_fn.stderr new file mode 100644 index 00000000000..92a0489e472 --- /dev/null +++ b/tests/ui/lint/large_assignments/move_into_fn.stderr @@ -0,0 +1,15 @@ +error: moving 9999 bytes + --> $DIR/move_into_fn.rs:14:16 + | +LL | let data = Data([100; 9999]); + | ^^^^^^^^^^^^^^^^^ value moved from here + | + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` +note: the lint level is defined here + --> $DIR/move_into_fn.rs:5:9 + | +LL | #![deny(large_assignments)] + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/proc-macro/auxiliary/issue-118809.rs b/tests/ui/proc-macro/auxiliary/issue-118809.rs new file mode 100644 index 00000000000..029b58c6d0c --- /dev/null +++ b/tests/ui/proc-macro/auxiliary/issue-118809.rs @@ -0,0 +1,20 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::TokenStream; + +#[proc_macro_derive(Deserialize)] +pub fn deserialize_derive(input: TokenStream) -> TokenStream { + "impl Build { + fn deserialize() -> Option<u64> { + let x: Option<u32> = Some(0); + Some(x? + 1) + } + } + " + .parse() + .unwrap() +} diff --git a/tests/ui/proc-macro/issue-118809.rs b/tests/ui/proc-macro/issue-118809.rs new file mode 100644 index 00000000000..732bf19c173 --- /dev/null +++ b/tests/ui/proc-macro/issue-118809.rs @@ -0,0 +1,10 @@ +// aux-build: issue-118809.rs + +#[macro_use] +extern crate issue_118809; + +#[derive(Deserialize)] //~ ERROR mismatched types [E0308] +pub struct Build { +} + +fn main() {} diff --git a/tests/ui/proc-macro/issue-118809.stderr b/tests/ui/proc-macro/issue-118809.stderr new file mode 100644 index 00000000000..30b09fd4006 --- /dev/null +++ b/tests/ui/proc-macro/issue-118809.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/issue-118809.rs:6:10 + | +LL | #[derive(Deserialize)] + | ^^^^^^^^^^^ + | | + | expected `u64`, found `u32` + | arguments to this enum variant are incorrect + | +help: the type constructed contains `u32` due to the type of the argument passed + --> $DIR/issue-118809.rs:6:10 + | +LL | #[derive(Deserialize)] + | ^^^^^^^^^^^ this argument influences the type of `Some` +note: tuple variant defined here + --> $SRC_DIR/core/src/option.rs:LL:COL + = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr index dc4ec5d3ee2..ec9826819c0 100644 --- a/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr +++ b/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr @@ -18,16 +18,16 @@ help: use parentheses to call this function LL | bar(foo()); | ++ -error[E0277]: `{coroutine-closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` is not a future +error[E0277]: `{async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` is not a future --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:12:9 | LL | bar(async_closure); - | --- ^^^^^^^^^^^^^ `{coroutine-closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` is not a future + | --- ^^^^^^^^^^^^^ `{async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` is not a future | | | required by a bound introduced by this call | - = help: the trait `Future` is not implemented for `{coroutine-closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` - = note: {coroutine-closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33} must be a future or must implement `IntoFuture` to be awaited + = help: the trait `Future` is not implemented for `{async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` + = note: {async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33} must be a future or must implement `IntoFuture` to be awaited note: required by a bound in `bar` --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:7:16 | diff --git a/tests/ui/trait-impl-bound-suggestions.fixed b/tests/ui/trait-impl-bound-suggestions.fixed index 744e7bef04e..fb11286a175 100644 --- a/tests/ui/trait-impl-bound-suggestions.fixed +++ b/tests/ui/trait-impl-bound-suggestions.fixed @@ -17,4 +17,13 @@ trait InsufficientlyConstrainedGeneric<X=()> where X: std::marker::Copy { } } +// Regression test for #120838 +#[allow(dead_code)] +trait InsufficientlyConstrainedGenericWithEmptyWhere<X=()> where X: std::marker::Copy { + fn return_the_constrained_type(&self, x: X) -> ConstrainedStruct<X> { + //~^ ERROR the trait bound `X: Copy` is not satisfied + ConstrainedStruct { x } + } +} + pub fn main() { } diff --git a/tests/ui/trait-impl-bound-suggestions.rs b/tests/ui/trait-impl-bound-suggestions.rs index bf75175179e..46130a5e766 100644 --- a/tests/ui/trait-impl-bound-suggestions.rs +++ b/tests/ui/trait-impl-bound-suggestions.rs @@ -17,4 +17,13 @@ trait InsufficientlyConstrainedGeneric<X=()> { } } +// Regression test for #120838 +#[allow(dead_code)] +trait InsufficientlyConstrainedGenericWithEmptyWhere<X=()> where { + fn return_the_constrained_type(&self, x: X) -> ConstrainedStruct<X> { + //~^ ERROR the trait bound `X: Copy` is not satisfied + ConstrainedStruct { x } + } +} + pub fn main() { } diff --git a/tests/ui/trait-impl-bound-suggestions.stderr b/tests/ui/trait-impl-bound-suggestions.stderr index c1f31e2b32e..9883c5bda01 100644 --- a/tests/ui/trait-impl-bound-suggestions.stderr +++ b/tests/ui/trait-impl-bound-suggestions.stderr @@ -14,6 +14,22 @@ help: consider further restricting type parameter `X` LL | trait InsufficientlyConstrainedGeneric<X=()> where X: std::marker::Copy { | ++++++++++++++++++++++++++ -error: aborting due to 1 previous error +error[E0277]: the trait bound `X: Copy` is not satisfied + --> $DIR/trait-impl-bound-suggestions.rs:23:52 + | +LL | fn return_the_constrained_type(&self, x: X) -> ConstrainedStruct<X> { + | ^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `X` + | +note: required by a bound in `ConstrainedStruct` + --> $DIR/trait-impl-bound-suggestions.rs:8:29 + | +LL | struct ConstrainedStruct<X: Copy> { + | ^^^^ required by this bound in `ConstrainedStruct` +help: consider further restricting type parameter `X` + | +LL | trait InsufficientlyConstrainedGenericWithEmptyWhere<X=()> where X: std::marker::Copy { + | ++++++++++++++++++++ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/typeck/issue-104510-ice.rs b/tests/ui/typeck/issue-104510-ice.rs index 635cc8fad66..157bdf07e38 100644 --- a/tests/ui/typeck/issue-104510-ice.rs +++ b/tests/ui/typeck/issue-104510-ice.rs @@ -6,7 +6,7 @@ struct W<T: ?Sized>(Oops); unsafe fn test() { let j = W(()); - let pointer = &j as *const _; //~ ERROR type annotations needed + let pointer = &j as *const _; core::arch::asm!( "nop", in("eax") pointer, diff --git a/tests/ui/typeck/issue-104510-ice.stderr b/tests/ui/typeck/issue-104510-ice.stderr index 774e5268184..143139b2c08 100644 --- a/tests/ui/typeck/issue-104510-ice.stderr +++ b/tests/ui/typeck/issue-104510-ice.stderr @@ -4,18 +4,6 @@ error[E0412]: cannot find type `Oops` in this scope LL | struct W<T: ?Sized>(Oops); | ^^^^ not found in this scope -error[E0282]: type annotations needed for `*const W<T>` - --> $DIR/issue-104510-ice.rs:9:9 - | -LL | let pointer = &j as *const _; - | ^^^^^^^ - | -help: consider giving `pointer` an explicit type, where the type for type parameter `T` is specified - | -LL | let pointer: *const W<T> = &j as *const _; - | +++++++++++++ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0282, E0412. -For more information about an error, try `rustc --explain E0282`. +For more information about this error, try `rustc --explain E0412`. |
