From 9918693037dce8aa4bb6f08741b6812923486c18 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 19 Jun 2024 11:26:03 +0200 Subject: Merging upstream version 1.76.0+dfsg1. Signed-off-by: Daniel Baumann --- ...sync_await.b-{closure#0}.coroutine_resume.0.mir | 11 +- tests/mir-opt/building/custom/terminators.rs | 8 +- tests/mir-opt/building/custom/unwind_action.rs | 68 +++++++ tests/mir-opt/building/custom/unwind_terminate.rs | 34 ++++ ...const_allocation.main.ConstProp.after.32bit.mir | 14 +- ...const_allocation.main.ConstProp.after.64bit.mir | 18 +- ...onst_allocation2.main.ConstProp.after.32bit.mir | 12 +- ...onst_allocation2.main.ConstProp.after.64bit.mir | 14 +- ...onst_allocation3.main.ConstProp.after.32bit.mir | 6 +- ...onst_allocation3.main.ConstProp.after.64bit.mir | 6 +- tests/mir-opt/const_prop/address_of_pair.rs | 15 +- .../aggregate.foo.PreCodegen.after.panic-abort.mir | 49 ----- ...aggregate.foo.PreCodegen.after.panic-unwind.mir | 49 ----- ...aggregate.main.PreCodegen.after.panic-abort.mir | 36 ---- ...ggregate.main.PreCodegen.after.panic-unwind.mir | 36 ---- tests/mir-opt/const_prop/aggregate.rs | 18 +- tests/mir-opt/const_prop/array_index.rs | 6 +- tests/mir-opt/const_prop/bad_op_div_by_zero.rs | 10 +- tests/mir-opt/const_prop/bad_op_mod_by_zero.rs | 9 +- .../const_prop/bad_op_unsafe_oob_for_slices.rs | 5 +- tests/mir-opt/const_prop/boolean_identities.rs | 12 +- .../boolean_identities.test.ConstProp.diff | 32 ++- tests/mir-opt/const_prop/boxes.rs | 6 +- tests/mir-opt/const_prop/cast.rs | 7 +- tests/mir-opt/const_prop/checked_add.rs | 5 +- ...ails_gracefully.main.ConstProp.panic-abort.diff | 38 ---- ...ils_gracefully.main.ConstProp.panic-unwind.diff | 38 ---- .../const_prop/const_prop_fails_gracefully.rs | 12 -- tests/mir-opt/const_prop/discriminant.rs | 15 +- tests/mir-opt/const_prop/indirect.rs | 4 +- ...nherit_overflow.main.ConstProp.panic-abort.diff | 2 +- ...herit_overflow.main.ConstProp.panic-unwind.diff | 2 +- tests/mir-opt/const_prop/inherit_overflow.rs | 9 +- .../issue_66971.main.ConstProp.panic-abort.diff | 11 +- .../issue_66971.main.ConstProp.panic-unwind.diff | 11 +- tests/mir-opt/const_prop/issue_66971.rs | 4 +- .../issue_67019.main.ConstProp.panic-abort.diff | 3 + .../issue_67019.main.ConstProp.panic-unwind.diff | 3 + tests/mir-opt/const_prop/issue_67019.rs | 4 +- tests/mir-opt/const_prop/mult_by_zero.rs | 7 +- tests/mir-opt/const_prop/mutable_variable.rs | 7 +- .../const_prop/mutable_variable_aggregate.rs | 7 +- .../mutable_variable_aggregate_mut_ref.rs | 9 +- .../mutable_variable_aggregate_partial_read.rs | 8 +- .../mir-opt/const_prop/mutable_variable_no_prop.rs | 9 +- .../const_prop/mutable_variable_unprop_assign.rs | 14 +- ..._expose_address.main.ConstProp.panic-abort.diff | 38 ++++ ...expose_address.main.ConstProp.panic-unwind.diff | 38 ++++ tests/mir-opt/const_prop/pointer_expose_address.rs | 18 ++ tests/mir-opt/const_prop/read_immutable_static.rs | 4 +- .../const_prop/ref_deref.main.ConstProp.diff | 5 +- tests/mir-opt/const_prop/ref_deref.rs | 8 +- .../ref_deref_project.main.ConstProp.diff | 5 +- tests/mir-opt/const_prop/ref_deref_project.rs | 9 +- tests/mir-opt/const_prop/reify_fn_ptr.rs | 5 +- tests/mir-opt/const_prop/repeat.rs | 4 +- tests/mir-opt/const_prop/return_place.rs | 3 +- .../const_prop/scalar_literal_propagation.rs | 4 +- ...slice_len.main.ConstProp.32bit.panic-abort.diff | 5 +- ...lice_len.main.ConstProp.32bit.panic-unwind.diff | 5 +- ...slice_len.main.ConstProp.64bit.panic-abort.diff | 5 +- ...lice_len.main.ConstProp.64bit.panic-unwind.diff | 5 +- tests/mir-opt/const_prop/slice_len.rs | 9 +- tests/mir-opt/const_prop/switch_int.rs | 9 +- .../const_prop/tuple_literal_propagation.rs | 5 +- tests/mir-opt/const_prop/while_let_loops.rs | 3 +- tests/mir-opt/copy-prop/borrowed_local.rs | 4 +- tests/mir-opt/copy-prop/calls.rs | 2 +- tests/mir-opt/copy-prop/custom_move_arg.rs | 4 +- tests/mir-opt/copy-prop/move_projection.rs | 4 +- ...ne_tiny.main-{closure#0}.coroutine_resume.0.mir | 3 + ...xed_slice.main.ConstProp.32bit.panic-abort.diff | 8 +- ...ed_slice.main.ConstProp.32bit.panic-unwind.diff | 8 +- ...xed_slice.main.ConstProp.64bit.panic-abort.diff | 8 +- ...ed_slice.main.ConstProp.64bit.panic-unwind.diff | 8 +- ...e.main.DataflowConstProp.32bit.panic-abort.diff | 8 +- ....main.DataflowConstProp.32bit.panic-unwind.diff | 8 +- ...e.main.DataflowConstProp.64bit.panic-abort.diff | 8 +- ....main.DataflowConstProp.64bit.panic-unwind.diff | 8 +- .../enum.statics.DataflowConstProp.32bit.diff | 2 +- .../enum.statics.DataflowConstProp.64bit.diff | 2 +- ...verflow.main.DataflowConstProp.panic-abort.diff | 2 +- ...erflow.main.DataflowConstProp.panic-unwind.diff | 2 +- ...ing_ptr.main.DataflowConstProp.panic-abort.diff | 2 +- ...ng_ptr.main.DataflowConstProp.panic-unwind.diff | 2 +- .../struct.main.DataflowConstProp.32bit.diff | 8 +- .../struct.main.DataflowConstProp.64bit.diff | 8 +- .../dead-store-elimination/call_arg_copy.rs | 2 +- tests/mir-opt/dead-store-elimination/cycle.rs | 4 +- ...al_or.match_tuple.SimplifyCfg-initial.after.mir | 14 +- ...vn.constant_index_overflow.GVN.panic-abort.diff | 104 ++++++++++ ...n.constant_index_overflow.GVN.panic-unwind.diff | 104 ++++++++++ tests/mir-opt/gvn.rs | 30 ++- ...xponential_runtime.main.Inline.panic-abort.diff | 44 ++-- ...ponential_runtime.main.Inline.panic-unwind.diff | 44 ++-- tests/mir-opt/inline/indirect_destination.rs | 42 ++++ .../inline_coroutine.main.Inline.panic-abort.diff | 23 ++- .../inline_coroutine.main.Inline.panic-unwind.diff | 75 +++---- ...ine_into_box_place.main.Inline.panic-abort.diff | 209 ------------------- ...ne_into_box_place.main.Inline.panic-unwind.diff | 222 --------------------- tests/mir-opt/inline/inline_into_box_place.rs | 11 - ...reading.identity.JumpThreading.panic-abort.diff | 36 ++-- ...eading.identity.JumpThreading.panic-unwind.diff | 36 ++-- tests/mir-opt/jump_threading.rs | 18 +- ...option_payload.LowerIntrinsics.panic-abort.diff | 48 ----- ...ption_payload.LowerIntrinsics.panic-unwind.diff | 48 ----- tests/mir-opt/lower_intrinsics.rs | 12 -- .../match_test.main.SimplifyCfg-initial.after.mir | 28 +-- ...nvalid_constant.main.GVN.32bit.panic-abort.diff | 4 +- ...valid_constant.main.GVN.32bit.panic-unwind.diff | 4 +- ...nvalid_constant.main.GVN.64bit.panic-abort.diff | 4 +- ...valid_constant.main.GVN.64bit.panic-unwind.diff | 4 +- .../loops.int_range.PreCodegen.after.mir | 2 +- .../mem_replace.mem_replace.PreCodegen.after.mir | 10 +- ...r.forward_loop.PreCodegen.after.panic-abort.mir | 2 +- ....forward_loop.PreCodegen.after.panic-unwind.mir | 2 +- ...ange_iter_next.PreCodegen.after.panic-abort.mir | 2 +- ...nge_iter_next.PreCodegen.after.panic-unwind.mir | 2 +- ...lter.variant_a-{closure#0}.PreCodegen.after.mir | 16 +- ..._get_mut_usize.PreCodegen.after.panic-abort.mir | 43 ++-- ...get_mut_usize.PreCodegen.after.panic-unwind.mir | 43 ++-- ...cked_mut_range.PreCodegen.after.panic-abort.mir | 85 ++++---- ...ked_mut_range.PreCodegen.after.panic-unwind.mir | 85 ++++---- ...numerated_loop.PreCodegen.after.panic-abort.mir | 10 +- ...umerated_loop.PreCodegen.after.panic-unwind.mir | 10 +- ...r.forward_loop.PreCodegen.after.panic-abort.mir | 10 +- ....forward_loop.PreCodegen.after.panic-unwind.mir | 10 +- ...ter.range_loop.PreCodegen.after.panic-abort.mir | 2 +- ...er.range_loop.PreCodegen.after.panic-unwind.mir | 2 +- ...r.reverse_loop.PreCodegen.after.panic-abort.mir | 10 +- ....reverse_loop.PreCodegen.after.panic-unwind.mir | 10 +- tests/mir-opt/reference_prop.rs | 10 +- ...mplifyCfg-elaborate-drops.after.panic-abort.mir | 4 +- ...plifyCfg-elaborate-drops.after.panic-unwind.mir | 4 +- ..._const_switch.identity.SeparateConstSwitch.diff | 26 +-- 135 files changed, 1216 insertions(+), 1353 deletions(-) create mode 100644 tests/mir-opt/building/custom/unwind_action.rs create mode 100644 tests/mir-opt/building/custom/unwind_terminate.rs delete mode 100644 tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-abort.mir delete mode 100644 tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-unwind.mir delete mode 100644 tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-abort.mir delete mode 100644 tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir delete mode 100644 tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-abort.diff delete mode 100644 tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-unwind.diff delete mode 100644 tests/mir-opt/const_prop/const_prop_fails_gracefully.rs create mode 100644 tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-abort.diff create mode 100644 tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-unwind.diff create mode 100644 tests/mir-opt/const_prop/pointer_expose_address.rs create mode 100644 tests/mir-opt/gvn.constant_index_overflow.GVN.panic-abort.diff create mode 100644 tests/mir-opt/gvn.constant_index_overflow.GVN.panic-unwind.diff create mode 100644 tests/mir-opt/inline/indirect_destination.rs delete mode 100644 tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff delete mode 100644 tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff delete mode 100644 tests/mir-opt/inline/inline_into_box_place.rs delete mode 100644 tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.panic-abort.diff delete mode 100644 tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.panic-unwind.diff (limited to 'tests/mir-opt') diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir index 396e4a378..59e275124 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir @@ -14,7 +14,7 @@ Static, ), source_info: SourceInfo { - span: $DIR/async_await.rs:16:9: 16:14 (#8), + span: $DIR/async_await.rs:16:5: 16:14 (#9), scope: scope[0], }, ignore_for_traits: false, @@ -32,7 +32,7 @@ Static, ), source_info: SourceInfo { - span: $DIR/async_await.rs:17:9: 17:14 (#10), + span: $DIR/async_await.rs:17:5: 17:14 (#11), scope: scope[0], }, ignore_for_traits: false, @@ -178,6 +178,10 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:15:18: 18:2}>, StorageLive(_20); _20 = (); _0 = Poll::<()>::Pending; + StorageDead(_3); + StorageDead(_4); + StorageDead(_19); + StorageDead(_20); discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2}))) = 3; return; } @@ -276,6 +280,9 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:15:18: 18:2}>, StorageLive(_36); _36 = (); _0 = Poll::<()>::Pending; + StorageDead(_21); + StorageDead(_35); + StorageDead(_36); discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2}))) = 4; return; } diff --git a/tests/mir-opt/building/custom/terminators.rs b/tests/mir-opt/building/custom/terminators.rs index 9e442e0f9..a83a6c074 100644 --- a/tests/mir-opt/building/custom/terminators.rs +++ b/tests/mir-opt/building/custom/terminators.rs @@ -13,7 +13,7 @@ fn ident(t: T) -> T { fn direct_call(x: i32) -> i32 { mir!( { - Call(RET = ident(x), retblock) + Call(RET = ident(x), retblock, UnwindContinue()) } retblock = { @@ -27,7 +27,7 @@ fn direct_call(x: i32) -> i32 { fn indirect_call(x: i32, f: fn(i32) -> i32) -> i32 { mir!( { - Call(RET = f(x), retblock) + Call(RET = f(x), retblock, UnwindContinue()) } retblock = { @@ -49,7 +49,7 @@ impl<'a> Drop for WriteOnDrop<'a> { fn drop_first<'a>(a: WriteOnDrop<'a>, b: WriteOnDrop<'a>) { mir!( { - Drop(a, retblock) + Drop(a, retblock, UnwindContinue()) } retblock = { @@ -64,7 +64,7 @@ fn drop_first<'a>(a: WriteOnDrop<'a>, b: WriteOnDrop<'a>) { fn drop_second<'a>(a: WriteOnDrop<'a>, b: WriteOnDrop<'a>) { mir!( { - Drop(b, retblock) + Drop(b, retblock, UnwindContinue()) } retblock = { diff --git a/tests/mir-opt/building/custom/unwind_action.rs b/tests/mir-opt/building/custom/unwind_action.rs new file mode 100644 index 000000000..e3c4ffac3 --- /dev/null +++ b/tests/mir-opt/building/custom/unwind_action.rs @@ -0,0 +1,68 @@ +// compile-flags: --crate-type=lib +// edition:2021 +// needs-unwind +#![feature(custom_mir, core_intrinsics)] +use core::intrinsics::mir::*; + +// CHECK-LABEL: fn a() +// CHECK: bb0: { +// CHECK-NEXT: a() -> [return: bb1, unwind unreachable]; +#[custom_mir(dialect = "runtime", phase = "optimized")] +pub fn a() { + mir!( + { + Call(RET = a(), bb1, UnwindUnreachable()) + } + bb1 = { + Return() + } + ) +} + +// CHECK-LABEL: fn b() +// CHECK: bb0: { +// CHECK-NEXT: b() -> [return: bb1, unwind continue]; +#[custom_mir(dialect = "runtime", phase = "optimized")] +pub fn b() { + mir!( + { + Call(RET = b(), bb1, UnwindContinue()) + } + bb1 = { + Return() + } + ) +} + +// CHECK-LABEL: fn c() +// CHECK: bb0: { +// CHECK-NEXT: c() -> [return: bb1, unwind terminate(abi)]; +#[custom_mir(dialect = "runtime", phase = "optimized")] +pub fn c() { + mir!( + { + Call(RET = c(), bb1, UnwindTerminate(ReasonAbi)) + } + bb1 = { + Return() + } + ) +} + +// CHECK-LABEL: fn d() +// CHECK: bb0: { +// CHECK-NEXT: d() -> [return: bb1, unwind: bb2]; +#[custom_mir(dialect = "runtime", phase = "optimized")] +pub fn d() { + mir!( + { + Call(RET = d(), bb1, UnwindCleanup(bb2)) + } + bb1 = { + Return() + } + bb2 (cleanup) = { + UnwindResume() + } + ) +} diff --git a/tests/mir-opt/building/custom/unwind_terminate.rs b/tests/mir-opt/building/custom/unwind_terminate.rs new file mode 100644 index 000000000..efdf2ddb1 --- /dev/null +++ b/tests/mir-opt/building/custom/unwind_terminate.rs @@ -0,0 +1,34 @@ +// compile-flags: --crate-type=lib +// edition:2021 +#![feature(custom_mir, core_intrinsics)] +use core::intrinsics::mir::*; + +// CHECK-LABEL: fn f() +// CHECK: bb1 (cleanup): { +// CHECK-NEXT: terminate(abi); +#[custom_mir(dialect = "runtime", phase = "optimized")] +pub fn f() { + mir!( + { + Return() + } + bb1(cleanup) = { + UnwindTerminate(ReasonAbi) + } + ) +} + +// CHECK-LABEL: fn g() +// CHECK: bb1 (cleanup): { +// CHECK-NEXT: terminate(cleanup); +#[custom_mir(dialect = "runtime", phase = "optimized")] +pub fn g() { + mir!( + { + Return() + } + bb1(cleanup) = { + UnwindTerminate(ReasonInCleanup) + } + ) +} diff --git a/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir b/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir index f20bfef8c..9cc4c7c4d 100644 --- a/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir +++ b/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir @@ -18,19 +18,19 @@ fn main() -> () { } ALLOC9 (static: FOO, size: 8, align: 4) { - ╾ALLOC0╼ 03 00 00 00 │ ╾──╼.... + ╾ALLOC0╼ 03 00 00 00 │ ╾──╼.... } ALLOC0 (size: 48, align: 4) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC1╼ 00 00 00 00 │ ....░░░░╾──╼.... - 0x10 │ 00 00 00 00 __ __ __ __ ╾ALLOC2╼ 02 00 00 00 │ ....░░░░╾──╼.... - 0x20 │ 01 00 00 00 2a 00 00 00 ╾ALLOC3╼ 03 00 00 00 │ ....*...╾──╼.... + 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC1╼ 00 00 00 00 │ ....░░░░╾──╼.... + 0x10 │ 00 00 00 00 __ __ __ __ ╾ALLOC2╼ 02 00 00 00 │ ....░░░░╾──╼.... + 0x20 │ 01 00 00 00 2a 00 00 00 ╾ALLOC3╼ 03 00 00 00 │ ....*...╾──╼.... } ALLOC1 (size: 0, align: 4) {} ALLOC2 (size: 16, align: 4) { - ╾ALLOC4╼ 03 00 00 00 ╾ALLOC5╼ 03 00 00 00 │ ╾──╼....╾──╼.... + ╾ALLOC4╼ 03 00 00 00 ╾ALLOC5╼ 03 00 00 00 │ ╾──╼....╾──╼.... } ALLOC4 (size: 3, align: 1) { @@ -42,8 +42,8 @@ ALLOC5 (size: 3, align: 1) { } ALLOC3 (size: 24, align: 4) { - 0x00 │ ╾ALLOC6╼ 03 00 00 00 ╾ALLOC7╼ 03 00 00 00 │ ╾──╼....╾──╼.... - 0x10 │ ╾ALLOC8╼ 04 00 00 00 │ ╾──╼.... + 0x00 │ ╾ALLOC6╼ 03 00 00 00 ╾ALLOC7╼ 03 00 00 00 │ ╾──╼....╾──╼.... + 0x10 │ ╾ALLOC8╼ 04 00 00 00 │ ╾──╼.... } ALLOC6 (size: 3, align: 1) { diff --git a/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir b/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir index 263cae2f3..faa9d20f2 100644 --- a/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir +++ b/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir @@ -18,22 +18,22 @@ fn main() -> () { } ALLOC9 (static: FOO, size: 16, align: 8) { - ╾ALLOC0╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + ╾ALLOC0╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ } ALLOC0 (size: 72, align: 8) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC1╼ │ ....░░░░╾──────╼ + 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC1╼ │ ....░░░░╾──────╼ 0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ │ ............░░░░ - 0x20 │ ╾ALLOC2╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x30 │ 01 00 00 00 2a 00 00 00 ╾ALLOC3╼ │ ....*...╾──────╼ + 0x20 │ ╾ALLOC2╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x30 │ 01 00 00 00 2a 00 00 00 ╾ALLOC3╼ │ ....*...╾──────╼ 0x40 │ 03 00 00 00 00 00 00 00 │ ........ } ALLOC1 (size: 0, align: 8) {} ALLOC2 (size: 32, align: 8) { - 0x00 │ ╾ALLOC4╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x10 │ ╾ALLOC5╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x00 │ ╾ALLOC4╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x10 │ ╾ALLOC5╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ } ALLOC4 (size: 3, align: 1) { @@ -45,9 +45,9 @@ ALLOC5 (size: 3, align: 1) { } ALLOC3 (size: 48, align: 8) { - 0x00 │ ╾ALLOC6╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x10 │ ╾ALLOC7╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x20 │ ╾ALLOC8╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x00 │ ╾ALLOC6╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x10 │ ╾ALLOC7╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x20 │ ╾ALLOC8╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } ALLOC6 (size: 3, align: 1) { diff --git a/tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir b/tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir index 713abb264..898835b46 100644 --- a/tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir +++ b/tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir @@ -18,19 +18,19 @@ fn main() -> () { } ALLOC9 (static: FOO, size: 8, align: 4) { - ╾ALLOC0╼ 03 00 00 00 │ ╾──╼.... + ╾ALLOC0╼ 03 00 00 00 │ ╾──╼.... } ALLOC0 (size: 48, align: 4) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC1╼ 00 00 00 00 │ ....░░░░╾──╼.... - 0x10 │ 00 00 00 00 __ __ __ __ ╾ALLOC2╼ 02 00 00 00 │ ....░░░░╾──╼.... - 0x20 │ 01 00 00 00 2a 00 00 00 ╾ALLOC3╼ 03 00 00 00 │ ....*...╾──╼.... + 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC1╼ 00 00 00 00 │ ....░░░░╾──╼.... + 0x10 │ 00 00 00 00 __ __ __ __ ╾ALLOC2╼ 02 00 00 00 │ ....░░░░╾──╼.... + 0x20 │ 01 00 00 00 2a 00 00 00 ╾ALLOC3╼ 03 00 00 00 │ ....*...╾──╼.... } ALLOC1 (size: 0, align: 4) {} ALLOC2 (size: 8, align: 4) { - ╾ALLOC4╼ ╾ALLOC5╼ │ ╾──╼╾──╼ + ╾ALLOC4╼ ╾ALLOC5╼ │ ╾──╼╾──╼ } ALLOC4 (size: 1, align: 1) { @@ -42,7 +42,7 @@ ALLOC5 (size: 1, align: 1) { } ALLOC3 (size: 12, align: 4) { - ╾ALLOC6+0x3╼ ╾ALLOC7╼ ╾ALLOC8+0x2╼ │ ╾──╼╾──╼╾──╼ + ╾ALLOC6+0x3╼ ╾ALLOC7╼ ╾ALLOC8+0x2╼ │ ╾──╼╾──╼╾──╼ } ALLOC6 (size: 4, align: 1) { diff --git a/tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir b/tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir index e9d61ef12..f5352c2ae 100644 --- a/tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir +++ b/tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir @@ -18,21 +18,21 @@ fn main() -> () { } ALLOC9 (static: FOO, size: 16, align: 8) { - ╾ALLOC0╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + ╾ALLOC0╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ } ALLOC0 (size: 72, align: 8) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC1╼ │ ....░░░░╾──────╼ + 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC1╼ │ ....░░░░╾──────╼ 0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ │ ............░░░░ - 0x20 │ ╾ALLOC2╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x30 │ 01 00 00 00 2a 00 00 00 ╾ALLOC3╼ │ ....*...╾──────╼ + 0x20 │ ╾ALLOC2╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x30 │ 01 00 00 00 2a 00 00 00 ╾ALLOC3╼ │ ....*...╾──────╼ 0x40 │ 03 00 00 00 00 00 00 00 │ ........ } ALLOC1 (size: 0, align: 8) {} ALLOC2 (size: 16, align: 8) { - ╾ALLOC4╼ ╾ALLOC5╼ │ ╾──────╼╾──────╼ + ╾ALLOC4╼ ╾ALLOC5╼ │ ╾──────╼╾──────╼ } ALLOC4 (size: 1, align: 1) { @@ -44,8 +44,8 @@ ALLOC5 (size: 1, align: 1) { } ALLOC3 (size: 24, align: 8) { - 0x00 │ ╾ALLOC6+0x3╼ ╾ALLOC7╼ │ ╾──────╼╾──────╼ - 0x10 │ ╾ALLOC8+0x2╼ │ ╾──────╼ + 0x00 │ ╾ALLOC6+0x3╼ ╾ALLOC7╼ │ ╾──────╼╾──────╼ + 0x10 │ ╾ALLOC8+0x2╼ │ ╾──────╼ } ALLOC6 (size: 4, align: 1) { diff --git a/tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir b/tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir index c18c067c7..624047f5b 100644 --- a/tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir +++ b/tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir @@ -18,12 +18,12 @@ fn main() -> () { } ALLOC4 (static: FOO, size: 4, align: 4) { - ╾ALLOC0╼ │ ╾──╼ + ╾ALLOC0╼ │ ╾──╼ } ALLOC0 (size: 168, align: 1) { 0x00 │ ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab │ ................ - 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾ALLOC1╼ │ ............╾──╼ + 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾ALLOC1╼ │ ............╾──╼ 0x20 │ 01 ef cd ab 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x30 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x40 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ @@ -31,7 +31,7 @@ ALLOC0 (size: 168, align: 1) { 0x60 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x70 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x80 │ 00 00 00 00 00 00 00 00 00 00 ╾ALLOC2╼ 00 00 │ ..........╾──╼.. - 0x90 │ ╾ALLOC3+0x63╼ 00 00 00 00 00 00 00 00 00 00 00 00 │ ╾──╼............ + 0x90 │ ╾ALLOC3+0x63╼ 00 00 00 00 00 00 00 00 00 00 00 00 │ ╾──╼............ 0xa0 │ 00 00 00 00 00 00 00 00 │ ........ } diff --git a/tests/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir b/tests/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir index 6af0e3cbd..cdd4758e1 100644 --- a/tests/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir +++ b/tests/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir @@ -18,12 +18,12 @@ fn main() -> () { } ALLOC2 (static: FOO, size: 8, align: 8) { - ╾ALLOC0╼ │ ╾──────╼ + ╾ALLOC0╼ │ ╾──────╼ } ALLOC0 (size: 180, align: 1) { 0x00 │ ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab │ ................ - 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾──ALLOC3── │ ............╾─── + 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾ALLOC3 (8 ptr bytes) │ ............╾─── 0x20 │ ──────────╼ 01 ef cd ab 00 00 00 00 00 00 00 00 │ ───╼............ 0x30 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x40 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ @@ -31,7 +31,7 @@ ALLOC0 (size: 180, align: 1) { 0x60 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x70 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x80 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ╾──── │ ..............╾─ - 0x90 │ ─────ALLOC4─────╼ 00 00 ╾ALLOC1+0x63╼ │ ─────╼..╾──────╼ + 0x90 │ ─────ALLOC4─────╼ 00 00 ╾ALLOC1+0x63╼ │ ─────╼..╾──────╼ 0xa0 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0xb0 │ 00 00 00 00 │ .... } diff --git a/tests/mir-opt/const_prop/address_of_pair.rs b/tests/mir-opt/const_prop/address_of_pair.rs index 169469a07..730ebe2ca 100644 --- a/tests/mir-opt/const_prop/address_of_pair.rs +++ b/tests/mir-opt/const_prop/address_of_pair.rs @@ -1,8 +1,21 @@ -// skip-filecheck // unit-test: ConstProp // EMIT_MIR address_of_pair.fn0.ConstProp.diff pub fn fn0() -> bool { + // CHECK-LABEL: fn fn0( + // CHECK: debug pair => [[pair:_.*]]; + // CHECK: debug ptr => [[ptr:_.*]]; + // CHECK: debug ret => [[ret:_.*]]; + // CHECK: (*[[ptr]]) = const true; + // CHECK-NOT: = const false; + // CHECK-NOT: = const true; + // CHECK: [[tmp:_.*]] = ([[pair]].1: bool); + // CHECK-NOT: = const false; + // CHECK-NOT: = const true; + // CHECK: [[ret]] = Not(move [[tmp]]); + // CHECK-NOT: = const false; + // CHECK-NOT: = const true; + // CHECK: _0 = [[ret]]; let mut pair = (1, false); let ptr = core::ptr::addr_of_mut!(pair.1); pair = (1, false); diff --git a/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-abort.mir b/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-abort.mir deleted file mode 100644 index b9c5859ca..000000000 --- a/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-abort.mir +++ /dev/null @@ -1,49 +0,0 @@ -// MIR for `foo` after PreCodegen - -fn foo(_1: u8) -> () { - debug x => _1; - let mut _0: (); - let _2: i32; - let mut _3: i32; - let mut _4: (i32, u8); - let mut _5: u8; - let mut _7: i32; - let mut _8: (u8, i32); - let mut _9: u8; - scope 1 { - debug first => _2; - let _6: i32; - scope 2 { - debug second => _6; - } - } - - bb0: { - StorageLive(_2); - StorageLive(_3); - StorageLive(_4); - StorageLive(_5); - _5 = _1; - _4 = (const 0_i32, move _5); - StorageDead(_5); - _3 = const 0_i32; - _2 = const 1_i32; - StorageDead(_3); - StorageDead(_4); - StorageLive(_6); - StorageLive(_7); - StorageLive(_8); - StorageLive(_9); - _9 = _1; - _8 = (move _9, const 1_i32); - StorageDead(_9); - _7 = const 1_i32; - _6 = const 3_i32; - StorageDead(_7); - StorageDead(_8); - _0 = const (); - StorageDead(_6); - StorageDead(_2); - return; - } -} diff --git a/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-unwind.mir deleted file mode 100644 index b9c5859ca..000000000 --- a/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-unwind.mir +++ /dev/null @@ -1,49 +0,0 @@ -// MIR for `foo` after PreCodegen - -fn foo(_1: u8) -> () { - debug x => _1; - let mut _0: (); - let _2: i32; - let mut _3: i32; - let mut _4: (i32, u8); - let mut _5: u8; - let mut _7: i32; - let mut _8: (u8, i32); - let mut _9: u8; - scope 1 { - debug first => _2; - let _6: i32; - scope 2 { - debug second => _6; - } - } - - bb0: { - StorageLive(_2); - StorageLive(_3); - StorageLive(_4); - StorageLive(_5); - _5 = _1; - _4 = (const 0_i32, move _5); - StorageDead(_5); - _3 = const 0_i32; - _2 = const 1_i32; - StorageDead(_3); - StorageDead(_4); - StorageLive(_6); - StorageLive(_7); - StorageLive(_8); - StorageLive(_9); - _9 = _1; - _8 = (move _9, const 1_i32); - StorageDead(_9); - _7 = const 1_i32; - _6 = const 3_i32; - StorageDead(_7); - StorageDead(_8); - _0 = const (); - StorageDead(_6); - StorageDead(_2); - return; - } -} diff --git a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-abort.mir b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-abort.mir deleted file mode 100644 index 44a85a563..000000000 --- a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-abort.mir +++ /dev/null @@ -1,36 +0,0 @@ -// MIR for `main` after PreCodegen - -fn main() -> () { - let mut _0: (); - let _1: u8; - let mut _2: u8; - let mut _3: (i32, u8, i32); - let _4: (); - let mut _5: u8; - scope 1 { - debug x => _1; - } - - bb0: { - StorageLive(_1); - StorageLive(_2); - StorageLive(_3); - _3 = (const 0_i32, const 1_u8, const 2_i32); - _2 = const 1_u8; - _1 = const 1_u8; - StorageDead(_2); - StorageDead(_3); - StorageLive(_4); - StorageLive(_5); - _5 = const 1_u8; - _4 = foo(const 1_u8) -> [return: bb1, unwind unreachable]; - } - - bb1: { - StorageDead(_5); - StorageDead(_4); - _0 = const (); - StorageDead(_1); - return; - } -} diff --git a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir deleted file mode 100644 index 2c7bdbb50..000000000 --- a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir +++ /dev/null @@ -1,36 +0,0 @@ -// MIR for `main` after PreCodegen - -fn main() -> () { - let mut _0: (); - let _1: u8; - let mut _2: u8; - let mut _3: (i32, u8, i32); - let _4: (); - let mut _5: u8; - scope 1 { - debug x => _1; - } - - bb0: { - StorageLive(_1); - StorageLive(_2); - StorageLive(_3); - _3 = (const 0_i32, const 1_u8, const 2_i32); - _2 = const 1_u8; - _1 = const 1_u8; - StorageDead(_2); - StorageDead(_3); - StorageLive(_4); - StorageLive(_5); - _5 = const 1_u8; - _4 = foo(const 1_u8) -> [return: bb1, unwind continue]; - } - - bb1: { - StorageDead(_5); - StorageDead(_4); - _0 = const (); - StorageDead(_1); - return; - } -} diff --git a/tests/mir-opt/const_prop/aggregate.rs b/tests/mir-opt/const_prop/aggregate.rs index 2e043af08..fa716b084 100644 --- a/tests/mir-opt/const_prop/aggregate.rs +++ b/tests/mir-opt/const_prop/aggregate.rs @@ -1,19 +1,29 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -O // EMIT_MIR aggregate.main.ConstProp.diff -// EMIT_MIR aggregate.main.PreCodegen.after.mir fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug x => [[x:_.*]]; + // CHECK-NOT: = Add( + // CHECK: [[x]] = const 1_u8; + // CHECK-NOT: = Add( + // CHECK: foo(const 1_u8) let x = (0, 1, 2).1 + 0; foo(x); } +// Verify that we still propagate if part of the aggregate is not known. // EMIT_MIR aggregate.foo.ConstProp.diff -// EMIT_MIR aggregate.foo.PreCodegen.after.mir fn foo(x: u8) { - // Verify that we still propagate if part of the aggregate is not known. + // CHECK-LABEL: fn foo( + // CHECK: debug first => [[first:_.*]]; + // CHECK: debug second => [[second:_.*]]; + // CHECK-NOT: = Add( + // CHECK: [[first]] = const 1_i32; + // CHECK-NOT: = Add( + // CHECK: [[second]] = const 3_i32; let first = (0, x).0 + 1; let second = (x, 1).1 + 2; } diff --git a/tests/mir-opt/const_prop/array_index.rs b/tests/mir-opt/const_prop/array_index.rs index 3bd232165..c4c46d78f 100644 --- a/tests/mir-opt/const_prop/array_index.rs +++ b/tests/mir-opt/const_prop/array_index.rs @@ -1,9 +1,11 @@ -// skip-filecheck -// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR array_index.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug x => [[x:_.*]]; + // CHECK: [[x]] = const 2_u32; let x: u32 = [0, 1, 2, 3][2]; } diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.rs b/tests/mir-opt/const_prop/bad_op_div_by_zero.rs index ab41f64a5..0e8765a07 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.rs +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.rs @@ -1,9 +1,15 @@ -// skip-filecheck -// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY + // EMIT_MIR bad_op_div_by_zero.main.ConstProp.diff #[allow(unconditional_panic)] fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug y => [[y:_.*]]; + // CHECK: debug _z => [[z:_.*]]; + // CHECK: assert(!const true, "attempt to divide `{}` by zero", const 1_i32) + // CHECK: assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, const 0_i32) + // CHECK: [[z]] = Div(const 1_i32, const 0_i32); let y = 0; let _z = 1 / y; } diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs index e747b21cf..d895d9e21 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs @@ -1,9 +1,16 @@ -// skip-filecheck // unit-test: ConstProp // EMIT_MIR_FOR_EACH_PANIC_STRATEGY + // EMIT_MIR bad_op_mod_by_zero.main.ConstProp.diff #[allow(unconditional_panic)] fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug y => [[y:_.*]]; + // CHECK: debug _z => [[z:_.*]]; + // CHECK: assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of + // zero", const 1_i32) + // CHECK: assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, const 0_i32) + // CHECK: [[z]] = Rem(const 1_i32, const 0_i32); let y = 0; let _z = 1 % y; } diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs index 38c97a4cf..266105c11 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs @@ -1,4 +1,3 @@ -// skip-filecheck // unit-test: ConstProp // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH @@ -6,6 +5,10 @@ // EMIT_MIR bad_op_unsafe_oob_for_slices.main.ConstProp.diff #[allow(unconditional_panic)] fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug _b => [[b:_.*]]; + // CHECK: [[b]] = (*[[a]])[3 of 4]; let a: *const [_] = &[1, 2, 3]; unsafe { let _b = (*a)[3]; diff --git a/tests/mir-opt/const_prop/boolean_identities.rs b/tests/mir-opt/const_prop/boolean_identities.rs index 781cce8c7..2aa038034 100644 --- a/tests/mir-opt/const_prop/boolean_identities.rs +++ b/tests/mir-opt/const_prop/boolean_identities.rs @@ -1,10 +1,16 @@ -// skip-filecheck // unit-test: ConstProp -// compile-flags: -O -Zmir-opt-level=4 // EMIT_MIR boolean_identities.test.ConstProp.diff pub fn test(x: bool, y: bool) -> bool { - (y | true) & (x & false) + // CHECK-LABEL: fn test( + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug b => [[b:_.*]]; + // CHECK: [[a]] = const true; + // CHECK: [[b]] = const false; + // CHECK: _0 = const false; + let a = (y | true); + let b = (x & false); + a & b } fn main() { diff --git a/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff b/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff index d80534199..41e1acdff 100644 --- a/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff +++ b/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff @@ -5,20 +5,42 @@ debug x => _1; debug y => _2; let mut _0: bool; - let mut _3: bool; + let _3: bool; let mut _4: bool; - let mut _5: bool; let mut _6: bool; + let mut _7: bool; + let mut _8: bool; + scope 1 { + debug a => _3; + let _5: bool; + scope 2 { + debug b => _5; + } + } bb0: { StorageLive(_3); -- _3 = BitOr(_2, const true); + StorageLive(_4); + _4 = _2; +- _3 = BitOr(move _4, const true); + _3 = const true; + StorageDead(_4); StorageLive(_5); -- _5 = BitAnd(_1, const false); -- _0 = BitAnd(move _3, move _5); + StorageLive(_6); + _6 = _1; +- _5 = BitAnd(move _6, const false); + _5 = const false; + StorageDead(_6); + StorageLive(_7); +- _7 = _3; ++ _7 = const true; + StorageLive(_8); +- _8 = _5; +- _0 = BitAnd(move _7, move _8); ++ _8 = const false; + _0 = const false; + StorageDead(_8); + StorageDead(_7); StorageDead(_5); StorageDead(_3); return; diff --git a/tests/mir-opt/const_prop/boxes.rs b/tests/mir-opt/const_prop/boxes.rs index c6807ece1..90a8e33e8 100644 --- a/tests/mir-opt/const_prop/boxes.rs +++ b/tests/mir-opt/const_prop/boxes.rs @@ -1,4 +1,3 @@ -// skip-filecheck // unit-test: ConstProp // compile-flags: -O // EMIT_MIR_FOR_EACH_PANIC_STRATEGY @@ -9,6 +8,11 @@ // EMIT_MIR boxes.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug x => [[x:_.*]]; + // CHECK: (*{{_.*}}) = const 42_i32; + // CHECK: [[tmp:_.*]] = (*{{_.*}}); + // CHECK: [[x]] = Add(move [[tmp]], const 0_i32); let x = *(#[rustc_box] Box::new(42)) + 0; diff --git a/tests/mir-opt/const_prop/cast.rs b/tests/mir-opt/const_prop/cast.rs index 3d543bada..b81c2740a 100644 --- a/tests/mir-opt/const_prop/cast.rs +++ b/tests/mir-opt/const_prop/cast.rs @@ -1,9 +1,12 @@ -// skip-filecheck // unit-test: ConstProp // EMIT_MIR cast.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug x => [[x:_.*]]; + // CHECK: debug y => [[y:_.*]]; + // CHECK: [[x]] = const 42_u32; + // CHECK: [[y]] = const 42_u8; let x = 42u8 as u32; - let y = 42u32 as u8; } diff --git a/tests/mir-opt/const_prop/checked_add.rs b/tests/mir-opt/const_prop/checked_add.rs index 6a53aced0..571a5cc4e 100644 --- a/tests/mir-opt/const_prop/checked_add.rs +++ b/tests/mir-opt/const_prop/checked_add.rs @@ -1,9 +1,12 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -C overflow-checks=on // EMIT_MIR checked_add.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug x => [[x:_.*]]; + // CHECK: assert(!const false, + // CHECK: [[x]] = const 2_u32; let x: u32 = 1 + 1; } diff --git a/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-abort.diff deleted file mode 100644 index bd1de7476..000000000 --- a/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-abort.diff +++ /dev/null @@ -1,38 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); - let _1: usize; - let mut _2: *const i32; - let _3: &i32; - let _4: (); - let mut _5: usize; - scope 1 { - debug x => _1; - } - - bb0: { - StorageLive(_1); - StorageLive(_2); - StorageLive(_3); - _3 = const _; - _2 = &raw const (*_3); - _1 = move _2 as usize (PointerExposeAddress); - StorageDead(_2); - StorageDead(_3); - StorageLive(_4); - StorageLive(_5); - _5 = _1; - _4 = read(move _5) -> [return: bb1, unwind unreachable]; - } - - bb1: { - StorageDead(_5); - StorageDead(_4); - _0 = const (); - StorageDead(_1); - return; - } - } - diff --git a/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-unwind.diff deleted file mode 100644 index 850b743fe..000000000 --- a/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-unwind.diff +++ /dev/null @@ -1,38 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); - let _1: usize; - let mut _2: *const i32; - let _3: &i32; - let _4: (); - let mut _5: usize; - scope 1 { - debug x => _1; - } - - bb0: { - StorageLive(_1); - StorageLive(_2); - StorageLive(_3); - _3 = const _; - _2 = &raw const (*_3); - _1 = move _2 as usize (PointerExposeAddress); - StorageDead(_2); - StorageDead(_3); - StorageLive(_4); - StorageLive(_5); - _5 = _1; - _4 = read(move _5) -> [return: bb1, unwind continue]; - } - - bb1: { - StorageDead(_5); - StorageDead(_4); - _0 = const (); - StorageDead(_1); - return; - } - } - diff --git a/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs b/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs deleted file mode 100644 index 5bd4731bf..000000000 --- a/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs +++ /dev/null @@ -1,12 +0,0 @@ -// skip-filecheck -// EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp -#[inline(never)] -fn read(_: usize) { } - -// EMIT_MIR const_prop_fails_gracefully.main.ConstProp.diff -fn main() { - const FOO: &i32 = &1; - let x = FOO as *const i32 as usize; - read(x); -} diff --git a/tests/mir-opt/const_prop/discriminant.rs b/tests/mir-opt/const_prop/discriminant.rs index 11405f38b..0ed683d62 100644 --- a/tests/mir-opt/const_prop/discriminant.rs +++ b/tests/mir-opt/const_prop/discriminant.rs @@ -1,6 +1,4 @@ -// skip-filecheck // unit-test: ConstProp -// compile-flags: -O // FIXME(wesleywiser): Ideally, we could const-prop away all of this and just be left with // `let x = 42` but that doesn't work because const-prop doesn't support `Operand::Indirect` @@ -10,5 +8,18 @@ // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR discriminant.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: bb0: { + // CHECK: switchInt(const 1_isize) -> [1: bb1, otherwise: bb3]; + // CHECK: bb1: { + // CHECK: switchInt(const true) -> [0: bb3, otherwise: bb2]; + // CHECK: bb2: { + // CHECK: [[tmp:_.*]] = const 42_i32; + // CHECK: goto -> bb4; + // CHECK: bb3: { + // CHECK: [[tmp]] = const 10_i32; + // CHECK: goto -> bb4; + // CHECK: bb4: { + // CHECK: {{_.*}} = Add(move [[tmp]], const 0_i32); let x = (if let Some(true) = Some(true) { 42 } else { 10 }) + 0; } diff --git a/tests/mir-opt/const_prop/indirect.rs b/tests/mir-opt/const_prop/indirect.rs index 0e6e1d78d..d3c42e3eb 100644 --- a/tests/mir-opt/const_prop/indirect.rs +++ b/tests/mir-opt/const_prop/indirect.rs @@ -1,9 +1,11 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -C overflow-checks=on // EMIT_MIR indirect.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug x => [[x:_.*]]; + // CHECK: [[x]] = const 3_u8; let x = (2u32 as u8) + 1; } diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff index b30deb2a4..11cdf9e09 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff @@ -8,7 +8,7 @@ let mut _3: u8; scope 1 { } - scope 2 (inlined ::add) { + scope 2 (inlined #[track_caller] ::add) { debug self => _2; debug other => _3; let mut _4: (u8, bool); diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff index 47c51196c..181a2f287 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff @@ -8,7 +8,7 @@ let mut _3: u8; scope 1 { } - scope 2 (inlined ::add) { + scope 2 (inlined #[track_caller] ::add) { debug self => _2; debug other => _3; let mut _4: (u8, bool); diff --git a/tests/mir-opt/const_prop/inherit_overflow.rs b/tests/mir-opt/const_prop/inherit_overflow.rs index 41989462d..5b561ae14 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.rs +++ b/tests/mir-opt/const_prop/inherit_overflow.rs @@ -1,11 +1,14 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -Zmir-enable-passes=+Inline +// After inlining, this will contain a `CheckedBinaryOp`. +// Propagating the overflow is ok as codegen will just skip emitting the panic. // EMIT_MIR inherit_overflow.main.ConstProp.diff fn main() { - // After inlining, this will contain a `CheckedBinaryOp`. - // Propagating the overflow is ok as codegen will just skip emitting the panic. + // CHECK-LABEL: fn main( + // CHECK: {{_.*}} = const (0_u8, true); + // CHECK: assert(!const true, + // CHECK: {{_.*}} = const 0_u8; let _ = ::add(255, 1); } diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff index 6484b4b67..ff93c85e5 100644 --- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff @@ -5,17 +5,24 @@ let mut _0: (); let _1: (); let mut _2: ((), u8, u8); + let mut _3: (); bb0: { + StorageLive(_1); StorageLive(_2); -- _2 = (const (), const 0_u8, const 0_u8); -- _1 = encode(move _2) -> [return: bb1, unwind unreachable]; + StorageLive(_3); + _3 = (); +- _2 = (move _3, const 0_u8, const 0_u8); + _2 = const ((), 0_u8, 0_u8); + StorageDead(_3); +- _1 = encode(move _2) -> [return: bb1, unwind unreachable]; + _1 = encode(const ((), 0_u8, 0_u8)) -> [return: bb1, unwind unreachable]; } bb1: { StorageDead(_2); + StorageDead(_1); + _0 = const (); return; } + } diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff index b02f04078..8790aad45 100644 --- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff @@ -5,17 +5,24 @@ let mut _0: (); let _1: (); let mut _2: ((), u8, u8); + let mut _3: (); bb0: { + StorageLive(_1); StorageLive(_2); -- _2 = (const (), const 0_u8, const 0_u8); -- _1 = encode(move _2) -> [return: bb1, unwind continue]; + StorageLive(_3); + _3 = (); +- _2 = (move _3, const 0_u8, const 0_u8); + _2 = const ((), 0_u8, 0_u8); + StorageDead(_3); +- _1 = encode(move _2) -> [return: bb1, unwind continue]; + _1 = encode(const ((), 0_u8, 0_u8)) -> [return: bb1, unwind continue]; } bb1: { StorageDead(_2); + StorageDead(_1); + _0 = const (); return; } + } diff --git a/tests/mir-opt/const_prop/issue_66971.rs b/tests/mir-opt/const_prop/issue_66971.rs index 386c95b5b..49d598ff2 100644 --- a/tests/mir-opt/const_prop/issue_66971.rs +++ b/tests/mir-opt/const_prop/issue_66971.rs @@ -1,7 +1,5 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp -// compile-flags: -Z mir-opt-level=3 // Due to a bug in propagating scalar pairs the assertion below used to fail. In the expected // outputs below, after ConstProp this is how _2 would look like with the bug: @@ -16,5 +14,7 @@ fn encode(this: ((), u8, u8)) { // EMIT_MIR issue_66971.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: = encode(const ((), 0_u8, 0_u8)) encode(((), 0, 0)); } diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff index c1ef453e9..3de9cdd79 100644 --- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff @@ -8,6 +8,7 @@ let mut _3: (u8, u8); bb0: { + StorageLive(_1); StorageLive(_2); StorageLive(_3); - _3 = (const 1_u8, const 2_u8); @@ -21,6 +22,8 @@ bb1: { StorageDead(_2); + StorageDead(_1); + _0 = const (); return; } + } diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff index 53cdcc181..72cf48b5c 100644 --- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff @@ -8,6 +8,7 @@ let mut _3: (u8, u8); bb0: { + StorageLive(_1); StorageLive(_2); StorageLive(_3); - _3 = (const 1_u8, const 2_u8); @@ -21,6 +22,8 @@ bb1: { StorageDead(_2); + StorageDead(_1); + _0 = const (); return; } + } diff --git a/tests/mir-opt/const_prop/issue_67019.rs b/tests/mir-opt/const_prop/issue_67019.rs index 2f61298bb..f0a09e6e8 100644 --- a/tests/mir-opt/const_prop/issue_67019.rs +++ b/tests/mir-opt/const_prop/issue_67019.rs @@ -1,7 +1,5 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp -// compile-flags: -Z mir-opt-level=3 // This used to ICE in const-prop @@ -11,5 +9,7 @@ fn test(this: ((u8, u8),)) { // EMIT_MIR issue_67019.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: = test(const ((1_u8, 2_u8),)) test(((1, 2),)); } diff --git a/tests/mir-opt/const_prop/mult_by_zero.rs b/tests/mir-opt/const_prop/mult_by_zero.rs index 47e15205e..2e9c63a1c 100644 --- a/tests/mir-opt/const_prop/mult_by_zero.rs +++ b/tests/mir-opt/const_prop/mult_by_zero.rs @@ -1,9 +1,10 @@ -// skip-filecheck // unit-test: ConstProp // EMIT_MIR mult_by_zero.test.ConstProp.diff -fn test(x : i32) -> i32 { - x * 0 +fn test(x: i32) -> i32 { + // CHECK: fn test( + // CHECK: _0 = const 0_i32; + x * 0 } fn main() { diff --git a/tests/mir-opt/const_prop/mutable_variable.rs b/tests/mir-opt/const_prop/mutable_variable.rs index 175d63d46..6c74ea5b9 100644 --- a/tests/mir-opt/const_prop/mutable_variable.rs +++ b/tests/mir-opt/const_prop/mutable_variable.rs @@ -1,8 +1,13 @@ -// skip-filecheck // unit-test: ConstProp // EMIT_MIR mutable_variable.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug x => [[x:_.*]]; + // CHECK: debug y => [[y:_.*]]; + // CHECK: [[x]] = const 42_i32; + // CHECK: [[x]] = const 99_i32; + // CHECK: [[y]] = const 99_i32; let mut x = 42; x = 99; let y = x; diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate.rs index f926771ae..a38296502 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate.rs @@ -1,8 +1,13 @@ -// skip-filecheck // unit-test: ConstProp // EMIT_MIR mutable_variable_aggregate.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug x => [[x:_.*]]; + // CHECK: debug y => [[y:_.*]]; + // CHECK: [[x]] = const (42_i32, 43_i32); + // CHECK: ([[x]].1: i32) = const 99_i32; + // CHECK: [[y]] = const (42_i32, 99_i32); let mut x = (42, 43); x.1 = 99; let y = x; diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs index a81aa7b49..60f414ae2 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs @@ -1,8 +1,15 @@ -// skip-filecheck // unit-test: ConstProp // EMIT_MIR mutable_variable_aggregate_mut_ref.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug x => [[x:_.*]]; + // CHECK: debug z => [[z:_.*]]; + // CHECK: debug y => [[y:_.*]]; + // CHECK: [[x]] = (const 42_i32, const 43_i32); + // CHECK: [[z]] = &mut [[x]]; + // CHECK: ((*[[z]]).1: i32) = const 99_i32; + // CHECK: [[y]] = [[x]]; let mut x = (42, 43); let z = &mut x; z.1 = 99; diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs index 54a5d9223..888fcde2d 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs @@ -1,9 +1,15 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // EMIT_MIR mutable_variable_aggregate_partial_read.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug x => [[x:_.*]]; + // CHECK: debug y => [[y:_.*]]; + // CHECK: [[x]] = foo() + // CHECK: ([[x]].1: i32) = const 99_i32; + // CHECK: ([[x]].0: i32) = const 42_i32; + // CHECK: [[y]] = const 99_i32; let mut x: (i32, i32) = foo(); x.1 = 99; x.0 = 42; diff --git a/tests/mir-opt/const_prop/mutable_variable_no_prop.rs b/tests/mir-opt/const_prop/mutable_variable_no_prop.rs index a7aeeccd8..49e9a7015 100644 --- a/tests/mir-opt/const_prop/mutable_variable_no_prop.rs +++ b/tests/mir-opt/const_prop/mutable_variable_no_prop.rs @@ -1,10 +1,17 @@ -// skip-filecheck // unit-test: ConstProp +// Verify that we do not propagate the contents of this mutable static. static mut STATIC: u32 = 0x42424242; // EMIT_MIR mutable_variable_no_prop.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug x => [[x:_.*]]; + // CHECK: debug y => [[y:_.*]]; + // CHECK: [[x]] = const 42_u32; + // CHECK: [[tmp:_.*]] = (*{{_.*}}); + // CHECK: [[x]] = move [[tmp]]; + // CHECK: [[y]] = [[x]]; let mut x = 42; unsafe { x = STATIC; diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs index 6bdb136a9..04e347fc0 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs @@ -1,14 +1,24 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // EMIT_MIR mutable_variable_unprop_assign.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug x => [[x:_.*]]; + // CHECK: debug y => [[y:_.*]]; + // CHECK: debug z => [[z:_.*]]; + // CHECK: [[a]] = foo() + // CHECK: [[x]] = const (1_i32, 2_i32); + // CHECK: [[tmp:_.*]] = [[a]]; + // CHECK: ([[x]].1: i32) = move [[tmp]]; + // CHECK: [[y]] = ([[x]].1: i32); + // CHECK: [[z]] = const 1_i32; let a = foo(); let mut x: (i32, i32) = (1, 2); x.1 = a; let y = x.1; - let z = x.0; // this could theoretically be allowed, but we can't handle it right now + let z = x.0; } #[inline(never)] diff --git a/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-abort.diff new file mode 100644 index 000000000..bd1de7476 --- /dev/null +++ b/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-abort.diff @@ -0,0 +1,38 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: usize; + let mut _2: *const i32; + let _3: &i32; + let _4: (); + let mut _5: usize; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _3 = const _; + _2 = &raw const (*_3); + _1 = move _2 as usize (PointerExposeAddress); + StorageDead(_2); + StorageDead(_3); + StorageLive(_4); + StorageLive(_5); + _5 = _1; + _4 = read(move _5) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_5); + StorageDead(_4); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-unwind.diff new file mode 100644 index 000000000..850b743fe --- /dev/null +++ b/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-unwind.diff @@ -0,0 +1,38 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); + let _1: usize; + let mut _2: *const i32; + let _3: &i32; + let _4: (); + let mut _5: usize; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + _3 = const _; + _2 = &raw const (*_3); + _1 = move _2 as usize (PointerExposeAddress); + StorageDead(_2); + StorageDead(_3); + StorageLive(_4); + StorageLive(_5); + _5 = _1; + _4 = read(move _5) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_5); + StorageDead(_4); + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/const_prop/pointer_expose_address.rs b/tests/mir-opt/const_prop/pointer_expose_address.rs new file mode 100644 index 000000000..631aac901 --- /dev/null +++ b/tests/mir-opt/const_prop/pointer_expose_address.rs @@ -0,0 +1,18 @@ +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// unit-test: ConstProp + +#[inline(never)] +fn read(_: usize) { } + +// EMIT_MIR pointer_expose_address.main.ConstProp.diff +fn main() { + // CHECK-LABEL: fn main( + // CHECK: [[ptr:_.*]] = const _; + // CHECK: [[ref:_.*]] = &raw const (*[[ptr]]); + // CHECK: [[x:_.*]] = move [[ref]] as usize (PointerExposeAddress); + // CHECK: [[arg:_.*]] = [[x]]; + // CHECK: = read(move [[arg]]) + const FOO: &i32 = &1; + let x = FOO as *const i32 as usize; + read(x); +} diff --git a/tests/mir-opt/const_prop/read_immutable_static.rs b/tests/mir-opt/const_prop/read_immutable_static.rs index a8d8cfacc..0fa18dd10 100644 --- a/tests/mir-opt/const_prop/read_immutable_static.rs +++ b/tests/mir-opt/const_prop/read_immutable_static.rs @@ -1,9 +1,11 @@ -// skip-filecheck // unit-test: ConstProp static FOO: u8 = 2; // EMIT_MIR read_immutable_static.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug x => [[x:_.*]]; + // CHECK: [[x]] = const 4_u8; let x = FOO + FOO; } diff --git a/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff b/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff index 6b897a881..a54ae8d2f 100644 --- a/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff @@ -7,6 +7,9 @@ let mut _2: &i32; let _3: i32; let mut _4: &i32; + scope 1 { + debug a => _1; + } bb0: { StorageLive(_1); @@ -15,8 +18,8 @@ _2 = &(*_4); _1 = (*_2); StorageDead(_2); - StorageDead(_1); _0 = const (); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/ref_deref.rs b/tests/mir-opt/const_prop/ref_deref.rs index f2fa024f7..5bceae749 100644 --- a/tests/mir-opt/const_prop/ref_deref.rs +++ b/tests/mir-opt/const_prop/ref_deref.rs @@ -1,7 +1,9 @@ -// skip-filecheck // unit-test: ConstProp -// EMIT_MIR ref_deref.main.ConstProp.diff +// EMIT_MIR ref_deref.main.ConstProp.diff fn main() { - *(&4); + // CHECK-LABEL: fn main( + // CHECK: debug a => [[a:_.*]]; + // CHECK: [[a]] = (*{{_.*}}); + let a = *(&4); } diff --git a/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff b/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff index 7f6161665..05a4e1774 100644 --- a/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff @@ -7,6 +7,9 @@ let mut _2: &i32; let _3: (i32, i32); let mut _4: &(i32, i32); + scope 1 { + debug a => _1; + } bb0: { StorageLive(_1); @@ -15,8 +18,8 @@ _2 = &((*_4).1: i32); _1 = (*_2); StorageDead(_2); - StorageDead(_1); _0 = const (); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/ref_deref_project.rs b/tests/mir-opt/const_prop/ref_deref_project.rs index 1b9e0acb2..4b5c67303 100644 --- a/tests/mir-opt/const_prop/ref_deref_project.rs +++ b/tests/mir-opt/const_prop/ref_deref_project.rs @@ -1,7 +1,10 @@ -// skip-filecheck +// This does not currently propagate (#67862) // unit-test: ConstProp -// EMIT_MIR ref_deref_project.main.ConstProp.diff +// EMIT_MIR ref_deref_project.main.ConstProp.diff fn main() { - *(&(4, 5).1); // This does not currently propagate (#67862) + // CHECK-LABEL: fn main( + // CHECK: debug a => [[a:_.*]]; + // CHECK: [[a]] = (*{{_.*}}); + let a = *(&(4, 5).1); } diff --git a/tests/mir-opt/const_prop/reify_fn_ptr.rs b/tests/mir-opt/const_prop/reify_fn_ptr.rs index da7de80c5..33fdd4142 100644 --- a/tests/mir-opt/const_prop/reify_fn_ptr.rs +++ b/tests/mir-opt/const_prop/reify_fn_ptr.rs @@ -1,7 +1,10 @@ -// skip-filecheck // unit-test: ConstProp // EMIT_MIR reify_fn_ptr.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: [[ptr:_.*]] = main as fn() (PointerCoercion(ReifyFnPointer)); + // CHECK: [[addr:_.*]] = move [[ptr]] as usize (PointerExposeAddress); + // CHECK: [[back:_.*]] = move [[addr]] as *const fn() (PointerFromExposedAddress); let _ = main as usize as *const fn(); } diff --git a/tests/mir-opt/const_prop/repeat.rs b/tests/mir-opt/const_prop/repeat.rs index 92194d6bb..9f688bbb5 100644 --- a/tests/mir-opt/const_prop/repeat.rs +++ b/tests/mir-opt/const_prop/repeat.rs @@ -1,9 +1,11 @@ -// skip-filecheck // unit-test: ConstProp // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR repeat.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug x => [[x:_.*]]; + // CHECK: [[x]] = const 42_u32; let x: u32 = [42; 8][2] + 0; } diff --git a/tests/mir-opt/const_prop/return_place.rs b/tests/mir-opt/const_prop/return_place.rs index 1263de793..286543abb 100644 --- a/tests/mir-opt/const_prop/return_place.rs +++ b/tests/mir-opt/const_prop/return_place.rs @@ -1,4 +1,3 @@ -// skip-filecheck // unit-test: ConstProp // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -C overflow-checks=on @@ -6,6 +5,8 @@ // EMIT_MIR return_place.add.ConstProp.diff // EMIT_MIR return_place.add.PreCodegen.before.mir fn add() -> u32 { + // CHECK-LABEL: fn add( + // CHECK: _0 = const 4_u32; 2 + 2 } diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.rs b/tests/mir-opt/const_prop/scalar_literal_propagation.rs index 9dcddf7c7..782cd35d4 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.rs +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.rs @@ -1,8 +1,10 @@ -// skip-filecheck // unit-test: ConstProp // EMIT_MIR_FOR_EACH_PANIC_STRATEGY + // EMIT_MIR scalar_literal_propagation.main.ConstProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: = consume(const 1_u32) let x = 1; consume(x); } diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff index c2e1288b4..7d5d036f4 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff @@ -12,6 +12,9 @@ let mut _7: usize; let mut _8: bool; let mut _9: &[u32; 3]; + scope 1 { + debug a => _1; + } bb0: { StorageLive(_1); @@ -39,8 +42,8 @@ StorageDead(_6); StorageDead(_4); StorageDead(_2); - StorageDead(_1); _0 = const (); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff index 23646c3c9..fa4c5a71b 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff @@ -12,6 +12,9 @@ let mut _7: usize; let mut _8: bool; let mut _9: &[u32; 3]; + scope 1 { + debug a => _1; + } bb0: { StorageLive(_1); @@ -39,8 +42,8 @@ StorageDead(_6); StorageDead(_4); StorageDead(_2); - StorageDead(_1); _0 = const (); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff index c2e1288b4..7d5d036f4 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff @@ -12,6 +12,9 @@ let mut _7: usize; let mut _8: bool; let mut _9: &[u32; 3]; + scope 1 { + debug a => _1; + } bb0: { StorageLive(_1); @@ -39,8 +42,8 @@ StorageDead(_6); StorageDead(_4); StorageDead(_2); - StorageDead(_1); _0 = const (); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff index 23646c3c9..fa4c5a71b 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff @@ -12,6 +12,9 @@ let mut _7: usize; let mut _8: bool; let mut _9: &[u32; 3]; + scope 1 { + debug a => _1; + } bb0: { StorageLive(_1); @@ -39,8 +42,8 @@ StorageDead(_6); StorageDead(_4); StorageDead(_2); - StorageDead(_1); _0 = const (); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/slice_len.rs b/tests/mir-opt/const_prop/slice_len.rs index 3b551b6b1..0bf442726 100644 --- a/tests/mir-opt/const_prop/slice_len.rs +++ b/tests/mir-opt/const_prop/slice_len.rs @@ -1,10 +1,13 @@ -// skip-filecheck -// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: ConstProp // compile-flags: -Zmir-enable-passes=+InstSimplify +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR slice_len.main.ConstProp.diff fn main() { - (&[1u32, 2, 3] as &[u32])[1]; + // CHECK-LABEL: fn main( + // CHECK: debug a => [[a:_.*]]; + // CHECK: assert(const true, + // CHECK: [[a]] = const 2_u32; + let a = (&[1u32, 2, 3] as &[u32])[1]; } diff --git a/tests/mir-opt/const_prop/switch_int.rs b/tests/mir-opt/const_prop/switch_int.rs index 7ec56e11e..d1cbaae49 100644 --- a/tests/mir-opt/const_prop/switch_int.rs +++ b/tests/mir-opt/const_prop/switch_int.rs @@ -1,13 +1,20 @@ -// skip-filecheck // unit-test: ConstProp // compile-flags: -Zmir-enable-passes=+SimplifyConstCondition-after-const-prop // EMIT_MIR_FOR_EACH_PANIC_STRATEGY + #[inline(never)] fn foo(_: i32) { } // EMIT_MIR switch_int.main.ConstProp.diff // EMIT_MIR switch_int.main.SimplifyConstCondition-after-const-prop.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: bb0: { + // CHECK-NOT: switchInt( + // CHECK: goto -> [[bb:bb.*]]; + // CHECK: [[bb]]: { + // CHECK-NOT: _0 = foo(const -1_i32) + // CHECK: _0 = foo(const 0_i32) match 1 { 1 => foo(0), _ => foo(-1), diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.rs b/tests/mir-opt/const_prop/tuple_literal_propagation.rs index e0bc6e1be..dfc4a6f3f 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.rs +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.rs @@ -1,10 +1,11 @@ -// skip-filecheck // unit-test: ConstProp // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR tuple_literal_propagation.main.ConstProp.diff + fn main() { + // CHECK-LABEL: fn main( + // CHECK: = consume(const (1_u32, 2_u32)) let x = (1, 2); - consume(x); } diff --git a/tests/mir-opt/const_prop/while_let_loops.rs b/tests/mir-opt/const_prop/while_let_loops.rs index 39081c355..8b2a73438 100644 --- a/tests/mir-opt/const_prop/while_let_loops.rs +++ b/tests/mir-opt/const_prop/while_let_loops.rs @@ -1,8 +1,9 @@ -// skip-filecheck // unit-test: ConstProp // EMIT_MIR while_let_loops.change_loop_body.ConstProp.diff pub fn change_loop_body() { + // CHECK-LABEL: fn change_loop_body( + // CHECK: switchInt(const 0_isize) let mut _x = 0; while let Some(0u32) = None { _x = 1; diff --git a/tests/mir-opt/copy-prop/borrowed_local.rs b/tests/mir-opt/copy-prop/borrowed_local.rs index c6b8ad357..a44e65164 100644 --- a/tests/mir-opt/copy-prop/borrowed_local.rs +++ b/tests/mir-opt/copy-prop/borrowed_local.rs @@ -22,11 +22,11 @@ fn f() -> bool { let b = a; // We cannot propagate the place `a`. let r2 = &b; - Call(RET = cmp_ref(r1, r2), next) + Call(RET = cmp_ref(r1, r2), next, UnwindContinue()) } next = { // But we can propagate the value `a`. - Call(RET = opaque(b), ret) + Call(RET = opaque(b), ret, UnwindContinue()) } ret = { Return() diff --git a/tests/mir-opt/copy-prop/calls.rs b/tests/mir-opt/copy-prop/calls.rs index 2970f5f0b..bc6760707 100644 --- a/tests/mir-opt/copy-prop/calls.rs +++ b/tests/mir-opt/copy-prop/calls.rs @@ -26,7 +26,7 @@ fn multiple_edges(t: bool) -> u8 { match t { true => bbt, _ => ret } } bbt = { - Call(x = dummy(13), ret) + Call(x = dummy(13), ret, UnwindContinue()) } ret = { // `x` is not assigned on the `bb0 -> ret` edge, diff --git a/tests/mir-opt/copy-prop/custom_move_arg.rs b/tests/mir-opt/copy-prop/custom_move_arg.rs index 2077874ee..8593d9fa9 100644 --- a/tests/mir-opt/copy-prop/custom_move_arg.rs +++ b/tests/mir-opt/copy-prop/custom_move_arg.rs @@ -14,11 +14,11 @@ struct NotCopy(bool); fn f(_1: NotCopy) { mir!({ let _2 = _1; - Call(RET = opaque(Move(_1)), bb1) + Call(RET = opaque(Move(_1)), bb1, UnwindContinue()) } bb1 = { let _3 = Move(_2); - Call(RET = opaque(_3), bb2) + Call(RET = opaque(_3), bb2, UnwindContinue()) } bb2 = { Return() diff --git a/tests/mir-opt/copy-prop/move_projection.rs b/tests/mir-opt/copy-prop/move_projection.rs index 8629d535b..438a90ddd 100644 --- a/tests/mir-opt/copy-prop/move_projection.rs +++ b/tests/mir-opt/copy-prop/move_projection.rs @@ -18,10 +18,10 @@ fn f(a: Foo) -> bool { let b = a; // This is a move out of a copy, so must become a copy of `a.0`. let c = Move(b.0); - Call(RET = opaque(Move(a)), bb1) + Call(RET = opaque(Move(a)), bb1, UnwindContinue()) } bb1 = { - Call(RET = opaque(Move(c)), ret) + Call(RET = opaque(Move(c)), ret, UnwindContinue()) } ret = { Return() diff --git a/tests/mir-opt/coroutine_tiny.main-{closure#0}.coroutine_resume.0.mir b/tests/mir-opt/coroutine_tiny.main-{closure#0}.coroutine_resume.0.mir index 17b99c87c..165aa3a05 100644 --- a/tests/mir-opt/coroutine_tiny.main-{closure#0}.coroutine_resume.0.mir +++ b/tests/mir-opt/coroutine_tiny.main-{closure#0}.coroutine_resume.0.mir @@ -55,6 +55,9 @@ fn main::{closure#0}(_1: Pin<&mut {coroutine@$DIR/coroutine_tiny.rs:20:16: 20:24 StorageLive(_7); _7 = (); _0 = CoroutineState::<(), ()>::Yielded(move _7); + StorageDead(_4); + StorageDead(_6); + StorageDead(_7); discriminant((*(_1.0: &mut {coroutine@$DIR/coroutine_tiny.rs:20:16: 20:24}))) = 3; return; } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-abort.diff index 9bfd46231..8363783e6 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-abort.diff @@ -28,16 +28,16 @@ scope 12 { scope 13 (inlined NonNull::::new_unchecked::runtime::<[bool; 0]>) { debug ptr => _6; - scope 14 (inlined ptr::mut_ptr::::is_null) { + scope 14 (inlined std::ptr::mut_ptr::::is_null) { debug self => _6; let mut _9: *mut u8; scope 15 { - scope 16 (inlined ptr::mut_ptr::::is_null::runtime_impl) { + scope 16 (inlined std::ptr::mut_ptr::::is_null::runtime_impl) { debug ptr => _9; - scope 17 (inlined ptr::mut_ptr::::addr) { + scope 17 (inlined std::ptr::mut_ptr::::addr) { debug self => _9; scope 18 { - scope 19 (inlined ptr::mut_ptr::::cast::<()>) { + scope 19 (inlined std::ptr::mut_ptr::::cast::<()>) { debug self => _9; } } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff index dba50b142..19326b6a9 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff @@ -28,16 +28,16 @@ scope 12 { scope 13 (inlined NonNull::::new_unchecked::runtime::<[bool; 0]>) { debug ptr => _6; - scope 14 (inlined ptr::mut_ptr::::is_null) { + scope 14 (inlined std::ptr::mut_ptr::::is_null) { debug self => _6; let mut _9: *mut u8; scope 15 { - scope 16 (inlined ptr::mut_ptr::::is_null::runtime_impl) { + scope 16 (inlined std::ptr::mut_ptr::::is_null::runtime_impl) { debug ptr => _9; - scope 17 (inlined ptr::mut_ptr::::addr) { + scope 17 (inlined std::ptr::mut_ptr::::addr) { debug self => _9; scope 18 { - scope 19 (inlined ptr::mut_ptr::::cast::<()>) { + scope 19 (inlined std::ptr::mut_ptr::::cast::<()>) { debug self => _9; } } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-abort.diff index 33fe4628d..0d1e2430c 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-abort.diff @@ -28,16 +28,16 @@ scope 12 { scope 13 (inlined NonNull::::new_unchecked::runtime::<[bool; 0]>) { debug ptr => _6; - scope 14 (inlined ptr::mut_ptr::::is_null) { + scope 14 (inlined std::ptr::mut_ptr::::is_null) { debug self => _6; let mut _9: *mut u8; scope 15 { - scope 16 (inlined ptr::mut_ptr::::is_null::runtime_impl) { + scope 16 (inlined std::ptr::mut_ptr::::is_null::runtime_impl) { debug ptr => _9; - scope 17 (inlined ptr::mut_ptr::::addr) { + scope 17 (inlined std::ptr::mut_ptr::::addr) { debug self => _9; scope 18 { - scope 19 (inlined ptr::mut_ptr::::cast::<()>) { + scope 19 (inlined std::ptr::mut_ptr::::cast::<()>) { debug self => _9; } } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff index b2d561911..35f1e5ba7 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff @@ -28,16 +28,16 @@ scope 12 { scope 13 (inlined NonNull::::new_unchecked::runtime::<[bool; 0]>) { debug ptr => _6; - scope 14 (inlined ptr::mut_ptr::::is_null) { + scope 14 (inlined std::ptr::mut_ptr::::is_null) { debug self => _6; let mut _9: *mut u8; scope 15 { - scope 16 (inlined ptr::mut_ptr::::is_null::runtime_impl) { + scope 16 (inlined std::ptr::mut_ptr::::is_null::runtime_impl) { debug ptr => _9; - scope 17 (inlined ptr::mut_ptr::::addr) { + scope 17 (inlined std::ptr::mut_ptr::::addr) { debug self => _9; scope 18 { - scope 19 (inlined ptr::mut_ptr::::cast::<()>) { + scope 19 (inlined std::ptr::mut_ptr::::cast::<()>) { debug self => _9; } } 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 1751b0de2..ddfe2e8c8 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 @@ -28,16 +28,16 @@ scope 12 { scope 13 (inlined NonNull::::new_unchecked::runtime::<[bool; 0]>) { debug ptr => _6; - scope 14 (inlined ptr::mut_ptr::::is_null) { + scope 14 (inlined std::ptr::mut_ptr::::is_null) { debug self => _6; let mut _9: *mut u8; scope 15 { - scope 16 (inlined ptr::mut_ptr::::is_null::runtime_impl) { + scope 16 (inlined std::ptr::mut_ptr::::is_null::runtime_impl) { debug ptr => _9; - scope 17 (inlined ptr::mut_ptr::::addr) { + scope 17 (inlined std::ptr::mut_ptr::::addr) { debug self => _9; scope 18 { - scope 19 (inlined ptr::mut_ptr::::cast::<()>) { + scope 19 (inlined std::ptr::mut_ptr::::cast::<()>) { debug self => _9; } } 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 858a9d33d..861295faa 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 @@ -28,16 +28,16 @@ scope 12 { scope 13 (inlined NonNull::::new_unchecked::runtime::<[bool; 0]>) { debug ptr => _6; - scope 14 (inlined ptr::mut_ptr::::is_null) { + scope 14 (inlined std::ptr::mut_ptr::::is_null) { debug self => _6; let mut _9: *mut u8; scope 15 { - scope 16 (inlined ptr::mut_ptr::::is_null::runtime_impl) { + scope 16 (inlined std::ptr::mut_ptr::::is_null::runtime_impl) { debug ptr => _9; - scope 17 (inlined ptr::mut_ptr::::addr) { + scope 17 (inlined std::ptr::mut_ptr::::addr) { debug self => _9; scope 18 { - scope 19 (inlined ptr::mut_ptr::::cast::<()>) { + scope 19 (inlined std::ptr::mut_ptr::::cast::<()>) { debug self => _9; } } 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 517070420..cbb639edc 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 @@ -28,16 +28,16 @@ scope 12 { scope 13 (inlined NonNull::::new_unchecked::runtime::<[bool; 0]>) { debug ptr => _6; - scope 14 (inlined ptr::mut_ptr::::is_null) { + scope 14 (inlined std::ptr::mut_ptr::::is_null) { debug self => _6; let mut _9: *mut u8; scope 15 { - scope 16 (inlined ptr::mut_ptr::::is_null::runtime_impl) { + scope 16 (inlined std::ptr::mut_ptr::::is_null::runtime_impl) { debug ptr => _9; - scope 17 (inlined ptr::mut_ptr::::addr) { + scope 17 (inlined std::ptr::mut_ptr::::addr) { debug self => _9; scope 18 { - scope 19 (inlined ptr::mut_ptr::::cast::<()>) { + scope 19 (inlined std::ptr::mut_ptr::::cast::<()>) { debug self => _9; } } 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 9141a6c67..656846e9f 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 @@ -28,16 +28,16 @@ scope 12 { scope 13 (inlined NonNull::::new_unchecked::runtime::<[bool; 0]>) { debug ptr => _6; - scope 14 (inlined ptr::mut_ptr::::is_null) { + scope 14 (inlined std::ptr::mut_ptr::::is_null) { debug self => _6; let mut _9: *mut u8; scope 15 { - scope 16 (inlined ptr::mut_ptr::::is_null::runtime_impl) { + scope 16 (inlined std::ptr::mut_ptr::::is_null::runtime_impl) { debug ptr => _9; - scope 17 (inlined ptr::mut_ptr::::addr) { + scope 17 (inlined std::ptr::mut_ptr::::addr) { debug self => _9; scope 18 { - scope 19 (inlined ptr::mut_ptr::::cast::<()>) { + scope 19 (inlined std::ptr::mut_ptr::::cast::<()>) { debug self => _9; } } diff --git a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff index d502b1982..053981abe 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff @@ -118,7 +118,7 @@ } ALLOC2 (static: RC, size: 4, align: 4) { - ╾ALLOC0╼ │ ╾──╼ + ╾ALLOC0╼ │ ╾──╼ } ALLOC0 (size: 8, align: 4) { diff --git a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff index 5d69572b5..d862bd93f 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff @@ -118,7 +118,7 @@ } ALLOC2 (static: RC, size: 8, align: 8) { - ╾ALLOC0╼ │ ╾──────╼ + ╾ALLOC0╼ │ ╾──────╼ } ALLOC0 (size: 8, align: 4) { diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff index 2d4591ea2..09fc48043 100644 --- a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff @@ -8,7 +8,7 @@ let mut _3: u8; scope 1 { } - scope 2 (inlined ::add) { + scope 2 (inlined #[track_caller] ::add) { debug self => _2; debug other => _3; let mut _4: (u8, bool); diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff index e99ac782a..c0b26080f 100644 --- a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff @@ -8,7 +8,7 @@ let mut _3: u8; scope 1 { } - scope 2 (inlined ::add) { + scope 2 (inlined #[track_caller] ::add) { debug self => _2; debug other => _3; let mut _4: (u8, bool); diff --git a/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-abort.diff index cc96cbef2..9b0093c45 100644 --- a/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-abort.diff @@ -30,7 +30,7 @@ StorageLive(_4); StorageLive(_5); _5 = _3; - _4 = ptr::mut_ptr::::add(move _5, const 1_usize) -> [return: bb1, unwind unreachable]; + _4 = std::ptr::mut_ptr::::add(move _5, const 1_usize) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-unwind.diff index ebeb8619d..635a21425 100644 --- a/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-unwind.diff @@ -30,7 +30,7 @@ StorageLive(_4); StorageLive(_5); _5 = _3; - _4 = ptr::mut_ptr::::add(move _5, const 1_usize) -> [return: bb1, unwind continue]; + _4 = std::ptr::mut_ptr::::add(move _5, const 1_usize) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.32bit.diff index 8499d0a89..0f461f515 100644 --- a/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.32bit.diff +++ b/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.32bit.diff @@ -220,11 +220,11 @@ } ALLOC5 (static: BIG_STAT, size: 4, align: 4) { - ╾ALLOC0╼ │ ╾──╼ + ╾ALLOC0╼ │ ╾──╼ } ALLOC0 (size: 20, align: 4) { - 0x00 │ 01 00 00 00 23 00 00 00 ╾ALLOC1╼ 02 00 00 00 │ ....#...╾──╼.... + 0x00 │ 01 00 00 00 23 00 00 00 ╾ALLOC1╼ 02 00 00 00 │ ....#...╾──╼.... 0x10 │ 00 00 a4 42 │ ...B } @@ -233,11 +233,11 @@ } ALLOC4 (static: SMALL_STAT, size: 4, align: 4) { - ╾ALLOC2╼ │ ╾──╼ + ╾ALLOC2╼ │ ╾──╼ } ALLOC2 (size: 20, align: 4) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC3╼ 01 00 00 00 │ ....░░░░╾──╼.... + 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC3╼ 01 00 00 00 │ ....░░░░╾──╼.... 0x10 │ 00 00 10 41 │ ...A } diff --git a/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.64bit.diff index 01ec3f623..3c40ec8bf 100644 --- a/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.64bit.diff +++ b/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.64bit.diff @@ -220,11 +220,11 @@ } ALLOC5 (static: BIG_STAT, size: 8, align: 8) { - ╾ALLOC0╼ │ ╾──────╼ + ╾ALLOC0╼ │ ╾──────╼ } ALLOC0 (size: 32, align: 8) { - 0x00 │ 01 00 00 00 23 00 00 00 ╾ALLOC1╼ │ ....#...╾──────╼ + 0x00 │ 01 00 00 00 23 00 00 00 ╾ALLOC1╼ │ ....#...╾──────╼ 0x10 │ 02 00 00 00 00 00 00 00 00 00 a4 42 __ __ __ __ │ ...........B░░░░ } @@ -233,11 +233,11 @@ } ALLOC4 (static: SMALL_STAT, size: 8, align: 8) { - ╾ALLOC2╼ │ ╾──────╼ + ╾ALLOC2╼ │ ╾──────╼ } ALLOC2 (size: 32, align: 8) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC3╼ │ ....░░░░╾──────╼ + 0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC3╼ │ ....░░░░╾──────╼ 0x10 │ 01 00 00 00 00 00 00 00 00 00 10 41 __ __ __ __ │ ...........A░░░░ } diff --git a/tests/mir-opt/dead-store-elimination/call_arg_copy.rs b/tests/mir-opt/dead-store-elimination/call_arg_copy.rs index dcd15fb2b..b2eb64756 100644 --- a/tests/mir-opt/dead-store-elimination/call_arg_copy.rs +++ b/tests/mir-opt/dead-store-elimination/call_arg_copy.rs @@ -28,7 +28,7 @@ struct Packed { fn move_packed(packed: Packed) { mir!( { - Call(RET = use_both(0, packed.y), ret) + Call(RET = use_both(0, packed.y), ret, UnwindContinue()) } ret = { Return() diff --git a/tests/mir-opt/dead-store-elimination/cycle.rs b/tests/mir-opt/dead-store-elimination/cycle.rs index 8896f5ff3..c9ad06a9d 100644 --- a/tests/mir-opt/dead-store-elimination/cycle.rs +++ b/tests/mir-opt/dead-store-elimination/cycle.rs @@ -20,7 +20,7 @@ fn cycle(mut x: i32, mut y: i32, mut z: i32) { mir!( let condition: bool; { - Call(condition = cond(), bb1) + Call(condition = cond(), bb1, UnwindContinue()) } bb1 = { match condition { true => bb2, _ => ret } @@ -30,7 +30,7 @@ fn cycle(mut x: i32, mut y: i32, mut z: i32) { z = y; y = x; x = temp; - Call(condition = cond(), bb1) + Call(condition = cond(), bb1, UnwindContinue()) } ret = { Return() diff --git a/tests/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir b/tests/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir index b04e09e88..596dcef85 100644 --- a/tests/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir @@ -38,22 +38,22 @@ fn match_tuple(_1: (u32, bool, Option, u32)) -> u32 { bb4: { _5 = Le(const 6_u32, (_1.3: u32)); - switchInt(move _5) -> [0: bb6, otherwise: bb5]; + switchInt(move _5) -> [0: bb5, otherwise: bb7]; } bb5: { - _6 = Le((_1.3: u32), const 9_u32); - switchInt(move _6) -> [0: bb6, otherwise: bb8]; + _3 = Le(const 13_u32, (_1.3: u32)); + switchInt(move _3) -> [0: bb1, otherwise: bb6]; } bb6: { - _3 = Le(const 13_u32, (_1.3: u32)); - switchInt(move _3) -> [0: bb1, otherwise: bb7]; + _4 = Le((_1.3: u32), const 16_u32); + switchInt(move _4) -> [0: bb1, otherwise: bb8]; } bb7: { - _4 = Le((_1.3: u32), const 16_u32); - switchInt(move _4) -> [0: bb1, otherwise: bb8]; + _6 = Le((_1.3: u32), const 9_u32); + switchInt(move _6) -> [0: bb5, otherwise: bb8]; } bb8: { diff --git a/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-abort.diff b/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-abort.diff new file mode 100644 index 000000000..4b1e33791 --- /dev/null +++ b/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-abort.diff @@ -0,0 +1,104 @@ +- // MIR for `constant_index_overflow` before GVN ++ // MIR for `constant_index_overflow` after GVN + + fn constant_index_overflow(_1: &[T]) -> () { + debug x => _1; + let mut _0: (); + let _2: usize; + let mut _4: bool; + let mut _5: usize; + let mut _6: usize; + let mut _7: &[T]; + let _8: usize; + let mut _9: usize; + let mut _10: bool; + let _11: usize; + let mut _12: usize; + let mut _13: bool; + let mut _14: T; + scope 1 { + debug a => _2; + let _3: T; + scope 2 { + debug b => _3; + } + } + + bb0: { +- StorageLive(_2); +- _2 = const _ as usize (IntToInt); ++ nop; ++ _2 = const usize::MAX; + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); +- _5 = _2; ++ _5 = const usize::MAX; + StorageLive(_6); + StorageLive(_7); + _7 = &(*_1); + _6 = core::slice::::len(move _7) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_7); +- _4 = Lt(move _5, move _6); ++ _4 = Lt(const usize::MAX, move _6); + switchInt(move _4) -> [0: bb4, otherwise: bb2]; + } + + bb2: { + StorageDead(_6); + StorageDead(_5); + StorageLive(_8); +- _8 = _2; ++ _8 = const usize::MAX; + _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: bb3, unwind unreachable]; ++ _10 = Lt(const usize::MAX, _9); ++ assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, const usize::MAX) -> [success: bb3, unwind unreachable]; + } + + bb3: { +- _3 = (*_1)[_8]; ++ _3 = (*_1)[_2]; + StorageDead(_8); + goto -> bb6; + } + + bb4: { + StorageDead(_6); + StorageDead(_5); + StorageLive(_11); + _11 = const 0_usize; + _12 = Len((*_1)); +- _13 = Lt(_11, _12); +- assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb5, unwind unreachable]; ++ _13 = Lt(const 0_usize, _12); ++ assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, const 0_usize) -> [success: bb5, unwind unreachable]; + } + + bb5: { +- _3 = (*_1)[_11]; ++ _3 = (*_1)[0 of 1]; + StorageDead(_11); + goto -> bb6; + } + + bb6: { + StorageDead(_4); + StorageLive(_14); + _14 = _3; + _0 = opaque::(move _14) -> [return: bb7, unwind unreachable]; + } + + bb7: { + StorageDead(_14); + StorageDead(_3); +- StorageDead(_2); ++ nop; + return; + } + } + diff --git a/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-unwind.diff b/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-unwind.diff new file mode 100644 index 000000000..8abcd7e93 --- /dev/null +++ b/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-unwind.diff @@ -0,0 +1,104 @@ +- // MIR for `constant_index_overflow` before GVN ++ // MIR for `constant_index_overflow` after GVN + + fn constant_index_overflow(_1: &[T]) -> () { + debug x => _1; + let mut _0: (); + let _2: usize; + let mut _4: bool; + let mut _5: usize; + let mut _6: usize; + let mut _7: &[T]; + let _8: usize; + let mut _9: usize; + let mut _10: bool; + let _11: usize; + let mut _12: usize; + let mut _13: bool; + let mut _14: T; + scope 1 { + debug a => _2; + let _3: T; + scope 2 { + debug b => _3; + } + } + + bb0: { +- StorageLive(_2); +- _2 = const _ as usize (IntToInt); ++ nop; ++ _2 = const usize::MAX; + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); +- _5 = _2; ++ _5 = const usize::MAX; + StorageLive(_6); + StorageLive(_7); + _7 = &(*_1); + _6 = core::slice::::len(move _7) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_7); +- _4 = Lt(move _5, move _6); ++ _4 = Lt(const usize::MAX, move _6); + switchInt(move _4) -> [0: bb4, otherwise: bb2]; + } + + bb2: { + StorageDead(_6); + StorageDead(_5); + StorageLive(_8); +- _8 = _2; ++ _8 = const usize::MAX; + _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: bb3, unwind continue]; ++ _10 = Lt(const usize::MAX, _9); ++ assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, const usize::MAX) -> [success: bb3, unwind continue]; + } + + bb3: { +- _3 = (*_1)[_8]; ++ _3 = (*_1)[_2]; + StorageDead(_8); + goto -> bb6; + } + + bb4: { + StorageDead(_6); + StorageDead(_5); + StorageLive(_11); + _11 = const 0_usize; + _12 = Len((*_1)); +- _13 = Lt(_11, _12); +- assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb5, unwind continue]; ++ _13 = Lt(const 0_usize, _12); ++ assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, const 0_usize) -> [success: bb5, unwind continue]; + } + + bb5: { +- _3 = (*_1)[_11]; ++ _3 = (*_1)[0 of 1]; + StorageDead(_11); + goto -> bb6; + } + + bb6: { + StorageDead(_4); + StorageLive(_14); + _14 = _3; + _0 = opaque::(move _14) -> [return: bb7, unwind continue]; + } + + bb7: { + StorageDead(_14); + StorageDead(_3); +- StorageDead(_2); ++ nop; + return; + } + } + diff --git a/tests/mir-opt/gvn.rs b/tests/mir-opt/gvn.rs index 10a66ced0..db131f7f9 100644 --- a/tests/mir-opt/gvn.rs +++ b/tests/mir-opt/gvn.rs @@ -529,31 +529,31 @@ fn duplicate_slice() -> (bool, bool) { // CHECK: [[a:_.*]] = (const "a",); // CHECK: [[au:_.*]] = ([[a]].0: &str) as u128 (Transmute); let a = ("a",); - Call(au = transmute::<_, u128>(a.0), bb1) + Call(au = transmute::<_, u128>(a.0), bb1, UnwindContinue()) } bb1 = { // CHECK: [[c:_.*]] = identity::<&str>(([[a]].0: &str)) - Call(c = identity(a.0), bb2) + Call(c = identity(a.0), bb2, UnwindContinue()) } bb2 = { // CHECK: [[cu:_.*]] = [[c]] as u128 (Transmute); - Call(cu = transmute::<_, u128>(c), bb3) + Call(cu = transmute::<_, u128>(c), bb3, UnwindContinue()) } bb3 = { // This slice is different from `a.0`. Hence `bu` is not `au`. // CHECK: [[b:_.*]] = const "a"; // CHECK: [[bu:_.*]] = [[b]] as u128 (Transmute); let b = "a"; - Call(bu = transmute::<_, u128>(b), bb4) + Call(bu = transmute::<_, u128>(b), bb4, UnwindContinue()) } bb4 = { // This returns a copy of `b`, which is not `a`. // CHECK: [[d:_.*]] = identity::<&str>([[b]]) - Call(d = identity(b), bb5) + Call(d = identity(b), bb5, UnwindContinue()) } bb5 = { // CHECK: [[du:_.*]] = [[d]] as u128 (Transmute); - Call(du = transmute::<_, u128>(d), bb6) + Call(du = transmute::<_, u128>(d), bb6, UnwindContinue()) } bb6 = { // `direct` must not fold to `true`, as `indirect` will not. @@ -609,6 +609,22 @@ fn indirect_static() { }) } +/// Verify that having constant index `u64::MAX` does not yield to an overflow in rustc. +fn constant_index_overflow(x: &[T]) { + // CHECK-LABEL: fn constant_index_overflow( + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug b => [[b:_.*]]; + // CHECK: [[a]] = const usize::MAX; + // CHECK-NOT: = (*_1)[{{.*}} of 0]; + // CHECK: [[b]] = (*_1)[[[a]]]; + // CHECK-NOT: = (*_1)[{{.*}} of 0]; + // CHECK: [[b]] = (*_1)[0 of 1]; + // CHECK-NOT: = (*_1)[{{.*}} of 0]; + let a = u64::MAX as usize; + let b = if a < x.len() { x[a] } else { x[0] }; + opaque(b) +} + fn main() { subexpression_elimination(2, 4, 5); wrap_unwrap(5); @@ -627,6 +643,7 @@ fn main() { repeat(); fn_pointers(); indirect_static(); + constant_index_overflow(&[5, 3]); } #[inline(never)] @@ -653,3 +670,4 @@ fn identity(x: T) -> T { // EMIT_MIR gvn.repeat.GVN.diff // EMIT_MIR gvn.fn_pointers.GVN.diff // EMIT_MIR gvn.indirect_static.GVN.diff +// EMIT_MIR gvn.constant_index_overflow.GVN.diff diff --git a/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-abort.diff b/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-abort.diff index 217c8b802..3ffe2ee0c 100644 --- a/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-abort.diff @@ -69,58 +69,58 @@ + } + + bb2: { ++ _4 = <() as F>::call() -> [return: bb1, unwind unreachable]; ++ } ++ ++ bb3: { + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); -+ _3 = <() as F>::call() -> [return: bb3, unwind unreachable]; ++ _3 = <() as F>::call() -> [return: bb2, unwind unreachable]; + } + -+ bb3: { -+ _4 = <() as F>::call() -> [return: bb1, unwind unreachable]; ++ bb4: { ++ _7 = <() as E>::call() -> [return: bb3, unwind unreachable]; + } + -+ bb4: { ++ bb5: { + StorageDead(_10); + StorageDead(_9); + StorageDead(_8); -+ _6 = <() as E>::call() -> [return: bb5, unwind unreachable]; ++ _6 = <() as E>::call() -> [return: bb4, unwind unreachable]; + } + -+ bb5: { -+ _7 = <() as E>::call() -> [return: bb2, unwind unreachable]; ++ bb6: { ++ _10 = <() as D>::call() -> [return: bb5, unwind unreachable]; + } + -+ bb6: { ++ bb7: { + StorageDead(_13); + StorageDead(_12); + StorageDead(_11); -+ _9 = <() as D>::call() -> [return: bb7, unwind unreachable]; ++ _9 = <() as D>::call() -> [return: bb6, unwind unreachable]; + } + -+ bb7: { -+ _10 = <() as D>::call() -> [return: bb4, unwind unreachable]; ++ bb8: { ++ _13 = <() as C>::call() -> [return: bb7, unwind unreachable]; + } + -+ bb8: { ++ bb9: { + StorageDead(_16); + StorageDead(_15); + StorageDead(_14); -+ _12 = <() as C>::call() -> [return: bb9, unwind unreachable]; ++ _12 = <() as C>::call() -> [return: bb8, unwind unreachable]; + } + -+ bb9: { -+ _13 = <() as C>::call() -> [return: bb6, unwind unreachable]; ++ bb10: { ++ _16 = <() as B>::call() -> [return: bb9, unwind unreachable]; + } + -+ bb10: { ++ bb11: { + StorageDead(_19); + StorageDead(_18); + StorageDead(_17); -+ _15 = <() as B>::call() -> [return: bb11, unwind unreachable]; -+ } -+ -+ bb11: { -+ _16 = <() as B>::call() -> [return: bb8, unwind unreachable]; ++ _15 = <() as B>::call() -> [return: bb10, unwind unreachable]; + } + + bb12: { @@ -128,7 +128,7 @@ + } + + bb13: { -+ _19 = <() as A>::call() -> [return: bb10, unwind unreachable]; ++ _19 = <() as A>::call() -> [return: bb11, unwind unreachable]; } } diff --git a/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-unwind.diff index 0a4ce40c5..3f334779e 100644 --- a/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-unwind.diff @@ -69,58 +69,58 @@ + } + + bb2: { ++ _4 = <() as F>::call() -> [return: bb1, unwind continue]; ++ } ++ ++ bb3: { + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); -+ _3 = <() as F>::call() -> [return: bb3, unwind continue]; ++ _3 = <() as F>::call() -> [return: bb2, unwind continue]; + } + -+ bb3: { -+ _4 = <() as F>::call() -> [return: bb1, unwind continue]; ++ bb4: { ++ _7 = <() as E>::call() -> [return: bb3, unwind continue]; + } + -+ bb4: { ++ bb5: { + StorageDead(_10); + StorageDead(_9); + StorageDead(_8); -+ _6 = <() as E>::call() -> [return: bb5, unwind continue]; ++ _6 = <() as E>::call() -> [return: bb4, unwind continue]; + } + -+ bb5: { -+ _7 = <() as E>::call() -> [return: bb2, unwind continue]; ++ bb6: { ++ _10 = <() as D>::call() -> [return: bb5, unwind continue]; + } + -+ bb6: { ++ bb7: { + StorageDead(_13); + StorageDead(_12); + StorageDead(_11); -+ _9 = <() as D>::call() -> [return: bb7, unwind continue]; ++ _9 = <() as D>::call() -> [return: bb6, unwind continue]; + } + -+ bb7: { -+ _10 = <() as D>::call() -> [return: bb4, unwind continue]; ++ bb8: { ++ _13 = <() as C>::call() -> [return: bb7, unwind continue]; + } + -+ bb8: { ++ bb9: { + StorageDead(_16); + StorageDead(_15); + StorageDead(_14); -+ _12 = <() as C>::call() -> [return: bb9, unwind continue]; ++ _12 = <() as C>::call() -> [return: bb8, unwind continue]; + } + -+ bb9: { -+ _13 = <() as C>::call() -> [return: bb6, unwind continue]; ++ bb10: { ++ _16 = <() as B>::call() -> [return: bb9, unwind continue]; + } + -+ bb10: { ++ bb11: { + StorageDead(_19); + StorageDead(_18); + StorageDead(_17); -+ _15 = <() as B>::call() -> [return: bb11, unwind continue]; -+ } -+ -+ bb11: { -+ _16 = <() as B>::call() -> [return: bb8, unwind continue]; ++ _15 = <() as B>::call() -> [return: bb10, unwind continue]; + } + + bb12: { @@ -128,7 +128,7 @@ + } + + bb13: { -+ _19 = <() as A>::call() -> [return: bb10, unwind continue]; ++ _19 = <() as A>::call() -> [return: bb11, unwind continue]; } } diff --git a/tests/mir-opt/inline/indirect_destination.rs b/tests/mir-opt/inline/indirect_destination.rs new file mode 100644 index 000000000..2842e2336 --- /dev/null +++ b/tests/mir-opt/inline/indirect_destination.rs @@ -0,0 +1,42 @@ +// Test for inlining with an indirect destination place. +// +// unit-test: Inline +// edition: 2021 +// needs-unwind +#![crate_type = "lib"] +#![feature(custom_mir, core_intrinsics)] +use core::intrinsics::mir::*; + +#[custom_mir(dialect = "runtime", phase = "initial")] +// CHECK-LABEL: fn f( +// CHECK: bb1: { +// CHECK-NEXT: StorageLive([[A:.*]]); +// CHECK-NEXT: [[A]] = &mut (*_1); +// CHECK-NEXT: StorageLive([[B:.*]]); +// CHECK-NEXT: [[B]] = const 42_u8; +// CHECK-NEXT: (*[[A]]) = move [[B]]; +// CHECK-NEXT: StorageDead([[B]]); +// CHECK-NEXT: StorageDead([[A]]); +// CHECK-NEXT: goto -> bb1; +// CHECK-NEXT: } +pub fn f(a: *mut u8) { + mir! { + { + Goto(bb1) + } + bb1 = { + Call(*a = g(), bb1, UnwindUnreachable()) + } + } +} + +#[custom_mir(dialect = "runtime", phase = "initial")] +#[inline(always)] +fn g() -> u8 { + mir! { + { + RET = 42; + Return() + } + } +} diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff index 40eeda539..68c612314 100644 --- a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff @@ -50,20 +50,20 @@ bb1: { - _3 = &mut _4; - _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new(move _3) -> [return: bb2, unwind unreachable]; -+ StorageDead(_7); -+ StorageDead(_6); -+ StorageDead(_5); -+ StorageDead(_2); -+ drop(_4) -> [return: bb2, unwind unreachable]; ++ StorageDead(_4); ++ _0 = const (); ++ StorageDead(_1); ++ return; } bb2: { - StorageDead(_3); - _1 = <{coroutine@$DIR/inline_coroutine.rs:19:5: 19:8} as Coroutine>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; -+ StorageDead(_4); -+ _0 = const (); -+ StorageDead(_1); -+ return; ++ StorageDead(_7); ++ StorageDead(_6); ++ StorageDead(_5); ++ StorageDead(_2); ++ drop(_4) -> [return: bb1, unwind unreachable]; } bb3: { @@ -89,8 +89,9 @@ + + bb6: { + _1 = CoroutineState::::Yielded(move _8); ++ StorageDead(_8); + discriminant((*_6)) = 3; -+ goto -> bb1; ++ goto -> bb2; + } + + bb7: { @@ -102,7 +103,7 @@ + StorageDead(_8); + _1 = CoroutineState::::Complete(_5); + discriminant((*_6)) = 1; -+ goto -> bb1; ++ goto -> bb2; + } + + bb9: { diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff index fdb42bf3d..1bf14e8c3 100644 --- a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff @@ -34,18 +34,10 @@ StorageLive(_3); StorageLive(_4); - _4 = g() -> [return: bb1, unwind continue]; -- } -- -- bb1: { + _4 = {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8 (#0)}; - _3 = &mut _4; -- _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new(move _3) -> [return: bb2, unwind: bb5]; -- } -- -- bb2: { ++ _3 = &mut _4; + _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}> { pointer: move _3 }; - StorageDead(_3); -- _1 = <{coroutine@$DIR/inline_coroutine.rs:19:5: 19:8} as Coroutine>::resume(move _2, const false) -> [return: bb3, unwind: bb5]; ++ StorageDead(_3); + StorageLive(_5); + _5 = const false; + StorageLive(_6); @@ -55,40 +47,50 @@ + switchInt(move _7) -> [0: bb5, 1: bb9, 3: bb10, otherwise: bb11]; } + bb1: { +- _3 = &mut _4; +- _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new(move _3) -> [return: bb2, unwind: bb5]; ++ StorageDead(_4); ++ _0 = const (); ++ StorageDead(_1); ++ return; + } + +- bb2: { +- StorageDead(_3); +- _1 = <{coroutine@$DIR/inline_coroutine.rs:19:5: 19:8} as Coroutine>::resume(move _2, const false) -> [return: bb3, unwind: bb5]; ++ bb2 (cleanup): { ++ drop(_4) -> [return: bb3, unwind terminate(cleanup)]; + } + - bb3: { -+ bb1: { -+ StorageDead(_7); -+ StorageDead(_6); -+ StorageDead(_5); - StorageDead(_2); +- StorageDead(_2); - drop(_4) -> [return: bb4, unwind: bb6]; -+ drop(_4) -> [return: bb2, unwind: bb4]; ++ bb3 (cleanup): { ++ resume; } -- bb4: { -+ bb2: { - StorageDead(_4); - _0 = const (); - StorageDead(_1); - return; + bb4: { +- StorageDead(_4); +- _0 = const (); +- StorageDead(_1); +- return; ++ StorageDead(_7); ++ StorageDead(_6); ++ StorageDead(_5); ++ StorageDead(_2); ++ drop(_4) -> [return: bb1, unwind: bb3]; } - bb5 (cleanup): { - drop(_4) -> [return: bb6, unwind terminate(cleanup)]; -+ bb3 (cleanup): { -+ drop(_4) -> [return: bb4, unwind terminate(cleanup)]; - } - -- bb6 (cleanup): { -+ bb4 (cleanup): { - resume; -+ } -+ + bb5: { + StorageLive(_8); + switchInt(_5) -> [0: bb6, otherwise: bb7]; -+ } -+ + } + +- bb6 (cleanup): { +- resume; + bb6: { + _8 = const 13_i32; + goto -> bb8; @@ -101,12 +103,13 @@ + + bb8: { + _1 = CoroutineState::::Yielded(move _8); ++ StorageDead(_8); + discriminant((*_6)) = 3; -+ goto -> bb1; ++ goto -> bb4; + } + + bb9: { -+ assert(const false, "coroutine resumed after completion") -> [success: bb9, unwind: bb3]; ++ assert(const false, "coroutine resumed after completion") -> [success: bb9, unwind: bb2]; + } + + bb10: { @@ -114,7 +117,7 @@ + StorageDead(_8); + _1 = CoroutineState::::Complete(_5); + discriminant((*_6)) = 1; -+ goto -> bb1; ++ goto -> bb4; + } + + bb11: { diff --git a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff deleted file mode 100644 index b90e0505c..000000000 --- a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff +++ /dev/null @@ -1,209 +0,0 @@ -- // MIR for `main` before Inline -+ // MIR for `main` after Inline - - fn main() -> () { - let mut _0: (); - let _1: std::boxed::Box>; - let mut _2: std::vec::Vec; - scope 1 { - debug _x => _1; - } -+ scope 2 (inlined Vec::::new) { -+ let mut _3: alloc::raw_vec::RawVec; -+ } -+ scope 3 (inlined Box::>::new) { -+ debug x => _2; -+ let mut _4: usize; -+ let mut _5: usize; -+ let mut _6: *mut u8; -+ let mut _7: *const std::vec::Vec; -+ scope 4 { -+ scope 5 (inlined alloc::alloc::exchange_malloc) { -+ debug size => _4; -+ debug align => _5; -+ let _8: std::alloc::Layout; -+ let mut _9: std::result::Result, std::alloc::AllocError>; -+ let mut _10: isize; -+ let mut _12: !; -+ scope 6 { -+ debug layout => _8; -+ let _11: std::ptr::NonNull<[u8]>; -+ let mut _13: &std::alloc::Global; -+ scope 8 { -+ debug ptr => _11; -+ scope 18 (inlined NonNull::<[u8]>::as_mut_ptr) { -+ debug self => _11; -+ let mut _15: std::ptr::NonNull; -+ scope 19 (inlined NonNull::<[u8]>::as_non_null_ptr) { -+ debug self => _11; -+ let mut _16: *mut u8; -+ let mut _17: *mut [u8]; -+ scope 20 { -+ scope 21 (inlined NonNull::<[u8]>::as_ptr) { -+ debug self => _11; -+ let mut _18: *const [u8]; -+ } -+ scope 22 (inlined ptr::mut_ptr::::as_mut_ptr) { -+ debug self => _17; -+ } -+ scope 23 (inlined NonNull::::new_unchecked) { -+ debug ptr => _16; -+ let mut _19: *const u8; -+ scope 24 { -+ scope 25 (inlined NonNull::::new_unchecked::runtime::) { -+ debug ptr => _16; -+ scope 26 (inlined ptr::mut_ptr::::is_null) { -+ debug self => _16; -+ let mut _20: *mut u8; -+ scope 27 { -+ scope 28 (inlined ptr::mut_ptr::::is_null::runtime_impl) { -+ debug ptr => _20; -+ scope 29 (inlined ptr::mut_ptr::::addr) { -+ debug self => _20; -+ scope 30 { -+ scope 31 (inlined ptr::mut_ptr::::cast::<()>) { -+ debug self => _20; -+ } -+ } -+ } -+ } -+ } -+ } -+ } -+ } -+ } -+ } -+ } -+ scope 32 (inlined NonNull::::as_ptr) { -+ debug self => _15; -+ let mut _21: *const u8; -+ } -+ } -+ } -+ scope 17 (inlined ::allocate) { -+ debug self => const _; -+ debug layout => _8; -+ } -+ } -+ scope 7 { -+ scope 9 (inlined Layout::from_size_align_unchecked) { -+ debug size => _4; -+ debug align => _5; -+ let mut _14: std::ptr::Alignment; -+ scope 10 { -+ scope 11 (inlined std::ptr::Alignment::new_unchecked) { -+ debug align => _5; -+ scope 12 { -+ scope 14 (inlined std::ptr::Alignment::new_unchecked::runtime) { -+ debug align => _5; -+ scope 15 (inlined core::num::::is_power_of_two) { -+ debug self => _5; -+ scope 16 (inlined core::num::::count_ones) { -+ debug self => _5; -+ } -+ } -+ } -+ } -+ scope 13 { -+ } -+ } -+ } -+ } -+ } -+ } -+ } -+ } - - bb0: { - StorageLive(_1); - StorageLive(_2); -- _2 = Vec::::new() -> [return: bb1, unwind unreachable]; -+ StorageLive(_3); -+ _3 = const _; -+ _2 = Vec:: { buf: move _3, len: const 0_usize }; -+ StorageDead(_3); -+ StorageLive(_4); -+ StorageLive(_5); -+ StorageLive(_6); -+ StorageLive(_7); -+ _4 = SizeOf(std::vec::Vec); -+ _5 = AlignOf(std::vec::Vec); -+ StorageLive(_8); -+ StorageLive(_10); -+ StorageLive(_11); -+ StorageLive(_12); -+ StorageLive(_13); -+ StorageLive(_14); -+ _14 = _5 as std::ptr::Alignment (Transmute); -+ _8 = Layout { size: _4, align: move _14 }; -+ StorageDead(_14); -+ StorageLive(_9); -+ _13 = const _; -+ _9 = std::alloc::Global::alloc_impl(move _13, _8, const false) -> [return: bb5, unwind unreachable]; - } - - bb1: { -- _1 = Box::>::new(move _2) -> [return: bb2, unwind unreachable]; -+ StorageDead(_1); -+ return; - } - - bb2: { -+ _12 = handle_alloc_error(move _8) -> unwind unreachable; -+ } -+ -+ bb3: { -+ unreachable; -+ } -+ -+ bb4: { -+ _11 = ((_9 as Ok).0: std::ptr::NonNull<[u8]>); -+ StorageLive(_15); -+ StorageLive(_16); -+ StorageLive(_17); -+ StorageLive(_18); -+ _18 = (_11.0: *const [u8]); -+ _17 = move _18 as *mut [u8] (PtrToPtr); -+ StorageDead(_18); -+ _16 = _17 as *mut u8 (PtrToPtr); -+ StorageDead(_17); -+ StorageLive(_19); -+ StorageLive(_20); -+ _19 = _16 as *const u8 (PointerCoercion(MutToConstPointer)); -+ _15 = NonNull:: { pointer: _19 }; -+ StorageDead(_20); -+ StorageDead(_19); -+ StorageDead(_16); -+ StorageLive(_21); -+ _21 = (_15.0: *const u8); -+ _6 = move _21 as *mut u8 (PtrToPtr); -+ StorageDead(_21); -+ StorageDead(_15); -+ StorageDead(_9); -+ StorageDead(_13); -+ StorageDead(_12); -+ StorageDead(_11); -+ StorageDead(_10); -+ StorageDead(_8); -+ _1 = ShallowInitBox(move _6, std::vec::Vec); -+ _7 = (((_1.0: std::ptr::Unique>).0: std::ptr::NonNull>).0: *const std::vec::Vec); -+ (*_7) = move _2; -+ StorageDead(_7); -+ StorageDead(_6); -+ StorageDead(_5); -+ StorageDead(_4); - StorageDead(_2); - _0 = const (); -- drop(_1) -> [return: bb3, unwind unreachable]; -+ drop(_1) -> [return: bb1, unwind unreachable]; - } - -- bb3: { -- StorageDead(_1); -- return; -+ bb5: { -+ _10 = discriminant(_9); -+ switchInt(move _10) -> [0: bb4, 1: bb2, otherwise: bb3]; - } - } - diff --git a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff deleted file mode 100644 index f9c637caa..000000000 --- a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff +++ /dev/null @@ -1,222 +0,0 @@ -- // MIR for `main` before Inline -+ // MIR for `main` after Inline - - fn main() -> () { - let mut _0: (); - let _1: std::boxed::Box>; - let mut _2: std::vec::Vec; - scope 1 { - debug _x => _1; - } -+ scope 2 (inlined Vec::::new) { -+ let mut _3: alloc::raw_vec::RawVec; -+ } -+ scope 3 (inlined Box::>::new) { -+ debug x => _2; -+ let mut _4: usize; -+ let mut _5: usize; -+ let mut _6: *mut u8; -+ let mut _7: *const std::vec::Vec; -+ scope 4 { -+ scope 5 (inlined alloc::alloc::exchange_malloc) { -+ debug size => _4; -+ debug align => _5; -+ let _8: std::alloc::Layout; -+ let mut _9: std::result::Result, std::alloc::AllocError>; -+ let mut _10: isize; -+ let mut _12: !; -+ scope 6 { -+ debug layout => _8; -+ let _11: std::ptr::NonNull<[u8]>; -+ let mut _13: &std::alloc::Global; -+ scope 8 { -+ debug ptr => _11; -+ scope 18 (inlined NonNull::<[u8]>::as_mut_ptr) { -+ debug self => _11; -+ let mut _15: std::ptr::NonNull; -+ scope 19 (inlined NonNull::<[u8]>::as_non_null_ptr) { -+ debug self => _11; -+ let mut _16: *mut u8; -+ let mut _17: *mut [u8]; -+ scope 20 { -+ scope 21 (inlined NonNull::<[u8]>::as_ptr) { -+ debug self => _11; -+ let mut _18: *const [u8]; -+ } -+ scope 22 (inlined ptr::mut_ptr::::as_mut_ptr) { -+ debug self => _17; -+ } -+ scope 23 (inlined NonNull::::new_unchecked) { -+ debug ptr => _16; -+ let mut _19: *const u8; -+ scope 24 { -+ scope 25 (inlined NonNull::::new_unchecked::runtime::) { -+ debug ptr => _16; -+ scope 26 (inlined ptr::mut_ptr::::is_null) { -+ debug self => _16; -+ let mut _20: *mut u8; -+ scope 27 { -+ scope 28 (inlined ptr::mut_ptr::::is_null::runtime_impl) { -+ debug ptr => _20; -+ scope 29 (inlined ptr::mut_ptr::::addr) { -+ debug self => _20; -+ scope 30 { -+ scope 31 (inlined ptr::mut_ptr::::cast::<()>) { -+ debug self => _20; -+ } -+ } -+ } -+ } -+ } -+ } -+ } -+ } -+ } -+ } -+ } -+ scope 32 (inlined NonNull::::as_ptr) { -+ debug self => _15; -+ let mut _21: *const u8; -+ } -+ } -+ } -+ scope 17 (inlined ::allocate) { -+ debug self => const _; -+ debug layout => _8; -+ } -+ } -+ scope 7 { -+ scope 9 (inlined Layout::from_size_align_unchecked) { -+ debug size => _4; -+ debug align => _5; -+ let mut _14: std::ptr::Alignment; -+ scope 10 { -+ scope 11 (inlined std::ptr::Alignment::new_unchecked) { -+ debug align => _5; -+ scope 12 { -+ scope 14 (inlined std::ptr::Alignment::new_unchecked::runtime) { -+ debug align => _5; -+ scope 15 (inlined core::num::::is_power_of_two) { -+ debug self => _5; -+ scope 16 (inlined core::num::::count_ones) { -+ debug self => _5; -+ } -+ } -+ } -+ } -+ scope 13 { -+ } -+ } -+ } -+ } -+ } -+ } -+ } -+ } - - bb0: { - StorageLive(_1); - StorageLive(_2); -- _2 = Vec::::new() -> [return: bb1, unwind continue]; -+ StorageLive(_3); -+ _3 = const _; -+ _2 = Vec:: { buf: move _3, len: const 0_usize }; -+ StorageDead(_3); -+ StorageLive(_4); -+ StorageLive(_5); -+ StorageLive(_6); -+ StorageLive(_7); -+ _4 = SizeOf(std::vec::Vec); -+ _5 = AlignOf(std::vec::Vec); -+ StorageLive(_8); -+ StorageLive(_10); -+ StorageLive(_11); -+ StorageLive(_12); -+ StorageLive(_13); -+ StorageLive(_14); -+ _14 = _5 as std::ptr::Alignment (Transmute); -+ _8 = Layout { size: _4, align: move _14 }; -+ StorageDead(_14); -+ StorageLive(_9); -+ _13 = const _; -+ _9 = std::alloc::Global::alloc_impl(move _13, _8, const false) -> [return: bb7, unwind: bb3]; - } - - bb1: { -- _1 = Box::>::new(move _2) -> [return: bb2, unwind: bb4]; -+ StorageDead(_1); -+ return; - } - -- bb2: { -- StorageDead(_2); -- _0 = const (); -- drop(_1) -> [return: bb3, unwind: bb4]; -+ bb2 (cleanup): { -+ resume; - } - -- bb3: { -- StorageDead(_1); -- return; -+ bb3 (cleanup): { -+ drop(_2) -> [return: bb2, unwind terminate(cleanup)]; - } - -- bb4 (cleanup): { -- resume; -+ bb4: { -+ _12 = handle_alloc_error(move _8) -> bb3; -+ } -+ -+ bb5: { -+ unreachable; -+ } -+ -+ bb6: { -+ _11 = ((_9 as Ok).0: std::ptr::NonNull<[u8]>); -+ StorageLive(_15); -+ StorageLive(_16); -+ StorageLive(_17); -+ StorageLive(_18); -+ _18 = (_11.0: *const [u8]); -+ _17 = move _18 as *mut [u8] (PtrToPtr); -+ StorageDead(_18); -+ _16 = _17 as *mut u8 (PtrToPtr); -+ StorageDead(_17); -+ StorageLive(_19); -+ StorageLive(_20); -+ _19 = _16 as *const u8 (PointerCoercion(MutToConstPointer)); -+ _15 = NonNull:: { pointer: _19 }; -+ StorageDead(_20); -+ StorageDead(_19); -+ StorageDead(_16); -+ StorageLive(_21); -+ _21 = (_15.0: *const u8); -+ _6 = move _21 as *mut u8 (PtrToPtr); -+ StorageDead(_21); -+ StorageDead(_15); -+ StorageDead(_9); -+ StorageDead(_13); -+ StorageDead(_12); -+ StorageDead(_11); -+ StorageDead(_10); -+ StorageDead(_8); -+ _1 = ShallowInitBox(move _6, std::vec::Vec); -+ _7 = (((_1.0: std::ptr::Unique>).0: std::ptr::NonNull>).0: *const std::vec::Vec); -+ (*_7) = move _2; -+ StorageDead(_7); -+ StorageDead(_6); -+ StorageDead(_5); -+ StorageDead(_4); -+ StorageDead(_2); -+ _0 = const (); -+ drop(_1) -> [return: bb1, unwind: bb2]; -+ } -+ -+ bb7: { -+ _10 = discriminant(_9); -+ switchInt(move _10) -> [0: bb6, 1: bb4, otherwise: bb5]; - } - } - diff --git a/tests/mir-opt/inline/inline_into_box_place.rs b/tests/mir-opt/inline/inline_into_box_place.rs deleted file mode 100644 index 65f8e2916..000000000 --- a/tests/mir-opt/inline/inline_into_box_place.rs +++ /dev/null @@ -1,11 +0,0 @@ -// ignore-endian-big -// EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// ignore-debug MIR alignment checks in std alter the diff, breaking the test -// compile-flags: -Zmir-opt-level=4 -Zinline-mir-hint-threshold=200 - -// EMIT_MIR inline_into_box_place.main.Inline.diff -fn main() { - // CHECK-LABEL: fn main( - // CHECK: (inlined Box::>::new) - let _x: Box> = Box::new(Vec::new()); -} diff --git a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff index f17c9ba3f..f50603a66 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff @@ -60,16 +60,6 @@ } bb1: { - StorageDead(_12); - StorageDead(_11); - StorageDead(_10); - StorageDead(_4); - _5 = discriminant(_3); -- switchInt(move _5) -> [0: bb2, 1: bb4, otherwise: bb3]; -+ goto -> bb2; - } - - bb2: { StorageLive(_9); _9 = ((_3 as Continue).0: i32); _2 = _9; @@ -77,14 +67,14 @@ _0 = Result::::Ok(move _2); StorageDead(_2); StorageDead(_3); - goto -> bb5; + goto -> bb4; } - bb3: { + bb2: { unreachable; } - bb4: { + bb3: { StorageLive(_6); _6 = ((_3 as Break).0: std::result::Result); StorageLive(_8); @@ -100,20 +90,30 @@ StorageDead(_6); StorageDead(_2); StorageDead(_3); - goto -> bb5; + goto -> bb4; } - bb5: { + bb4: { return; } + bb5: { + StorageDead(_12); + StorageDead(_11); + StorageDead(_10); + StorageDead(_4); + _5 = discriminant(_3); +- switchInt(move _5) -> [0: bb1, 1: bb3, otherwise: bb2]; ++ goto -> bb1; + } + bb6: { _12 = move ((_4 as Err).0: i32); StorageLive(_13); _13 = Result::::Err(move _12); _3 = ControlFlow::, i32>::Break(move _13); StorageDead(_13); -- goto -> bb1; +- goto -> bb5; + goto -> bb9; } @@ -124,7 +124,7 @@ bb8: { _11 = move ((_4 as Ok).0: i32); _3 = ControlFlow::, i32>::Continue(move _11); - goto -> bb1; + goto -> bb5; + } + + bb9: { @@ -133,7 +133,7 @@ + StorageDead(_10); + StorageDead(_4); + _5 = discriminant(_3); -+ goto -> bb4; ++ goto -> bb3; } } diff --git a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff index f17c9ba3f..f50603a66 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff @@ -60,16 +60,6 @@ } bb1: { - StorageDead(_12); - StorageDead(_11); - StorageDead(_10); - StorageDead(_4); - _5 = discriminant(_3); -- switchInt(move _5) -> [0: bb2, 1: bb4, otherwise: bb3]; -+ goto -> bb2; - } - - bb2: { StorageLive(_9); _9 = ((_3 as Continue).0: i32); _2 = _9; @@ -77,14 +67,14 @@ _0 = Result::::Ok(move _2); StorageDead(_2); StorageDead(_3); - goto -> bb5; + goto -> bb4; } - bb3: { + bb2: { unreachable; } - bb4: { + bb3: { StorageLive(_6); _6 = ((_3 as Break).0: std::result::Result); StorageLive(_8); @@ -100,20 +90,30 @@ StorageDead(_6); StorageDead(_2); StorageDead(_3); - goto -> bb5; + goto -> bb4; } - bb5: { + bb4: { return; } + bb5: { + StorageDead(_12); + StorageDead(_11); + StorageDead(_10); + StorageDead(_4); + _5 = discriminant(_3); +- switchInt(move _5) -> [0: bb1, 1: bb3, otherwise: bb2]; ++ goto -> bb1; + } + bb6: { _12 = move ((_4 as Err).0: i32); StorageLive(_13); _13 = Result::::Err(move _12); _3 = ControlFlow::, i32>::Break(move _13); StorageDead(_13); -- goto -> bb1; +- goto -> bb5; + goto -> bb9; } @@ -124,7 +124,7 @@ bb8: { _11 = move ((_4 as Ok).0: i32); _3 = ControlFlow::, i32>::Continue(move _11); - goto -> bb1; + goto -> bb5; + } + + bb9: { @@ -133,7 +133,7 @@ + StorageDead(_10); + StorageDead(_4); + _5 = discriminant(_3); -+ goto -> bb4; ++ goto -> bb3; } } diff --git a/tests/mir-opt/jump_threading.rs b/tests/mir-opt/jump_threading.rs index 852dcd0db..66e5c5d3c 100644 --- a/tests/mir-opt/jump_threading.rs +++ b/tests/mir-opt/jump_threading.rs @@ -52,19 +52,19 @@ fn identity(x: Result) -> Result { // CHECK: [[x:_.*]] = _1; // CHECK: switchInt(move {{_.*}}) -> [0: bb8, 1: bb6, otherwise: bb7]; // CHECK: bb1: { - // CHECK: goto -> bb2; - // CHECK: bb2: { // CHECK: {{_.*}} = (([[controlflow:_.*]] as Continue).0: i32); // CHECK: _0 = Result::::Ok( - // CHECK: goto -> bb5; - // CHECK: bb3: { + // CHECK: goto -> bb4; + // CHECK: bb2: { // CHECK: unreachable; - // CHECK: bb4: { + // CHECK: bb3: { // CHECK: {{_.*}} = (([[controlflow]] as Break).0: std::result::Result); // CHECK: _0 = Result::::Err( - // CHECK: goto -> bb5; - // CHECK: bb5: { + // CHECK: goto -> bb4; + // CHECK: bb4: { // CHECK: return; + // CHECK: bb5: { + // CHECK: goto -> bb1; // CHECK: bb6: { // CHECK: {{_.*}} = move (([[x]] as Err).0: i32); // CHECK: [[controlflow]] = ControlFlow::, i32>::Break( @@ -74,9 +74,9 @@ fn identity(x: Result) -> Result { // CHECK: bb8: { // CHECK: {{_.*}} = move (([[x]] as Ok).0: i32); // CHECK: [[controlflow]] = ControlFlow::, i32>::Continue( - // CHECK: goto -> bb1; + // CHECK: goto -> bb5; // CHECK: bb9: { - // CHECK: goto -> bb4; + // CHECK: goto -> bb3; Ok(x?) } diff --git a/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.panic-abort.diff b/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.panic-abort.diff deleted file mode 100644 index 194478560..000000000 --- a/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.panic-abort.diff +++ /dev/null @@ -1,48 +0,0 @@ -- // MIR for `option_payload` before LowerIntrinsics -+ // MIR for `option_payload` after LowerIntrinsics - - fn option_payload(_1: &Option, _2: &Option) -> () { - debug o => _1; - debug p => _2; - let mut _0: (); - let mut _4: *const std::option::Option; - let mut _6: *const std::option::Option; - scope 1 { - let _3: *const usize; - scope 2 { - debug _x => _3; - let _5: *const std::string::String; - scope 3 { - debug _y => _5; - } - } - } - - bb0: { - StorageLive(_3); - StorageLive(_4); - _4 = &raw const (*_1); -- _3 = option_payload_ptr::(move _4) -> [return: bb1, unwind unreachable]; -+ _3 = &raw const (((*_4) as Some).0: usize); -+ goto -> bb1; - } - - bb1: { - StorageDead(_4); - StorageLive(_5); - StorageLive(_6); - _6 = &raw const (*_2); -- _5 = option_payload_ptr::(move _6) -> [return: bb2, unwind unreachable]; -+ _5 = &raw const (((*_6) as Some).0: std::string::String); -+ goto -> bb2; - } - - bb2: { - StorageDead(_6); - _0 = const (); - StorageDead(_5); - StorageDead(_3); - return; - } - } - diff --git a/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.panic-unwind.diff b/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.panic-unwind.diff deleted file mode 100644 index 194478560..000000000 --- a/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.panic-unwind.diff +++ /dev/null @@ -1,48 +0,0 @@ -- // MIR for `option_payload` before LowerIntrinsics -+ // MIR for `option_payload` after LowerIntrinsics - - fn option_payload(_1: &Option, _2: &Option) -> () { - debug o => _1; - debug p => _2; - let mut _0: (); - let mut _4: *const std::option::Option; - let mut _6: *const std::option::Option; - scope 1 { - let _3: *const usize; - scope 2 { - debug _x => _3; - let _5: *const std::string::String; - scope 3 { - debug _y => _5; - } - } - } - - bb0: { - StorageLive(_3); - StorageLive(_4); - _4 = &raw const (*_1); -- _3 = option_payload_ptr::(move _4) -> [return: bb1, unwind unreachable]; -+ _3 = &raw const (((*_4) as Some).0: usize); -+ goto -> bb1; - } - - bb1: { - StorageDead(_4); - StorageLive(_5); - StorageLive(_6); - _6 = &raw const (*_2); -- _5 = option_payload_ptr::(move _6) -> [return: bb2, unwind unreachable]; -+ _5 = &raw const (((*_6) as Some).0: std::string::String); -+ goto -> bb2; - } - - bb2: { - StorageDead(_6); - _0 = const (); - StorageDead(_5); - StorageDead(_3); - return; - } - } - diff --git a/tests/mir-opt/lower_intrinsics.rs b/tests/mir-opt/lower_intrinsics.rs index 913605cc2..cba2bc18d 100644 --- a/tests/mir-opt/lower_intrinsics.rs +++ b/tests/mir-opt/lower_intrinsics.rs @@ -222,18 +222,6 @@ pub fn write_via_move_string(r: &mut String, v: String) { pub enum Never {} -// EMIT_MIR lower_intrinsics.option_payload.LowerIntrinsics.diff -pub fn option_payload(o: &Option, p: &Option) { - // CHECK-LABEL: fn option_payload( - // CHECK: {{_.*}} = &raw const (((*{{_.*}}) as Some).0: usize); - // CHECK: {{_.*}} = &raw const (((*{{_.*}}) as Some).0: std::string::String); - - unsafe { - let _x = core::intrinsics::option_payload_ptr(o); - let _y = core::intrinsics::option_payload_ptr(p); - } -} - // EMIT_MIR lower_intrinsics.ptr_offset.LowerIntrinsics.diff pub unsafe fn ptr_offset(p: *const i32, d: isize) -> *const i32 { // CHECK-LABEL: fn ptr_offset( diff --git a/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir b/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir index ebb2f70a4..5bf78b615 100644 --- a/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir @@ -28,43 +28,43 @@ fn main() -> () { StorageLive(_3); PlaceMention(_1); _6 = Le(const 0_i32, _1); - switchInt(move _6) -> [0: bb4, otherwise: bb1]; + switchInt(move _6) -> [0: bb3, otherwise: bb8]; } bb1: { - _7 = Lt(_1, const 10_i32); - switchInt(move _7) -> [0: bb4, otherwise: bb2]; + falseEdge -> [real: bb9, imaginary: bb4]; } bb2: { - falseEdge -> [real: bb9, imaginary: bb6]; + _3 = const 3_i32; + goto -> bb14; } bb3: { - _3 = const 3_i32; - goto -> bb14; + _4 = Le(const 10_i32, _1); + switchInt(move _4) -> [0: bb5, otherwise: bb7]; } bb4: { - _4 = Le(const 10_i32, _1); - switchInt(move _4) -> [0: bb7, otherwise: bb5]; + falseEdge -> [real: bb12, imaginary: bb6]; } bb5: { - _5 = Le(_1, const 20_i32); - switchInt(move _5) -> [0: bb7, otherwise: bb6]; + switchInt(_1) -> [4294967295: bb6, otherwise: bb2]; } bb6: { - falseEdge -> [real: bb12, imaginary: bb8]; + falseEdge -> [real: bb13, imaginary: bb2]; } bb7: { - switchInt(_1) -> [4294967295: bb8, otherwise: bb3]; + _5 = Le(_1, const 20_i32); + switchInt(move _5) -> [0: bb5, otherwise: bb4]; } bb8: { - falseEdge -> [real: bb13, imaginary: bb3]; + _7 = Lt(_1, const 10_i32); + switchInt(move _7) -> [0: bb3, otherwise: bb1]; } bb9: { @@ -83,7 +83,7 @@ fn main() -> () { bb11: { StorageDead(_9); - falseEdge -> [real: bb3, imaginary: bb6]; + falseEdge -> [real: bb2, imaginary: bb4]; } bb12: { 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 50189d192..d5628dc7a 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 @@ -69,7 +69,7 @@ bb3: { - _1 = move ((_2 as Some).0: std::alloc::Layout); -+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): ptr::alignment::AlignmentEnum32) }}; ++ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum32) }}; StorageDead(_10); StorageDead(_2); StorageLive(_3); @@ -78,7 +78,7 @@ StorageLive(_6); _9 = const _; - _6 = std::alloc::Global::alloc_impl(_9, _1, const false) -> [return: bb4, unwind unreachable]; -+ _6 = std::alloc::Global::alloc_impl(const {ALLOC1: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): ptr::alignment::AlignmentEnum32) }}, const false) -> [return: bb4, unwind unreachable]; ++ _6 = std::alloc::Global::alloc_impl(const {ALLOC1: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum32) }}, const false) -> [return: bb4, unwind unreachable]; } bb4: { 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 6966762a1..d28059458 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 @@ -67,7 +67,7 @@ bb4: { - _1 = move ((_2 as Some).0: std::alloc::Layout); -+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): ptr::alignment::AlignmentEnum32) }}; ++ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum32) }}; StorageDead(_10); StorageDead(_2); StorageLive(_3); @@ -76,7 +76,7 @@ StorageLive(_6); _9 = const _; - _6 = std::alloc::Global::alloc_impl(_9, _1, const false) -> [return: bb5, unwind continue]; -+ _6 = std::alloc::Global::alloc_impl(const {ALLOC1: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): ptr::alignment::AlignmentEnum32) }}, const false) -> [return: bb5, unwind continue]; ++ _6 = std::alloc::Global::alloc_impl(const {ALLOC1: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum32) }}, const false) -> [return: bb5, unwind continue]; } bb5: { 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 08a185bad..d139fc73e 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 @@ -69,7 +69,7 @@ bb3: { - _1 = move ((_2 as Some).0: std::alloc::Layout); -+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): ptr::alignment::AlignmentEnum64) }}; ++ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum64) }}; StorageDead(_10); StorageDead(_2); StorageLive(_3); @@ -78,7 +78,7 @@ StorageLive(_6); _9 = const _; - _6 = std::alloc::Global::alloc_impl(_9, _1, const false) -> [return: bb4, unwind unreachable]; -+ _6 = std::alloc::Global::alloc_impl(const {ALLOC1: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): ptr::alignment::AlignmentEnum64) }}, const false) -> [return: bb4, unwind unreachable]; ++ _6 = std::alloc::Global::alloc_impl(const {ALLOC1: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum64) }}, const false) -> [return: bb4, unwind unreachable]; } bb4: { 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 6501cb85e..63db9553b 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 @@ -67,7 +67,7 @@ bb4: { - _1 = move ((_2 as Some).0: std::alloc::Layout); -+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): ptr::alignment::AlignmentEnum64) }}; ++ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum64) }}; StorageDead(_10); StorageDead(_2); StorageLive(_3); @@ -76,7 +76,7 @@ StorageLive(_6); _9 = const _; - _6 = std::alloc::Global::alloc_impl(_9, _1, const false) -> [return: bb5, unwind continue]; -+ _6 = std::alloc::Global::alloc_impl(const {ALLOC1: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): ptr::alignment::AlignmentEnum64) }}, const false) -> [return: bb5, unwind continue]; ++ _6 = std::alloc::Global::alloc_impl(const {ALLOC1: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum64) }}, const false) -> [return: bb5, unwind continue]; } bb5: { diff --git a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir index 49f685cfa..73a3be7f3 100644 --- a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir @@ -30,7 +30,7 @@ fn int_range(_1: usize, _2: usize) -> () { scope 7 { } } - scope 8 (inlined cmp::impls::::lt) { + scope 8 (inlined std::cmp::impls::::lt) { debug self => _6; debug other => _7; let mut _8: usize; diff --git a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir index 630babaa8..713d6cc55 100644 --- a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir @@ -24,16 +24,16 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 { debug src => _1; scope 7 (inlined intrinsics::is_aligned_and_not_null::) { debug ptr => _1; - scope 8 (inlined ptr::const_ptr::::is_null) { + scope 8 (inlined std::ptr::const_ptr::::is_null) { debug self => _1; let mut _3: *const u8; scope 9 { - scope 10 (inlined ptr::const_ptr::::is_null::runtime_impl) { + scope 10 (inlined std::ptr::const_ptr::::is_null::runtime_impl) { debug ptr => _3; - scope 11 (inlined ptr::const_ptr::::addr) { + scope 11 (inlined std::ptr::const_ptr::::addr) { debug self => _3; scope 12 { - scope 13 (inlined ptr::const_ptr::::cast::<()>) { + scope 13 (inlined std::ptr::const_ptr::::cast::<()>) { debug self => _3; } } @@ -41,7 +41,7 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 { } } } - scope 14 (inlined ptr::const_ptr::::is_aligned) { + scope 14 (inlined std::ptr::const_ptr::::is_aligned) { debug self => _1; scope 15 (inlined align_of::) { } diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir index 91c3731f4..cd734b10f 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -33,7 +33,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { scope 7 { } } - scope 8 (inlined cmp::impls::::lt) { + scope 8 (inlined std::cmp::impls::::lt) { debug self => _7; debug other => _8; let mut _9: u32; diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir index f76de02c9..3342da545 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -33,7 +33,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { scope 7 { } } - scope 8 (inlined cmp::impls::::lt) { + scope 8 (inlined std::cmp::impls::::lt) { debug self => _7; debug other => _8; let mut _9: u32; diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir index a7824f36d..6ed3d73b1 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir @@ -17,7 +17,7 @@ fn range_iter_next(_1: &mut std::ops::Range) -> Option { scope 4 { } } - scope 5 (inlined cmp::impls::::lt) { + scope 5 (inlined std::cmp::impls::::lt) { debug self => _2; debug other => _3; let mut _4: u32; diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir index 83c9e6c1a..a030647de 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir @@ -17,7 +17,7 @@ fn range_iter_next(_1: &mut std::ops::Range) -> Option { scope 4 { } } - scope 5 (inlined cmp::impls::::lt) { + scope 5 (inlined std::cmp::impls::::lt) { debug self => _2; debug other => _3; let mut _4: u32; diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir index 548767dca..05f16cdac 100644 --- a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir @@ -30,48 +30,48 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2 debug b => _6; debug c => _8; debug d => _10; - scope 2 (inlined cmp::impls::::le) { + scope 2 (inlined std::cmp::impls::::le) { debug self => _11; debug other => _13; let mut _14: &usize; let mut _15: &usize; - scope 3 (inlined cmp::impls::::le) { + scope 3 (inlined std::cmp::impls::::le) { debug self => _14; debug other => _15; let mut _16: usize; let mut _17: usize; } } - scope 4 (inlined cmp::impls::::le) { + scope 4 (inlined std::cmp::impls::::le) { debug self => _19; debug other => _21; let mut _22: &usize; let mut _23: &usize; - scope 5 (inlined cmp::impls::::le) { + scope 5 (inlined std::cmp::impls::::le) { debug self => _22; debug other => _23; let mut _24: usize; let mut _25: usize; } } - scope 6 (inlined cmp::impls::::le) { + scope 6 (inlined std::cmp::impls::::le) { debug self => _27; debug other => _29; let mut _30: &usize; let mut _31: &usize; - scope 7 (inlined cmp::impls::::le) { + scope 7 (inlined std::cmp::impls::::le) { debug self => _30; debug other => _31; let mut _32: usize; let mut _33: usize; } } - scope 8 (inlined cmp::impls::::le) { + scope 8 (inlined std::cmp::impls::::le) { debug self => _35; debug other => _37; let mut _38: &usize; let mut _39: &usize; - scope 9 (inlined cmp::impls::::le) { + scope 9 (inlined std::cmp::impls::::le) { debug self => _38; debug other => _39; let mut _40: usize; diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir index 8590c9d3b..e4d9060d4 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir @@ -20,33 +20,30 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { debug self => _2; debug slice => _5; let mut _6: *mut u32; + let mut _9: &[&str]; scope 5 { - debug this => _2; - scope 6 { - scope 7 (inlined >::get_unchecked_mut::runtime::) { - debug this => _2; - debug slice => _5; - scope 8 (inlined ptr::mut_ptr::::len) { - debug self => _5; - let mut _9: *const [u32]; - scope 9 (inlined std::ptr::metadata::<[u32]>) { - debug ptr => _9; - scope 10 { - } - } - } - } - scope 11 (inlined ptr::mut_ptr::::as_mut_ptr) { - debug self => _5; + scope 10 (inlined std::ptr::mut_ptr::::as_mut_ptr) { + debug self => _5; + } + scope 11 (inlined std::ptr::mut_ptr::::add) { + debug self => _6; + debug count => _2; + scope 12 { } - scope 12 (inlined ptr::mut_ptr::::add) { - debug self => _6; - debug count => _2; - scope 13 { - } + } + } + scope 6 (inlined std::ptr::mut_ptr::::len) { + debug self => _5; + let mut _10: *const [u32]; + scope 7 (inlined std::ptr::metadata::<[u32]>) { + debug ptr => _10; + scope 8 { } } } + scope 9 (inlined Arguments::<'_>::new_const) { + debug pieces => _9; + } } } } @@ -73,10 +70,12 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { StorageLive(_5); _5 = &raw mut (*_1); StorageLive(_9); + StorageLive(_10); StorageLive(_6); _6 = _5 as *mut u32 (PtrToPtr); _7 = Offset(_6, _2); StorageDead(_6); + StorageDead(_10); StorageDead(_9); StorageDead(_5); _8 = &mut (*_7); diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir index 8590c9d3b..e4d9060d4 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir @@ -20,33 +20,30 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { debug self => _2; debug slice => _5; let mut _6: *mut u32; + let mut _9: &[&str]; scope 5 { - debug this => _2; - scope 6 { - scope 7 (inlined >::get_unchecked_mut::runtime::) { - debug this => _2; - debug slice => _5; - scope 8 (inlined ptr::mut_ptr::::len) { - debug self => _5; - let mut _9: *const [u32]; - scope 9 (inlined std::ptr::metadata::<[u32]>) { - debug ptr => _9; - scope 10 { - } - } - } - } - scope 11 (inlined ptr::mut_ptr::::as_mut_ptr) { - debug self => _5; + scope 10 (inlined std::ptr::mut_ptr::::as_mut_ptr) { + debug self => _5; + } + scope 11 (inlined std::ptr::mut_ptr::::add) { + debug self => _6; + debug count => _2; + scope 12 { } - scope 12 (inlined ptr::mut_ptr::::add) { - debug self => _6; - debug count => _2; - scope 13 { - } + } + } + scope 6 (inlined std::ptr::mut_ptr::::len) { + debug self => _5; + let mut _10: *const [u32]; + scope 7 (inlined std::ptr::metadata::<[u32]>) { + debug ptr => _10; + scope 8 { } } } + scope 9 (inlined Arguments::<'_>::new_const) { + debug pieces => _9; + } } } } @@ -73,10 +70,12 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { StorageLive(_5); _5 = &raw mut (*_1); StorageLive(_9); + StorageLive(_10); StorageLive(_6); _6 = _5 as *mut u32 (PtrToPtr); _7 = Offset(_6, _2); StorageDead(_6); + StorageDead(_10); StorageDead(_9); StorageDead(_5); _8 = &mut (*_7); 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 729841ec5..0d95f81c3 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 @@ -19,56 +19,51 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> debug slice => _5; let mut _7: *mut u32; let mut _8: *mut u32; + let mut _14: &[&str]; scope 4 { - debug ((this: std::ops::Range).0: usize) => _3; - debug ((this: std::ops::Range).1: usize) => _4; + let _6: usize; scope 5 { - let _6: usize; - scope 6 { - debug new_len => _6; - scope 11 (inlined ptr::mut_ptr::::as_mut_ptr) { - debug self => _5; + debug new_len => _6; + scope 10 (inlined std::ptr::mut_ptr::::as_mut_ptr) { + debug self => _5; + } + scope 11 (inlined std::ptr::mut_ptr::::add) { + debug self => _7; + debug count => _3; + scope 12 { } - scope 12 (inlined ptr::mut_ptr::::add) { - debug self => _7; - debug count => _3; - scope 13 { - } + } + scope 13 (inlined slice_from_raw_parts_mut::) { + debug data => _8; + debug len => _6; + let mut _9: *mut (); + scope 14 (inlined std::ptr::mut_ptr::::cast::<()>) { + debug self => _8; } - scope 14 (inlined slice_from_raw_parts_mut::) { - debug data => _8; - debug len => _6; - let mut _9: *mut (); - scope 15 (inlined ptr::mut_ptr::::cast::<()>) { - debug self => _8; - } - scope 16 (inlined std::ptr::from_raw_parts_mut::<[u32]>) { - debug data_address => _9; - debug metadata => _6; - let mut _10: *const (); - let mut _11: std::ptr::metadata::PtrComponents<[u32]>; - let mut _12: std::ptr::metadata::PtrRepr<[u32]>; - scope 17 { - } + scope 15 (inlined std::ptr::from_raw_parts_mut::<[u32]>) { + debug data_address => _9; + debug metadata => _6; + let mut _10: *const (); + let mut _11: std::ptr::metadata::PtrComponents<[u32]>; + let mut _12: std::ptr::metadata::PtrRepr<[u32]>; + scope 16 { } } } - scope 7 (inlined as SliceIndex<[T]>>::get_unchecked_mut::runtime::) { - debug ((this: std::ops::Range).0: usize) => _3; - debug ((this: std::ops::Range).1: usize) => _4; - debug slice => _5; - scope 8 (inlined ptr::mut_ptr::::len) { - debug self => _5; - let mut _14: *const [u32]; - scope 9 (inlined std::ptr::metadata::<[u32]>) { - debug ptr => _14; - scope 10 { - } - } - } + } + } + scope 6 (inlined std::ptr::mut_ptr::::len) { + debug self => _5; + let mut _15: *const [u32]; + scope 7 (inlined std::ptr::metadata::<[u32]>) { + debug ptr => _15; + scope 8 { } } } + scope 9 (inlined Arguments::<'_>::new_const) { + debug pieces => _14; + } } } } @@ -78,8 +73,9 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> _4 = move (_2.1: usize); StorageLive(_5); _5 = &raw mut (*_1); - StorageLive(_6); StorageLive(_14); + StorageLive(_6); + StorageLive(_15); _6 = SubUnchecked(_4, _3); StorageLive(_8); StorageLive(_7); @@ -92,16 +88,17 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> StorageLive(_11); StorageLive(_10); _10 = _9 as *const () (PointerCoercion(MutToConstPointer)); - _11 = ptr::metadata::PtrComponents::<[u32]> { data_address: move _10, metadata: _6 }; + _11 = std::ptr::metadata::PtrComponents::<[u32]> { data_address: move _10, metadata: _6 }; StorageDead(_10); - _12 = ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _11 }; + _12 = std::ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _11 }; StorageDead(_11); _13 = (_12.1: *mut [u32]); StorageDead(_12); StorageDead(_9); StorageDead(_8); - StorageDead(_14); + StorageDead(_15); StorageDead(_6); + StorageDead(_14); StorageDead(_5); _0 = &mut (*_13); return; 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 729841ec5..0d95f81c3 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 @@ -19,56 +19,51 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> debug slice => _5; let mut _7: *mut u32; let mut _8: *mut u32; + let mut _14: &[&str]; scope 4 { - debug ((this: std::ops::Range).0: usize) => _3; - debug ((this: std::ops::Range).1: usize) => _4; + let _6: usize; scope 5 { - let _6: usize; - scope 6 { - debug new_len => _6; - scope 11 (inlined ptr::mut_ptr::::as_mut_ptr) { - debug self => _5; + debug new_len => _6; + scope 10 (inlined std::ptr::mut_ptr::::as_mut_ptr) { + debug self => _5; + } + scope 11 (inlined std::ptr::mut_ptr::::add) { + debug self => _7; + debug count => _3; + scope 12 { } - scope 12 (inlined ptr::mut_ptr::::add) { - debug self => _7; - debug count => _3; - scope 13 { - } + } + scope 13 (inlined slice_from_raw_parts_mut::) { + debug data => _8; + debug len => _6; + let mut _9: *mut (); + scope 14 (inlined std::ptr::mut_ptr::::cast::<()>) { + debug self => _8; } - scope 14 (inlined slice_from_raw_parts_mut::) { - debug data => _8; - debug len => _6; - let mut _9: *mut (); - scope 15 (inlined ptr::mut_ptr::::cast::<()>) { - debug self => _8; - } - scope 16 (inlined std::ptr::from_raw_parts_mut::<[u32]>) { - debug data_address => _9; - debug metadata => _6; - let mut _10: *const (); - let mut _11: std::ptr::metadata::PtrComponents<[u32]>; - let mut _12: std::ptr::metadata::PtrRepr<[u32]>; - scope 17 { - } + scope 15 (inlined std::ptr::from_raw_parts_mut::<[u32]>) { + debug data_address => _9; + debug metadata => _6; + let mut _10: *const (); + let mut _11: std::ptr::metadata::PtrComponents<[u32]>; + let mut _12: std::ptr::metadata::PtrRepr<[u32]>; + scope 16 { } } } - scope 7 (inlined as SliceIndex<[T]>>::get_unchecked_mut::runtime::) { - debug ((this: std::ops::Range).0: usize) => _3; - debug ((this: std::ops::Range).1: usize) => _4; - debug slice => _5; - scope 8 (inlined ptr::mut_ptr::::len) { - debug self => _5; - let mut _14: *const [u32]; - scope 9 (inlined std::ptr::metadata::<[u32]>) { - debug ptr => _14; - scope 10 { - } - } - } + } + } + scope 6 (inlined std::ptr::mut_ptr::::len) { + debug self => _5; + let mut _15: *const [u32]; + scope 7 (inlined std::ptr::metadata::<[u32]>) { + debug ptr => _15; + scope 8 { } } } + scope 9 (inlined Arguments::<'_>::new_const) { + debug pieces => _14; + } } } } @@ -78,8 +73,9 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> _4 = move (_2.1: usize); StorageLive(_5); _5 = &raw mut (*_1); - StorageLive(_6); StorageLive(_14); + StorageLive(_6); + StorageLive(_15); _6 = SubUnchecked(_4, _3); StorageLive(_8); StorageLive(_7); @@ -92,16 +88,17 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> StorageLive(_11); StorageLive(_10); _10 = _9 as *const () (PointerCoercion(MutToConstPointer)); - _11 = ptr::metadata::PtrComponents::<[u32]> { data_address: move _10, metadata: _6 }; + _11 = std::ptr::metadata::PtrComponents::<[u32]> { data_address: move _10, metadata: _6 }; StorageDead(_10); - _12 = ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _11 }; + _12 = std::ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _11 }; StorageDead(_11); _13 = (_12.1: *mut [u32]); StorageDead(_12); StorageDead(_9); StorageDead(_8); - StorageDead(_14); + StorageDead(_15); StorageDead(_6); + StorageDead(_14); StorageDead(_5); _0 = &mut (*_13); return; 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 89009864c..c58b630a0 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 @@ -45,16 +45,16 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { scope 14 { scope 15 (inlined NonNull::::new_unchecked::runtime::) { debug ptr => _9; - scope 16 (inlined ptr::mut_ptr::::is_null) { + scope 16 (inlined std::ptr::mut_ptr::::is_null) { debug self => _9; let mut _24: *mut u8; scope 17 { - scope 18 (inlined ptr::mut_ptr::::is_null::runtime_impl) { + scope 18 (inlined std::ptr::mut_ptr::::is_null::runtime_impl) { debug ptr => _24; - scope 19 (inlined ptr::mut_ptr::::addr) { + scope 19 (inlined std::ptr::mut_ptr::::addr) { debug self => _24; scope 20 { - scope 21 (inlined ptr::mut_ptr::::cast::<()>) { + scope 21 (inlined std::ptr::mut_ptr::::cast::<()>) { debug self => _24; } } @@ -71,7 +71,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { scope 10 { } } - scope 11 (inlined ptr::const_ptr::::add) { + scope 11 (inlined std::ptr::const_ptr::::add) { debug self => _4; debug count => _6; scope 12 { 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 3d76bab7c..1a805f0fd 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 @@ -45,16 +45,16 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { scope 14 { scope 15 (inlined NonNull::::new_unchecked::runtime::) { debug ptr => _9; - scope 16 (inlined ptr::mut_ptr::::is_null) { + scope 16 (inlined std::ptr::mut_ptr::::is_null) { debug self => _9; let mut _24: *mut u8; scope 17 { - scope 18 (inlined ptr::mut_ptr::::is_null::runtime_impl) { + scope 18 (inlined std::ptr::mut_ptr::::is_null::runtime_impl) { debug ptr => _24; - scope 19 (inlined ptr::mut_ptr::::addr) { + scope 19 (inlined std::ptr::mut_ptr::::addr) { debug self => _24; scope 20 { - scope 21 (inlined ptr::mut_ptr::::cast::<()>) { + scope 21 (inlined std::ptr::mut_ptr::::cast::<()>) { debug self => _24; } } @@ -71,7 +71,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { scope 10 { } } - scope 11 (inlined ptr::const_ptr::::add) { + scope 11 (inlined std::ptr::const_ptr::::add) { debug self => _4; debug count => _6; scope 12 { 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 146fa57a0..09075eed6 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 @@ -42,16 +42,16 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 14 { scope 15 (inlined NonNull::::new_unchecked::runtime::) { debug ptr => _9; - scope 16 (inlined ptr::mut_ptr::::is_null) { + scope 16 (inlined std::ptr::mut_ptr::::is_null) { debug self => _9; let mut _22: *mut u8; scope 17 { - scope 18 (inlined ptr::mut_ptr::::is_null::runtime_impl) { + scope 18 (inlined std::ptr::mut_ptr::::is_null::runtime_impl) { debug ptr => _22; - scope 19 (inlined ptr::mut_ptr::::addr) { + scope 19 (inlined std::ptr::mut_ptr::::addr) { debug self => _22; scope 20 { - scope 21 (inlined ptr::mut_ptr::::cast::<()>) { + scope 21 (inlined std::ptr::mut_ptr::::cast::<()>) { debug self => _22; } } @@ -68,7 +68,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 10 { } } - scope 11 (inlined ptr::const_ptr::::add) { + scope 11 (inlined std::ptr::const_ptr::::add) { debug self => _4; debug count => _6; scope 12 { 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 e8586cec9..47b847464 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 @@ -42,16 +42,16 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 14 { scope 15 (inlined NonNull::::new_unchecked::runtime::) { debug ptr => _9; - scope 16 (inlined ptr::mut_ptr::::is_null) { + scope 16 (inlined std::ptr::mut_ptr::::is_null) { debug self => _9; let mut _22: *mut u8; scope 17 { - scope 18 (inlined ptr::mut_ptr::::is_null::runtime_impl) { + scope 18 (inlined std::ptr::mut_ptr::::is_null::runtime_impl) { debug ptr => _22; - scope 19 (inlined ptr::mut_ptr::::addr) { + scope 19 (inlined std::ptr::mut_ptr::::addr) { debug self => _22; scope 20 { - scope 21 (inlined ptr::mut_ptr::::cast::<()>) { + scope 21 (inlined std::ptr::mut_ptr::::cast::<()>) { debug self => _22; } } @@ -68,7 +68,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 10 { } } - scope 11 (inlined ptr::const_ptr::::add) { + scope 11 (inlined std::ptr::const_ptr::::add) { debug self => _4; debug count => _6; scope 12 { diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir index ac1de7b4c..db6922968 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir @@ -39,7 +39,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { scope 8 { } } - scope 9 (inlined cmp::impls::::lt) { + scope 9 (inlined std::cmp::impls::::lt) { debug self => _7; debug other => _8; let mut _9: usize; diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir index 3c49ecf95..81d1832ee 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir @@ -39,7 +39,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { scope 8 { } } - scope 9 (inlined cmp::impls::::lt) { + scope 9 (inlined std::cmp::impls::::lt) { debug self => _7; debug other => _8; let mut _9: usize; 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 f3760463f..5ed7ca5e2 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 @@ -47,16 +47,16 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 14 { scope 15 (inlined NonNull::::new_unchecked::runtime::) { debug ptr => _9; - scope 16 (inlined ptr::mut_ptr::::is_null) { + scope 16 (inlined std::ptr::mut_ptr::::is_null) { debug self => _9; let mut _24: *mut u8; scope 17 { - scope 18 (inlined ptr::mut_ptr::::is_null::runtime_impl) { + scope 18 (inlined std::ptr::mut_ptr::::is_null::runtime_impl) { debug ptr => _24; - scope 19 (inlined ptr::mut_ptr::::addr) { + scope 19 (inlined std::ptr::mut_ptr::::addr) { debug self => _24; scope 20 { - scope 21 (inlined ptr::mut_ptr::::cast::<()>) { + scope 21 (inlined std::ptr::mut_ptr::::cast::<()>) { debug self => _24; } } @@ -73,7 +73,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 10 { } } - scope 11 (inlined ptr::const_ptr::::add) { + scope 11 (inlined std::ptr::const_ptr::::add) { debug self => _4; debug count => _6; scope 12 { 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 e63f8b893..bbb979d23 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 @@ -47,16 +47,16 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 14 { scope 15 (inlined NonNull::::new_unchecked::runtime::) { debug ptr => _9; - scope 16 (inlined ptr::mut_ptr::::is_null) { + scope 16 (inlined std::ptr::mut_ptr::::is_null) { debug self => _9; let mut _24: *mut u8; scope 17 { - scope 18 (inlined ptr::mut_ptr::::is_null::runtime_impl) { + scope 18 (inlined std::ptr::mut_ptr::::is_null::runtime_impl) { debug ptr => _24; - scope 19 (inlined ptr::mut_ptr::::addr) { + scope 19 (inlined std::ptr::mut_ptr::::addr) { debug self => _24; scope 20 { - scope 21 (inlined ptr::mut_ptr::::cast::<()>) { + scope 21 (inlined std::ptr::mut_ptr::::cast::<()>) { debug self => _24; } } @@ -73,7 +73,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 10 { } } - scope 11 (inlined ptr::const_ptr::::add) { + scope 11 (inlined std::ptr::const_ptr::::add) { debug self => _4; debug count => _6; scope 12 { diff --git a/tests/mir-opt/reference_prop.rs b/tests/mir-opt/reference_prop.rs index 36134e019..1b9c8fe15 100644 --- a/tests/mir-opt/reference_prop.rs +++ b/tests/mir-opt/reference_prop.rs @@ -695,7 +695,7 @@ fn multiple_storage() { // As there are multiple `StorageLive` statements for `x`, we cannot know if this `z`'s // pointer address is the address of `x`, so do nothing. let y = *z; - Call(RET = opaque(y), retblock) + Call(RET = opaque(y), retblock, UnwindContinue()) } retblock = { @@ -723,7 +723,7 @@ fn dominate_storage() { } bb1 = { let c = *r; - Call(RET = opaque(c), bb2) + Call(RET = opaque(c), bb2, UnwindContinue()) } bb2 = { StorageDead(x); @@ -759,18 +759,18 @@ fn maybe_dead(m: bool) { bb1 = { StorageDead(x); StorageDead(y); - Call(RET = opaque(u), bb2) + Call(RET = opaque(u), bb2, UnwindContinue()) } bb2 = { // As `x` may be `StorageDead`, `a` may be dangling, so we do nothing. let z = *a; - Call(RET = opaque(z), bb3) + Call(RET = opaque(z), bb3, UnwindContinue()) } bb3 = { // As `y` may be `StorageDead`, `b` may be dangling, so we do nothing. // This implies that we also do not substitute `b` in `bb0`. let t = *b; - Call(RET = opaque(t), retblock) + Call(RET = opaque(t), retblock, UnwindContinue()) } retblock = { Return() diff --git a/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-abort.mir b/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-abort.mir index 566b6af95..9c4d6da29 100644 --- a/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-abort.mir +++ b/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-abort.mir @@ -75,7 +75,7 @@ fn array_casts() -> () { StorageLive(_6); StorageLive(_7); _7 = _2; - _6 = ptr::mut_ptr::::add(move _7, const 1_usize) -> [return: bb1, unwind unreachable]; + _6 = std::ptr::mut_ptr::::add(move _7, const 1_usize) -> [return: bb1, unwind unreachable]; } bb1: { @@ -101,7 +101,7 @@ fn array_casts() -> () { StorageLive(_16); StorageLive(_17); _17 = _9; - _16 = ptr::const_ptr::::add(move _17, const 1_usize) -> [return: bb2, unwind unreachable]; + _16 = std::ptr::const_ptr::::add(move _17, const 1_usize) -> [return: bb2, unwind unreachable]; } bb2: { diff --git a/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-unwind.mir b/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-unwind.mir index d0d317632..ca064ab2b 100644 --- a/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-unwind.mir +++ b/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-unwind.mir @@ -75,7 +75,7 @@ fn array_casts() -> () { StorageLive(_6); StorageLive(_7); _7 = _2; - _6 = ptr::mut_ptr::::add(move _7, const 1_usize) -> [return: bb1, unwind continue]; + _6 = std::ptr::mut_ptr::::add(move _7, const 1_usize) -> [return: bb1, unwind continue]; } bb1: { @@ -101,7 +101,7 @@ fn array_casts() -> () { StorageLive(_16); StorageLive(_17); _17 = _9; - _16 = ptr::const_ptr::::add(move _17, const 1_usize) -> [return: bb2, unwind continue]; + _16 = std::ptr::const_ptr::::add(move _17, const 1_usize) -> [return: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff b/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff index fe4b33001..d287b20c4 100644 --- a/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff +++ b/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff @@ -52,29 +52,21 @@ StorageLive(_10); StorageLive(_11); _9 = discriminant(_1); - switchInt(move _9) -> [0: bb6, 1: bb5, otherwise: bb3]; + switchInt(move _9) -> [0: bb6, 1: bb5, otherwise: bb2]; } bb1: { - StorageDead(_11); - StorageDead(_10); - StorageDead(_9); - _5 = discriminant(_3); - switchInt(move _5) -> [0: bb2, 1: bb4, otherwise: bb3]; - } - - bb2: { _8 = ((_3 as Continue).0: i32); _0 = Result::::Ok(_8); StorageDead(_3); return; } - bb3: { + bb2: { unreachable; } - bb4: { + bb3: { _6 = ((_3 as Break).0: std::result::Result); _13 = ((_6 as Err).0: i32); _0 = Result::::Err(move _13); @@ -82,19 +74,27 @@ return; } + bb4: { + StorageDead(_11); + StorageDead(_10); + StorageDead(_9); + _5 = discriminant(_3); + switchInt(move _5) -> [0: bb1, 1: bb3, otherwise: bb2]; + } + bb5: { _11 = ((_1 as Err).0: i32); StorageLive(_12); _12 = Result::::Err(move _11); _3 = ControlFlow::, i32>::Break(move _12); StorageDead(_12); - goto -> bb1; + goto -> bb4; } bb6: { _10 = ((_1 as Ok).0: i32); _3 = ControlFlow::, i32>::Continue(move _10); - goto -> bb1; + goto -> bb4; } } -- cgit v1.2.3