about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-07-20 15:05:39 +0000
committerbors <bors@rust-lang.org>2023-07-20 15:05:39 +0000
commit06a53ddc0bd3a50f9bcf2f7c373011dc7869f59f (patch)
tree854cfd269af4e934514334956f1f5277dcd75f24 /tests/codegen
parent6b53175b5d8558b69f5f46ce969fe42fb457e01b (diff)
parent254bf6027d83a94e93b5112d558c81a3e050413f (diff)
downloadrust-06a53ddc0bd3a50f9bcf2f7c373011dc7869f59f.tar.gz
rust-06a53ddc0bd3a50f9bcf2f7c373011dc7869f59f.zip
Auto merge of #113758 - cjgillot:move-dse, r=JakobDegen,oli-obk
Turn copy into moves during DSE.

Dead store elimination computes whether removing a direct store to an unborrowed place is allowed.
Where removing a store is allowed, writing `uninit` is too.

This means that we can use this pass to transform `copy` operands into `move` operands. This is only interesting in call terminators, so we only handle those.

Special care is taken for the `use_both(_1, _1)` case:
- moving the second argument is ok, as `_1` is not live after the call;
- moving the first argument is not, as the second argument reads `_1`.

Fixes #75993
Fixes https://github.com/rust-lang/rust/issues/108068

r? `@RalfJung`
cc `@JakobDegen`
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/iter-repeat-n-trivial-drop.rs2
-rw-r--r--tests/codegen/move-operands.rs3
2 files changed, 3 insertions, 2 deletions
diff --git a/tests/codegen/iter-repeat-n-trivial-drop.rs b/tests/codegen/iter-repeat-n-trivial-drop.rs
index 65a0f7e7ffb..68b10934a0d 100644
--- a/tests/codegen/iter-repeat-n-trivial-drop.rs
+++ b/tests/codegen/iter-repeat-n-trivial-drop.rs
@@ -33,7 +33,7 @@ pub fn iter_repeat_n_next(it: &mut std::iter::RepeatN<NotCopy>) -> Option<NotCop
 
     // CHECK: [[EMPTY]]:
     // CHECK-NOT: br
-    // CHECK: phi i16 [ %[[VAL]], %[[NOT_EMPTY]] ], [ undef, %start ]
+    // CHECK: phi i16
     // CHECK-NOT: br
     // CHECK: ret
 
diff --git a/tests/codegen/move-operands.rs b/tests/codegen/move-operands.rs
index 1d8209e8ea5..df4fbe29ffd 100644
--- a/tests/codegen/move-operands.rs
+++ b/tests/codegen/move-operands.rs
@@ -1,4 +1,5 @@
-// compile-flags: -C no-prepopulate-passes -Zmir-enable-passes=+DestinationPropagation,-CopyProp
+// Verify that optimized MIR only copies `a` once.
+// compile-flags: -O -C no-prepopulate-passes
 
 #![crate_type = "lib"]