From 1b5a7448a31f847eb55cb947f2200ab22bfa95bb Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sat, 4 Jan 2025 11:18:22 +0000 Subject: [PATCH 01/20] Add FileCheck to branch.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/branch.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/mir-opt/copy-prop/branch.rs b/tests/mir-opt/copy-prop/branch.rs index fc9b8dc41b166..a26e224fa7088 100644 --- a/tests/mir-opt/copy-prop/branch.rs +++ b/tests/mir-opt/copy-prop/branch.rs @@ -1,4 +1,3 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY //! Tests that we bail out when there are multiple assignments to the same local. //@ test-mir-pass: CopyProp @@ -12,6 +11,14 @@ fn cond() -> bool { // EMIT_MIR branch.foo.CopyProp.diff fn foo() -> i32 { + // CHECK-LABEL: fn foo( + // CHECK: debug x => [[x:_.*]]; + // CHECK: debug y => [[y:_.*]]; + // CHECK: bb3: { + // CHECK: [[y]] = copy [[x]]; + // CHECK: bb5: { + // CHECK: [[y]] = copy [[x]]; + // CHECK: _0 = copy [[y]]; let x = val(); let y = if cond() { From e6dcb25e8997656c11d9fcb8351ace515446ea91 Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sat, 4 Jan 2025 11:18:40 +0000 Subject: [PATCH 02/20] Add FileCheck to calls.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/calls.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/mir-opt/copy-prop/calls.rs b/tests/mir-opt/copy-prop/calls.rs index 8937c0d2ecb22..595ce83a0a2c1 100644 --- a/tests/mir-opt/copy-prop/calls.rs +++ b/tests/mir-opt/copy-prop/calls.rs @@ -1,4 +1,3 @@ -// skip-filecheck // Check that CopyProp does propagate return values of call terminators. //@ test-mir-pass: CopyProp //@ needs-unwind @@ -13,6 +12,12 @@ fn dummy(x: u8) -> u8 { // EMIT_MIR calls.nrvo.CopyProp.diff fn nrvo() -> u8 { + // CHECK-LABEL: fn nrvo( + // CHECK: debug y => _0; + // CHECK-NOT: StorageLive(_1); + // CHECK-NOT: _1 = dummy(const 5_u8) + // CHECK-NOT: _0 = copy _1; + // CHECK-NOT: StorageDead(_1); let y = dummy(5); // this should get NRVO y } @@ -20,6 +25,9 @@ fn nrvo() -> u8 { // EMIT_MIR calls.multiple_edges.CopyProp.diff #[custom_mir(dialect = "runtime", phase = "initial")] fn multiple_edges(t: bool) -> u8 { + // CHECK-LABEL: fn multiple_edges( + // CHECK: bb2: { + // CHECK: _0 = copy _2; mir! { let x: u8; { From 78a143fcebcf53205065bc650c1cbfd5b2229ece Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sat, 4 Jan 2025 11:18:55 +0000 Subject: [PATCH 03/20] Add FileCheck to copy_propagation_arg.rs Signed-off-by: Shunpoco --- .../mir-opt/copy-prop/copy_propagation_arg.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.rs b/tests/mir-opt/copy-prop/copy_propagation_arg.rs index e062e1e972887..08bb40bba0137 100644 --- a/tests/mir-opt/copy-prop/copy_propagation_arg.rs +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.rs @@ -1,4 +1,3 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Check that CopyProp does not propagate an assignment to a function argument // (doing so can break usages of the original argument value) @@ -9,18 +8,31 @@ fn dummy(x: u8) -> u8 { // EMIT_MIR copy_propagation_arg.foo.CopyProp.diff fn foo(mut x: u8) { + // CHECK-LABEL: fn foo( + // CHECK: debug x => [[x:_.*]]; + // CHECK: [[three:_.*]] = copy [[x]]; + // CHECK: [[two:_.*]] = dummy(move [[three]]) + // CHECK: [[x]] = move [[two]]; // calling `dummy` to make a use of `x` that copyprop cannot eliminate x = dummy(x); // this will assign a local to `x` } // EMIT_MIR copy_propagation_arg.bar.CopyProp.diff fn bar(mut x: u8) { + // CHECK-LABEL: fn bar( + // CHECK: debug x => [[x:_.*]]; + // CHECK: [[three:_.*]] = copy [[x]]; + // CHECK: dummy(move [[three]]) + // CHECK: [[x]] = const 5_u8; dummy(x); x = 5; } // EMIT_MIR copy_propagation_arg.baz.CopyProp.diff fn baz(mut x: i32) -> i32 { + // CHECK-LABEL: fn baz( + // CHECK: debug x => [[x:_.*]]; + // CHECK: _0 = copy [[x]]; // self-assignment to a function argument should be eliminated x = x; x @@ -28,6 +40,11 @@ fn baz(mut x: i32) -> i32 { // EMIT_MIR copy_propagation_arg.arg_src.CopyProp.diff fn arg_src(mut x: i32) -> i32 { + // CHECK-LABEL: fn arg_src( + // CHECK: debug x => [[x:_.*]]; + // CHECK: debug y => [[y:_.*]]; + // CHECK: [[y]] = copy [[x]]; + // CHECK: [[x]] = const 123_i32; let y = x; x = 123; // Don't propagate this assignment to `y` y From ab21ba32b41c65a8b643ac661a862295280ca74b Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sat, 4 Jan 2025 11:19:16 +0000 Subject: [PATCH 04/20] Add FileCheck to custom_move_arg.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/custom_move_arg.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/mir-opt/copy-prop/custom_move_arg.rs b/tests/mir-opt/copy-prop/custom_move_arg.rs index 3dce7807b3477..54490b07f32fd 100644 --- a/tests/mir-opt/copy-prop/custom_move_arg.rs +++ b/tests/mir-opt/copy-prop/custom_move_arg.rs @@ -1,4 +1,3 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY //@ test-mir-pass: CopyProp @@ -12,6 +11,13 @@ struct NotCopy(bool); // EMIT_MIR custom_move_arg.f.CopyProp.diff #[custom_mir(dialect = "runtime")] fn f(_1: NotCopy) { + // CHECK-LABEL: fn f( + // CHECK: bb0: { + // CHECK-NOT: _2 = copy _1; + // CHECK: _0 = opaque::(copy _1) + // CHECK: bb1: { + // CHECK-NOT: _3 = move _2; + // CHECK: _0 = opaque::(copy _1) mir! { { let _2 = _1; From 4057797a3fccf8df17367630b98832eecca22260 Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sat, 4 Jan 2025 11:19:29 +0000 Subject: [PATCH 05/20] Add FileCheck to cycle.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/cycle.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/mir-opt/copy-prop/cycle.rs b/tests/mir-opt/copy-prop/cycle.rs index 1c0c9eae7fead..b0cc2fc1d29a0 100644 --- a/tests/mir-opt/copy-prop/cycle.rs +++ b/tests/mir-opt/copy-prop/cycle.rs @@ -1,4 +1,3 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY //! Tests that cyclic assignments don't hang CopyProp, and result in reasonable code. //@ test-mir-pass: CopyProp @@ -8,6 +7,16 @@ fn val() -> i32 { // EMIT_MIR cycle.main.CopyProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: debug z => _2; + // CHECK-NOT: StorageLive(_2); + // CHECK: _2 = copy _1; + // CHECK-NOT: StorageLive(_3); + // CHECK-NOT: _3 = copy _2; + // CHECK-NOT: StorageLive(_4); + // CHECK-NOT: _4 = copy _3; + // CHECK-NOT: _1 = move _4; + // CHECK: _1 = copy _2; let mut x = val(); let y = x; let z = y; From 77d571179c93b0fc580cf09036b7ba7994eed25b Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sat, 4 Jan 2025 11:19:48 +0000 Subject: [PATCH 06/20] Add FileCheck to dead_stores_79191.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/dead_stores_79191.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/mir-opt/copy-prop/dead_stores_79191.rs b/tests/mir-opt/copy-prop/dead_stores_79191.rs index 24420e19fa80d..016680b9530a2 100644 --- a/tests/mir-opt/copy-prop/dead_stores_79191.rs +++ b/tests/mir-opt/copy-prop/dead_stores_79191.rs @@ -1,4 +1,3 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY //@ test-mir-pass: CopyProp @@ -8,6 +7,14 @@ fn id(x: T) -> T { // EMIT_MIR dead_stores_79191.f.CopyProp.after.mir fn f(mut a: usize) -> usize { + // CHECK-LABEL: fn f( + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug b => [[b:_.*]]; + // CHECK: [[b]] = copy [[a]]; + // CHECK: [[a]] = const 5_usize; + // CHECK: [[a]] = copy [[b]]; + // CHECK: [[c:_.*]] = copy [[a]] + // CHECK: id::(move [[c]]) let b = a; a = 5; a = b; From f53476b893fd130bc31b62bad5eba20195851b34 Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sat, 4 Jan 2025 11:20:00 +0000 Subject: [PATCH 07/20] Add FileCheck to dead_stores_better.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/dead_stores_better.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/mir-opt/copy-prop/dead_stores_better.rs b/tests/mir-opt/copy-prop/dead_stores_better.rs index 4b18742940160..9b5dc85dd316c 100644 --- a/tests/mir-opt/copy-prop/dead_stores_better.rs +++ b/tests/mir-opt/copy-prop/dead_stores_better.rs @@ -1,4 +1,3 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // This is a copy of the `dead_stores_79191` test, except that we turn on DSE. This demonstrates // that that pass enables this one to do more optimizations. @@ -12,6 +11,14 @@ fn id(x: T) -> T { // EMIT_MIR dead_stores_better.f.CopyProp.after.mir pub fn f(mut a: usize) -> usize { + // CHECK-LABEL: fn f( + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug b => [[b:_.*]]; + // CHECK: [[b]] = copy [[a]]; + // CHECK: [[a]] = const 5_usize; + // CHECK: [[a]] = copy [[b]]; + // CHECK: [[c:_.*]] = copy [[a]] + // CHECK: id::(move [[c]]) let b = a; a = 5; a = b; From 2d04a63ddec43112eeddbb9985a8d75947a2c497 Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sat, 4 Jan 2025 12:40:03 +0000 Subject: [PATCH 08/20] Add FileCheck to issue_107511.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/issue_107511.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/mir-opt/copy-prop/issue_107511.rs b/tests/mir-opt/copy-prop/issue_107511.rs index 5e8fc8df42e23..eea10b4f54429 100644 --- a/tests/mir-opt/copy-prop/issue_107511.rs +++ b/tests/mir-opt/copy-prop/issue_107511.rs @@ -1,9 +1,11 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY //@ test-mir-pass: CopyProp // EMIT_MIR issue_107511.main.CopyProp.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK-NOT: StorageLive(_16); + // CHECK-NOT: StorageDead(_16); let mut sum = 0; let a = [0, 10, 20, 30]; From d0365d30c2c7f269fa8ecdbae9f95f7fb0a00108 Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sat, 4 Jan 2025 12:40:22 +0000 Subject: [PATCH 09/20] Add FileCheck to move_arg.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/move_arg.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/mir-opt/copy-prop/move_arg.rs b/tests/mir-opt/copy-prop/move_arg.rs index 498340534324b..b7adae3331968 100644 --- a/tests/mir-opt/copy-prop/move_arg.rs +++ b/tests/mir-opt/copy-prop/move_arg.rs @@ -1,10 +1,13 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Test that we do not move multiple times from the same local. //@ test-mir-pass: CopyProp // EMIT_MIR move_arg.f.CopyProp.diff pub fn f(a: T) { + // CHECK-LABEL: fn f( + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug b => [[a]]; + // CHECK: g::(copy [[a]], copy [[a]]) let b = a; g(a, b); } From 334d501f7cdd191fd32eb18b04dabb9d3820a71e Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sat, 4 Jan 2025 12:40:33 +0000 Subject: [PATCH 10/20] Add FileCheck to move_projection.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/move_projection.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/mir-opt/copy-prop/move_projection.rs b/tests/mir-opt/copy-prop/move_projection.rs index 0ac1c4e0ba261..f82ddeec2cb26 100644 --- a/tests/mir-opt/copy-prop/move_projection.rs +++ b/tests/mir-opt/copy-prop/move_projection.rs @@ -1,4 +1,3 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY //@ test-mir-pass: CopyProp @@ -15,6 +14,12 @@ struct Foo(u8); #[custom_mir(dialect = "runtime")] fn f(a: Foo) -> bool { + // CHECK-LABEL: fn f( + // CHECK-SAME: [[a:_.*]]: Foo) + // CHECK: bb0: { + // CHECK-NOT: _2 = copy [[a]]; + // CHECK-NOT: _3 = move (_2.0: u8); + // CHECK: _3 = copy ([[a]].0: u8); mir! { { let b = a; From d3176d532600bf8baa70e000380c6539747d8e55 Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sat, 4 Jan 2025 12:40:41 +0000 Subject: [PATCH 11/20] Add FileCheck to mutate_through_pointer.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/mutate_through_pointer.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/mir-opt/copy-prop/mutate_through_pointer.rs b/tests/mir-opt/copy-prop/mutate_through_pointer.rs index 53cca045248d8..7523da8a292e7 100644 --- a/tests/mir-opt/copy-prop/mutate_through_pointer.rs +++ b/tests/mir-opt/copy-prop/mutate_through_pointer.rs @@ -1,4 +1,3 @@ -// skip-filecheck //@ test-mir-pass: CopyProp // // This attempts to mutate `a` via a pointer derived from `addr_of!(a)`. That is UB @@ -18,6 +17,10 @@ use core::intrinsics::mir::*; #[custom_mir(dialect = "analysis", phase = "post-cleanup")] fn f(c: bool) -> bool { + // CHECK-LABEL: fn f( + // CHECK: _2 = copy _1; + // CHECK-NOT: _3 = &raw const _1; + // CHECK: _3 = &raw const _2; mir! { { let a = c; From ef42830a10293b31180b3b76f1bcc2b56e6a8373 Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sat, 4 Jan 2025 12:40:50 +0000 Subject: [PATCH 12/20] Add FileCheck to non_dominate.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/non_dominate.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/mir-opt/copy-prop/non_dominate.rs b/tests/mir-opt/copy-prop/non_dominate.rs index c01275370ea71..a6db10c461f5e 100644 --- a/tests/mir-opt/copy-prop/non_dominate.rs +++ b/tests/mir-opt/copy-prop/non_dominate.rs @@ -1,4 +1,3 @@ -// skip-filecheck //@ test-mir-pass: CopyProp #![feature(custom_mir, core_intrinsics)] @@ -8,6 +7,11 @@ use core::intrinsics::mir::*; #[custom_mir(dialect = "analysis", phase = "post-cleanup")] fn f(c: bool) -> bool { + // CHECK-LABEL: fn f( + // CHECK: bb2: { + // CHECK: _2 = copy _3; + // CHECK: bb3: { + // CHECK: _0 = copy _2; mir! { let a: bool; let b: bool; From 4627ea17653ef1eb626c71a5e6309765ad1862df Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sat, 4 Jan 2025 12:40:56 +0000 Subject: [PATCH 13/20] Add FileCheck to partial_init.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/partial_init.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/mir-opt/copy-prop/partial_init.rs b/tests/mir-opt/copy-prop/partial_init.rs index 88e94988181d2..0135d7c321b85 100644 --- a/tests/mir-opt/copy-prop/partial_init.rs +++ b/tests/mir-opt/copy-prop/partial_init.rs @@ -1,4 +1,3 @@ -// skip-filecheck //@ test-mir-pass: CopyProp // Verify that we do not ICE on partial initializations. @@ -9,6 +8,9 @@ use core::intrinsics::mir::*; // EMIT_MIR partial_init.main.CopyProp.diff #[custom_mir(dialect = "runtime", phase = "post-cleanup")] pub fn main() { + // CHECK-LABEL: fn main( + // CHECK: let mut [[x:_.*]]: (isize,); + // CHECK: ([[x]].0: isize) = const 1_isize; mir! ( let x: (isize, ); { From 381466c2441d6a8a52c6f53225658531edf59522 Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sat, 4 Jan 2025 12:41:01 +0000 Subject: [PATCH 14/20] Add FileCheck to reborrow.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/reborrow.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/mir-opt/copy-prop/reborrow.rs b/tests/mir-opt/copy-prop/reborrow.rs index 51a1f92cde2fc..8bc81106e9945 100644 --- a/tests/mir-opt/copy-prop/reborrow.rs +++ b/tests/mir-opt/copy-prop/reborrow.rs @@ -1,4 +1,3 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Check that CopyProp considers reborrows as not mutating the pointer. //@ test-mir-pass: CopyProp @@ -8,6 +7,9 @@ fn opaque(_: impl Sized) {} // EMIT_MIR reborrow.remut.CopyProp.diff fn remut(mut x: u8) { + // CHECK-LABEL: fn remut( + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug c => [[a]]; let a = &mut x; let b = &mut *a; //< this cannot mutate a. let c = a; //< so `c` and `a` can be merged. @@ -16,6 +18,9 @@ fn remut(mut x: u8) { // EMIT_MIR reborrow.reraw.CopyProp.diff fn reraw(mut x: u8) { + // CHECK-LABEL: fn reraw( + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug c => [[a]]; let a = &mut x; let b = &raw mut *a; //< this cannot mutate a. let c = a; //< so `c` and `a` can be merged. @@ -24,6 +29,9 @@ fn reraw(mut x: u8) { // EMIT_MIR reborrow.miraw.CopyProp.diff fn miraw(mut x: u8) { + // CHECK-LABEL: fn miraw( + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug c => [[a]]; let a = &raw mut x; let b = unsafe { &raw mut *a }; //< this cannot mutate a. let c = a; //< so `c` and `a` can be merged. @@ -32,6 +40,9 @@ fn miraw(mut x: u8) { // EMIT_MIR reborrow.demiraw.CopyProp.diff fn demiraw(mut x: u8) { + // CHECK-LABEL: fn demiraw( + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug c => [[a]]; let a = &raw mut x; let b = unsafe { &mut *a }; //< this cannot mutate a. let c = a; //< so `c` and `a` can be merged. From 1aeeebc5ceaf8cf43c900f77dfcbae1108746a46 Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Wed, 8 Jan 2025 22:05:34 +0000 Subject: [PATCH 15/20] address review: add CHECKs in calls.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/calls.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/mir-opt/copy-prop/calls.rs b/tests/mir-opt/copy-prop/calls.rs index 595ce83a0a2c1..f19b114523d3a 100644 --- a/tests/mir-opt/copy-prop/calls.rs +++ b/tests/mir-opt/copy-prop/calls.rs @@ -16,6 +16,7 @@ fn nrvo() -> u8 { // CHECK: debug y => _0; // CHECK-NOT: StorageLive(_1); // CHECK-NOT: _1 = dummy(const 5_u8) + // CHECK: _0 = dummy(const 5_u8) // CHECK-NOT: _0 = copy _1; // CHECK-NOT: StorageDead(_1); let y = dummy(5); // this should get NRVO @@ -26,6 +27,8 @@ fn nrvo() -> u8 { #[custom_mir(dialect = "runtime", phase = "initial")] fn multiple_edges(t: bool) -> u8 { // CHECK-LABEL: fn multiple_edges( + // CHECK: bb1: { + // CHECK: _2 = dummy(const 13_u8) // CHECK: bb2: { // CHECK: _0 = copy _2; mir! { From 30a656a9bd80a611305f956695042e68c8da279e Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Wed, 8 Jan 2025 22:09:18 +0000 Subject: [PATCH 16/20] address review: add CHECKs in cycle.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/cycle.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/mir-opt/copy-prop/cycle.rs b/tests/mir-opt/copy-prop/cycle.rs index b0cc2fc1d29a0..9f8312cc8fcd4 100644 --- a/tests/mir-opt/copy-prop/cycle.rs +++ b/tests/mir-opt/copy-prop/cycle.rs @@ -8,15 +8,17 @@ fn val() -> i32 { // EMIT_MIR cycle.main.CopyProp.diff fn main() { // CHECK-LABEL: fn main( - // CHECK: debug z => _2; - // CHECK-NOT: StorageLive(_2); - // CHECK: _2 = copy _1; + // CHECK: debug x => [[x:_.*]]; + // CHECK: debug y => [[y:_.*]]; + // CHECK: debug z => [[y]]; + // CHECK-NOT: StorageLive([[y]]); + // CHECK: [[y]] = copy [[x]]; // CHECK-NOT: StorageLive(_3); - // CHECK-NOT: _3 = copy _2; + // CHECK-NOT: _3 = copy [[y]]; // CHECK-NOT: StorageLive(_4); // CHECK-NOT: _4 = copy _3; // CHECK-NOT: _1 = move _4; - // CHECK: _1 = copy _2; + // CHECK: [[x]] = copy [[y]]; let mut x = val(); let y = x; let z = y; From 0d6fa54c231850af21adb9fe8087af180798e682 Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Wed, 8 Jan 2025 22:11:40 +0000 Subject: [PATCH 17/20] address review: dead_stores_better.rs should use DeadStoreElimination-initial Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/dead_stores_better.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mir-opt/copy-prop/dead_stores_better.rs b/tests/mir-opt/copy-prop/dead_stores_better.rs index 9b5dc85dd316c..4c33fe37d62d2 100644 --- a/tests/mir-opt/copy-prop/dead_stores_better.rs +++ b/tests/mir-opt/copy-prop/dead_stores_better.rs @@ -3,7 +3,7 @@ // that that pass enables this one to do more optimizations. //@ test-mir-pass: CopyProp -//@ compile-flags: -Zmir-enable-passes=+DeadStoreElimination +//@ compile-flags: -Zmir-enable-passes=+DeadStoreElimination-initial fn id(x: T) -> T { x From 430d88865386b007f00f27190960ae41befac686 Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Wed, 8 Jan 2025 22:13:32 +0000 Subject: [PATCH 18/20] address review: add debug info in issue_107511.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/issue_107511.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/mir-opt/copy-prop/issue_107511.rs b/tests/mir-opt/copy-prop/issue_107511.rs index eea10b4f54429..d345d2db2b7d8 100644 --- a/tests/mir-opt/copy-prop/issue_107511.rs +++ b/tests/mir-opt/copy-prop/issue_107511.rs @@ -4,8 +4,9 @@ // EMIT_MIR issue_107511.main.CopyProp.diff fn main() { // CHECK-LABEL: fn main( - // CHECK-NOT: StorageLive(_16); - // CHECK-NOT: StorageDead(_16); + // CHECK: debug i => [[i:_.*]]; + // CHECK-NOT: StorageLive([[i]]); + // CHECK-NOT: StorageDead([[i]]); let mut sum = 0; let a = [0, 10, 20, 30]; From 6eab7c7e63fa6853413fa2ab483ecc75687b624b Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Wed, 8 Jan 2025 22:16:29 +0000 Subject: [PATCH 19/20] address review: add opaques in move_projection.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/move_projection.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/mir-opt/copy-prop/move_projection.rs b/tests/mir-opt/copy-prop/move_projection.rs index f82ddeec2cb26..73473ee749f84 100644 --- a/tests/mir-opt/copy-prop/move_projection.rs +++ b/tests/mir-opt/copy-prop/move_projection.rs @@ -19,7 +19,10 @@ fn f(a: Foo) -> bool { // CHECK: bb0: { // CHECK-NOT: _2 = copy [[a]]; // CHECK-NOT: _3 = move (_2.0: u8); - // CHECK: _3 = copy ([[a]].0: u8); + // CHECK: [[c:_.*]] = copy ([[a]].0: u8); + // CHECK: _0 = opaque::(copy [[a]]) + // CHECK: bb1: { + // CHECK: _0 = opaque::(move [[c]]) mir! { { let b = a; From 7a641377ae492f0cb2dd0be53a397381e7abfb92 Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Wed, 8 Jan 2025 22:26:27 +0000 Subject: [PATCH 20/20] address review: add CHECKs for baz in copy_propagation_arg.rs Signed-off-by: Shunpoco --- tests/mir-opt/copy-prop/copy_propagation_arg.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.rs b/tests/mir-opt/copy-prop/copy_propagation_arg.rs index 08bb40bba0137..6c234c3aac0f3 100644 --- a/tests/mir-opt/copy-prop/copy_propagation_arg.rs +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.rs @@ -32,8 +32,11 @@ fn bar(mut x: u8) { fn baz(mut x: i32) -> i32 { // CHECK-LABEL: fn baz( // CHECK: debug x => [[x:_.*]]; + // CHECK: [[x2:_.*]] = copy [[x]]; + // CHECK: [[x]] = move [[x2]]; // CHECK: _0 = copy [[x]]; - // self-assignment to a function argument should be eliminated + // In the original case for DestProp, the self-assignment to a function argument is eliminated, + // but in CopyProp it is not eliminated. x = x; x }