summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/copy-prop
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /tests/mir-opt/copy-prop
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/mir-opt/copy-prop')
-rw-r--r--tests/mir-opt/copy-prop/borrowed_local.rs1
-rw-r--r--tests/mir-opt/copy-prop/branch.rs1
-rw-r--r--tests/mir-opt/copy-prop/calls.multiple_edges.CopyProp.diff21
-rw-r--r--tests/mir-opt/copy-prop/calls.nrvo.CopyProp.diff24
-rw-r--r--tests/mir-opt/copy-prop/calls.rs44
-rw-r--r--tests/mir-opt/copy-prop/copy_propagation_arg.rs1
-rw-r--r--tests/mir-opt/copy-prop/custom_move_arg.rs1
-rw-r--r--tests/mir-opt/copy-prop/cycle.rs1
-rw-r--r--tests/mir-opt/copy-prop/dead_stores_79191.rs1
-rw-r--r--tests/mir-opt/copy-prop/dead_stores_better.rs1
-rw-r--r--tests/mir-opt/copy-prop/issue_107511.rs1
-rw-r--r--tests/mir-opt/copy-prop/move_arg.rs1
-rw-r--r--tests/mir-opt/copy-prop/move_projection.rs1
-rw-r--r--tests/mir-opt/copy-prop/mutate_through_pointer.rs1
-rw-r--r--tests/mir-opt/copy-prop/non_dominate.rs1
-rw-r--r--tests/mir-opt/copy-prop/partial_init.rs1
-rw-r--r--tests/mir-opt/copy-prop/reborrow.rs1
17 files changed, 103 insertions, 0 deletions
diff --git a/tests/mir-opt/copy-prop/borrowed_local.rs b/tests/mir-opt/copy-prop/borrowed_local.rs
index bf94dc57d..c6b8ad357 100644
--- a/tests/mir-opt/copy-prop/borrowed_local.rs
+++ b/tests/mir-opt/copy-prop/borrowed_local.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: CopyProp
diff --git a/tests/mir-opt/copy-prop/branch.rs b/tests/mir-opt/copy-prop/branch.rs
index c8af1aa7b..278508957 100644
--- a/tests/mir-opt/copy-prop/branch.rs
+++ b/tests/mir-opt/copy-prop/branch.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
//! Tests that we bail out when there are multiple assignments to the same local.
// unit-test: CopyProp
diff --git a/tests/mir-opt/copy-prop/calls.multiple_edges.CopyProp.diff b/tests/mir-opt/copy-prop/calls.multiple_edges.CopyProp.diff
new file mode 100644
index 000000000..4d56a8b25
--- /dev/null
+++ b/tests/mir-opt/copy-prop/calls.multiple_edges.CopyProp.diff
@@ -0,0 +1,21 @@
+- // MIR for `multiple_edges` before CopyProp
++ // MIR for `multiple_edges` after CopyProp
+
+ fn multiple_edges(_1: bool) -> u8 {
+ let mut _0: u8;
+ let mut _2: u8;
+
+ bb0: {
+ switchInt(_1) -> [1: bb1, otherwise: bb2];
+ }
+
+ bb1: {
+ _2 = dummy(const 13_u8) -> [return: bb2, unwind continue];
+ }
+
+ bb2: {
+ _0 = _2;
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/copy-prop/calls.nrvo.CopyProp.diff b/tests/mir-opt/copy-prop/calls.nrvo.CopyProp.diff
new file mode 100644
index 000000000..b5d56909b
--- /dev/null
+++ b/tests/mir-opt/copy-prop/calls.nrvo.CopyProp.diff
@@ -0,0 +1,24 @@
+- // MIR for `nrvo` before CopyProp
++ // MIR for `nrvo` after CopyProp
+
+ fn nrvo() -> u8 {
+ let mut _0: u8;
+ let _1: u8;
+ scope 1 {
+- debug y => _1;
++ debug y => _0;
+ }
+
+ bb0: {
+- StorageLive(_1);
+- _1 = dummy(const 5_u8) -> [return: bb1, unwind continue];
++ _0 = dummy(const 5_u8) -> [return: bb1, unwind continue];
+ }
+
+ bb1: {
+- _0 = _1;
+- StorageDead(_1);
+ return;
+ }
+ }
+
diff --git a/tests/mir-opt/copy-prop/calls.rs b/tests/mir-opt/copy-prop/calls.rs
new file mode 100644
index 000000000..2970f5f0b
--- /dev/null
+++ b/tests/mir-opt/copy-prop/calls.rs
@@ -0,0 +1,44 @@
+// skip-filecheck
+// Check that CopyProp does propagate return values of call terminators.
+// unit-test: CopyProp
+// needs-unwind
+
+#![feature(custom_mir, core_intrinsics)]
+use std::intrinsics::mir::*;
+
+#[inline(never)]
+fn dummy(x: u8) -> u8 {
+ x
+}
+
+// EMIT_MIR calls.nrvo.CopyProp.diff
+fn nrvo() -> u8 {
+ let y = dummy(5); // this should get NRVO
+ y
+}
+
+// EMIT_MIR calls.multiple_edges.CopyProp.diff
+#[custom_mir(dialect = "runtime", phase = "initial")]
+fn multiple_edges(t: bool) -> u8 {
+ mir! {
+ let x: u8;
+ {
+ match t { true => bbt, _ => ret }
+ }
+ bbt = {
+ Call(x = dummy(13), ret)
+ }
+ ret = {
+ // `x` is not assigned on the `bb0 -> ret` edge,
+ // so should not be marked as SSA for merging with `_0`.
+ RET = x;
+ Return()
+ }
+ }
+}
+
+fn main() {
+ // Make sure the function actually gets instantiated.
+ nrvo();
+ multiple_edges(false);
+}
diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.rs b/tests/mir-opt/copy-prop/copy_propagation_arg.rs
index 671860da5..83bbefe09 100644
--- a/tests/mir-opt/copy-prop/copy_propagation_arg.rs
+++ b/tests/mir-opt/copy-prop/copy_propagation_arg.rs
@@ -1,3 +1,4 @@
+// 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)
diff --git a/tests/mir-opt/copy-prop/custom_move_arg.rs b/tests/mir-opt/copy-prop/custom_move_arg.rs
index d1c5ffdff..2077874ee 100644
--- a/tests/mir-opt/copy-prop/custom_move_arg.rs
+++ b/tests/mir-opt/copy-prop/custom_move_arg.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: CopyProp
diff --git a/tests/mir-opt/copy-prop/cycle.rs b/tests/mir-opt/copy-prop/cycle.rs
index 56ec75397..58e049fde 100644
--- a/tests/mir-opt/copy-prop/cycle.rs
+++ b/tests/mir-opt/copy-prop/cycle.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
//! Tests that cyclic assignments don't hang CopyProp, and result in reasonable code.
// unit-test: CopyProp
diff --git a/tests/mir-opt/copy-prop/dead_stores_79191.rs b/tests/mir-opt/copy-prop/dead_stores_79191.rs
index 4260d35b1..81306ab61 100644
--- a/tests/mir-opt/copy-prop/dead_stores_79191.rs
+++ b/tests/mir-opt/copy-prop/dead_stores_79191.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: CopyProp
diff --git a/tests/mir-opt/copy-prop/dead_stores_better.rs b/tests/mir-opt/copy-prop/dead_stores_better.rs
index c5962db6a..7addf6af2 100644
--- a/tests/mir-opt/copy-prop/dead_stores_better.rs
+++ b/tests/mir-opt/copy-prop/dead_stores_better.rs
@@ -1,3 +1,4 @@
+// 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.
diff --git a/tests/mir-opt/copy-prop/issue_107511.rs b/tests/mir-opt/copy-prop/issue_107511.rs
index ce6fcc17b..53fd93662 100644
--- a/tests/mir-opt/copy-prop/issue_107511.rs
+++ b/tests/mir-opt/copy-prop/issue_107511.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: CopyProp
diff --git a/tests/mir-opt/copy-prop/move_arg.rs b/tests/mir-opt/copy-prop/move_arg.rs
index a3a04e57b..fc2932a65 100644
--- a/tests/mir-opt/copy-prop/move_arg.rs
+++ b/tests/mir-opt/copy-prop/move_arg.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// Test that we do not move multiple times from the same local.
// unit-test: CopyProp
diff --git a/tests/mir-opt/copy-prop/move_projection.rs b/tests/mir-opt/copy-prop/move_projection.rs
index f94addb56..8629d535b 100644
--- a/tests/mir-opt/copy-prop/move_projection.rs
+++ b/tests/mir-opt/copy-prop/move_projection.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: CopyProp
diff --git a/tests/mir-opt/copy-prop/mutate_through_pointer.rs b/tests/mir-opt/copy-prop/mutate_through_pointer.rs
index 753787089..e36a10846 100644
--- a/tests/mir-opt/copy-prop/mutate_through_pointer.rs
+++ b/tests/mir-opt/copy-prop/mutate_through_pointer.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// unit-test: CopyProp
//
// This attempts to mutate `a` via a pointer derived from `addr_of!(a)`. That is UB
diff --git a/tests/mir-opt/copy-prop/non_dominate.rs b/tests/mir-opt/copy-prop/non_dominate.rs
index c0ea838e1..c26ac444e 100644
--- a/tests/mir-opt/copy-prop/non_dominate.rs
+++ b/tests/mir-opt/copy-prop/non_dominate.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// unit-test: CopyProp
#![feature(custom_mir, core_intrinsics)]
diff --git a/tests/mir-opt/copy-prop/partial_init.rs b/tests/mir-opt/copy-prop/partial_init.rs
index f5ab9974f..44cc203de 100644
--- a/tests/mir-opt/copy-prop/partial_init.rs
+++ b/tests/mir-opt/copy-prop/partial_init.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// unit-test: CopyProp
// Verify that we do not ICE on partial initializations.
diff --git a/tests/mir-opt/copy-prop/reborrow.rs b/tests/mir-opt/copy-prop/reborrow.rs
index c37ba5e5c..57c4fb8ad 100644
--- a/tests/mir-opt/copy-prop/reborrow.rs
+++ b/tests/mir-opt/copy-prop/reborrow.rs
@@ -1,3 +1,4 @@
+// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// Check that CopyProp considers reborrows as not mutating the pointer.
// unit-test: CopyProp