summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/copy-prop
diff options
context:
space:
mode:
Diffstat (limited to 'tests/mir-opt/copy-prop')
-rw-r--r--tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff4
-rw-r--r--tests/mir-opt/copy-prop/borrowed_local.rs1
-rw-r--r--tests/mir-opt/copy-prop/branch.foo.CopyProp.diff6
-rw-r--r--tests/mir-opt/copy-prop/branch.rs1
-rw-r--r--tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.diff2
-rw-r--r--tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.diff2
-rw-r--r--tests/mir-opt/copy-prop/copy_propagation_arg.rs1
-rw-r--r--tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.diff4
-rw-r--r--tests/mir-opt/copy-prop/custom_move_arg.rs1
-rw-r--r--tests/mir-opt/copy-prop/cycle.main.CopyProp.diff4
-rw-r--r--tests/mir-opt/copy-prop/cycle.rs1
-rw-r--r--tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.mir2
-rw-r--r--tests/mir-opt/copy-prop/dead_stores_79191.rs1
-rw-r--r--tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.mir2
-rw-r--r--tests/mir-opt/copy-prop/dead_stores_better.rs1
-rw-r--r--tests/mir-opt/copy-prop/issue_107511.main.CopyProp.diff6
-rw-r--r--tests/mir-opt/copy-prop/issue_107511.rs1
-rw-r--r--tests/mir-opt/copy-prop/move_arg.f.CopyProp.diff2
-rw-r--r--tests/mir-opt/copy-prop/move_arg.rs1
-rw-r--r--tests/mir-opt/copy-prop/move_projection.f.CopyProp.diff4
-rw-r--r--tests/mir-opt/copy-prop/move_projection.rs1
-rw-r--r--tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.diff56
-rw-r--r--tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.diff52
-rw-r--r--tests/mir-opt/copy-prop/reborrow.remut.CopyProp.diff50
-rw-r--r--tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.diff50
-rw-r--r--tests/mir-opt/copy-prop/reborrow.rs47
26 files changed, 284 insertions, 19 deletions
diff --git a/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff b/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff
index b183865a9..2a0bff57d 100644
--- a/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff
+++ b/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff
@@ -15,7 +15,7 @@
_4 = &_3; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
_0 = cmp_ref(_2, _4) -> bb1; // scope 0 at $DIR/borrowed_local.rs:+8:13: +8:45
// mir::Constant
- // + span: $DIR/borrowed_local.rs:23:29: 23:36
+ // + span: $DIR/borrowed_local.rs:24:29: 24:36
// + literal: Const { ty: for<'a, 'b> fn(&'a u8, &'b u8) -> bool {cmp_ref}, val: Value(<ZST>) }
}
@@ -23,7 +23,7 @@
- _0 = opaque::<u8>(_3) -> bb2; // scope 0 at $DIR/borrowed_local.rs:+12:13: +12:38
+ _0 = opaque::<u8>(_1) -> bb2; // scope 0 at $DIR/borrowed_local.rs:+12:13: +12:38
// mir::Constant
- // + span: $DIR/borrowed_local.rs:27:28: 27:34
+ // + span: $DIR/borrowed_local.rs:28:28: 28:34
// + literal: Const { ty: fn(u8) -> bool {opaque::<u8>}, val: Value(<ZST>) }
}
diff --git a/tests/mir-opt/copy-prop/borrowed_local.rs b/tests/mir-opt/copy-prop/borrowed_local.rs
index c4b980e2b..9186da5af 100644
--- a/tests/mir-opt/copy-prop/borrowed_local.rs
+++ b/tests/mir-opt/copy-prop/borrowed_local.rs
@@ -1,3 +1,4 @@
+// ignore-wasm32 compiled with panic=abort by default
// unit-test: CopyProp
#![feature(custom_mir, core_intrinsics)]
diff --git a/tests/mir-opt/copy-prop/branch.foo.CopyProp.diff b/tests/mir-opt/copy-prop/branch.foo.CopyProp.diff
index 8b116532d..b78c19d78 100644
--- a/tests/mir-opt/copy-prop/branch.foo.CopyProp.diff
+++ b/tests/mir-opt/copy-prop/branch.foo.CopyProp.diff
@@ -18,7 +18,7 @@
StorageLive(_1); // scope 0 at $DIR/branch.rs:+1:9: +1:10
_1 = val() -> bb1; // scope 0 at $DIR/branch.rs:+1:13: +1:18
// mir::Constant
- // + span: $DIR/branch.rs:13:13: 13:16
+ // + span: $DIR/branch.rs:14:13: 14:16
// + literal: Const { ty: fn() -> i32 {val}, val: Value(<ZST>) }
}
@@ -27,7 +27,7 @@
StorageLive(_3); // scope 1 at $DIR/branch.rs:+3:16: +3:22
_3 = cond() -> bb2; // scope 1 at $DIR/branch.rs:+3:16: +3:22
// mir::Constant
- // + span: $DIR/branch.rs:15:16: 15:20
+ // + span: $DIR/branch.rs:16:16: 16:20
// + literal: Const { ty: fn() -> bool {cond}, val: Value(<ZST>) }
}
@@ -44,7 +44,7 @@
StorageLive(_4); // scope 1 at $DIR/branch.rs:+6:9: +6:14
_4 = val() -> bb5; // scope 1 at $DIR/branch.rs:+6:9: +6:14
// mir::Constant
- // + span: $DIR/branch.rs:18:9: 18:12
+ // + span: $DIR/branch.rs:19:9: 19:12
// + literal: Const { ty: fn() -> i32 {val}, val: Value(<ZST>) }
}
diff --git a/tests/mir-opt/copy-prop/branch.rs b/tests/mir-opt/copy-prop/branch.rs
index 50b1e00fa..0a2e16946 100644
--- a/tests/mir-opt/copy-prop/branch.rs
+++ b/tests/mir-opt/copy-prop/branch.rs
@@ -1,3 +1,4 @@
+// ignore-wasm32 compiled with panic=abort by default
//! Tests that we bail out when there are multiple assignments to the same local.
// unit-test: CopyProp
fn val() -> i32 {
diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.diff
index ac4e9a2bf..24bca3220 100644
--- a/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.diff
+++ b/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.diff
@@ -13,7 +13,7 @@
_3 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+1:11: +1:12
_2 = dummy(move _3) -> bb1; // scope 0 at $DIR/copy_propagation_arg.rs:+1:5: +1:13
// mir::Constant
- // + span: $DIR/copy_propagation_arg.rs:16:5: 16:10
+ // + span: $DIR/copy_propagation_arg.rs:17:5: 17:10
// + literal: Const { ty: fn(u8) -> u8 {dummy}, val: Value(<ZST>) }
}
diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.diff
index 0a3e985e7..87708f340 100644
--- a/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.diff
+++ b/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.diff
@@ -13,7 +13,7 @@
_3 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+2:15: +2:16
_2 = dummy(move _3) -> bb1; // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:17
// mir::Constant
- // + span: $DIR/copy_propagation_arg.rs:11:9: 11:14
+ // + span: $DIR/copy_propagation_arg.rs:12:9: 12:14
// + literal: Const { ty: fn(u8) -> u8 {dummy}, val: Value(<ZST>) }
}
diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.rs b/tests/mir-opt/copy-prop/copy_propagation_arg.rs
index cc98985f1..1b65dcb01 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 @@
+// ignore-wasm32 compiled with panic=abort by default
// Check that CopyProp does not propagate an assignment to a function argument
// (doing so can break usages of the original argument value)
// unit-test: CopyProp
diff --git a/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.diff b/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.diff
index 6ca73ffdd..160f47bdd 100644
--- a/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.diff
+++ b/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.diff
@@ -11,7 +11,7 @@
- _0 = opaque::<NotCopy>(move _1) -> bb1; // scope 0 at $DIR/custom_move_arg.rs:+3:9: +3:41
+ _0 = opaque::<NotCopy>(_1) -> bb1; // scope 0 at $DIR/custom_move_arg.rs:+3:9: +3:41
// mir::Constant
- // + span: $DIR/custom_move_arg.rs:15:24: 15:30
+ // + span: $DIR/custom_move_arg.rs:16:24: 16:30
// + literal: Const { ty: fn(NotCopy) {opaque::<NotCopy>}, val: Value(<ZST>) }
}
@@ -20,7 +20,7 @@
- _0 = opaque::<NotCopy>(_3) -> bb2; // scope 0 at $DIR/custom_move_arg.rs:+7:9: +7:35
+ _0 = opaque::<NotCopy>(_1) -> bb2; // scope 0 at $DIR/custom_move_arg.rs:+7:9: +7:35
// mir::Constant
- // + span: $DIR/custom_move_arg.rs:19:24: 19:30
+ // + span: $DIR/custom_move_arg.rs:20:24: 20:30
// + literal: Const { ty: fn(NotCopy) {opaque::<NotCopy>}, val: Value(<ZST>) }
}
diff --git a/tests/mir-opt/copy-prop/custom_move_arg.rs b/tests/mir-opt/copy-prop/custom_move_arg.rs
index 4a591146e..29c368df8 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 @@
+// ignore-wasm32 compiled with panic=abort by default
// unit-test: CopyProp
#![feature(custom_mir, core_intrinsics)]
diff --git a/tests/mir-opt/copy-prop/cycle.main.CopyProp.diff b/tests/mir-opt/copy-prop/cycle.main.CopyProp.diff
index 3e61869e8..23d92ed1a 100644
--- a/tests/mir-opt/copy-prop/cycle.main.CopyProp.diff
+++ b/tests/mir-opt/copy-prop/cycle.main.CopyProp.diff
@@ -24,7 +24,7 @@
StorageLive(_1); // scope 0 at $DIR/cycle.rs:+1:9: +1:14
_1 = val() -> bb1; // scope 0 at $DIR/cycle.rs:+1:17: +1:22
// mir::Constant
- // + span: $DIR/cycle.rs:9:17: 9:20
+ // + span: $DIR/cycle.rs:10:17: 10:20
// + literal: Const { ty: fn() -> i32 {val}, val: Value(<ZST>) }
}
@@ -43,7 +43,7 @@
_6 = _1; // scope 3 at $DIR/cycle.rs:+6:10: +6:11
_5 = std::mem::drop::<i32>(move _6) -> bb2; // scope 3 at $DIR/cycle.rs:+6:5: +6:12
// mir::Constant
- // + span: $DIR/cycle.rs:14:5: 14:9
+ // + span: $DIR/cycle.rs:15:5: 15:9
// + literal: Const { ty: fn(i32) {std::mem::drop::<i32>}, val: Value(<ZST>) }
}
diff --git a/tests/mir-opt/copy-prop/cycle.rs b/tests/mir-opt/copy-prop/cycle.rs
index b74c39726..da70f6bec 100644
--- a/tests/mir-opt/copy-prop/cycle.rs
+++ b/tests/mir-opt/copy-prop/cycle.rs
@@ -1,3 +1,4 @@
+// ignore-wasm32 compiled with panic=abort by default
//! Tests that cyclic assignments don't hang CopyProp, and result in reasonable code.
// unit-test: CopyProp
fn val() -> i32 {
diff --git a/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.mir b/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.mir
index d48b04e2d..c56418d88 100644
--- a/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.mir
+++ b/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.mir
@@ -18,7 +18,7 @@ fn f(_1: usize) -> usize {
_4 = _1; // scope 1 at $DIR/dead_stores_79191.rs:+4:8: +4:9
_0 = id::<usize>(move _4) -> bb1; // scope 1 at $DIR/dead_stores_79191.rs:+4:5: +4:10
// mir::Constant
- // + span: $DIR/dead_stores_79191.rs:12:5: 12:7
+ // + span: $DIR/dead_stores_79191.rs:13:5: 13:7
// + literal: Const { ty: fn(usize) -> usize {id::<usize>}, val: Value(<ZST>) }
}
diff --git a/tests/mir-opt/copy-prop/dead_stores_79191.rs b/tests/mir-opt/copy-prop/dead_stores_79191.rs
index e3493b8b7..84453c55e 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 @@
+// ignore-wasm32 compiled with panic=abort by default
// unit-test: CopyProp
fn id<T>(x: T) -> T {
diff --git a/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.mir b/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.mir
index 727791f50..f35542173 100644
--- a/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.mir
+++ b/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.mir
@@ -18,7 +18,7 @@ fn f(_1: usize) -> usize {
_4 = _1; // scope 1 at $DIR/dead_stores_better.rs:+4:8: +4:9
_0 = id::<usize>(move _4) -> bb1; // scope 1 at $DIR/dead_stores_better.rs:+4:5: +4:10
// mir::Constant
- // + span: $DIR/dead_stores_better.rs:16:5: 16:7
+ // + span: $DIR/dead_stores_better.rs:17:5: 17:7
// + literal: Const { ty: fn(usize) -> usize {id::<usize>}, val: Value(<ZST>) }
}
diff --git a/tests/mir-opt/copy-prop/dead_stores_better.rs b/tests/mir-opt/copy-prop/dead_stores_better.rs
index 8465b3c98..87b916fd3 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 @@
+// ignore-wasm32 compiled with panic=abort by default
// 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.main.CopyProp.diff b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.diff
index 97d0a01e0..e09ccb831 100644
--- a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.diff
+++ b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.diff
@@ -51,7 +51,7 @@
StorageDead(_7); // scope 2 at $DIR/issue_107511.rs:+6:17: +6:18
_5 = core::slice::<impl [i32]>::len(move _6) -> bb1; // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24
// mir::Constant
- // + span: $DIR/issue_107511.rs:10:19: 10:22
+ // + span: $DIR/issue_107511.rs:11:19: 11:22
// + literal: Const { ty: for<'a> fn(&'a [i32]) -> usize {core::slice::<impl [i32]>::len}, val: Value(<ZST>) }
}
@@ -61,7 +61,7 @@
StorageDead(_5); // scope 2 at $DIR/issue_107511.rs:+6:23: +6:24
_3 = <std::ops::Range<usize> as IntoIterator>::into_iter(move _4) -> bb2; // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24
// mir::Constant
- // + span: $DIR/issue_107511.rs:10:14: 10:24
+ // + span: $DIR/issue_107511.rs:11:14: 11:24
// + literal: Const { ty: fn(std::ops::Range<usize>) -> <std::ops::Range<usize> as IntoIterator>::IntoIter {<std::ops::Range<usize> as IntoIterator>::into_iter}, val: Value(<ZST>) }
}
@@ -81,7 +81,7 @@
_12 = &mut (*_13); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24
_11 = <std::ops::Range<usize> as Iterator>::next(move _12) -> bb4; // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24
// mir::Constant
- // + span: $DIR/issue_107511.rs:10:14: 10:24
+ // + span: $DIR/issue_107511.rs:11:14: 11:24
// + literal: Const { ty: for<'a> fn(&'a mut std::ops::Range<usize>) -> Option<<std::ops::Range<usize> as Iterator>::Item> {<std::ops::Range<usize> as Iterator>::next}, val: Value(<ZST>) }
}
diff --git a/tests/mir-opt/copy-prop/issue_107511.rs b/tests/mir-opt/copy-prop/issue_107511.rs
index d593f2872..2b00ff155 100644
--- a/tests/mir-opt/copy-prop/issue_107511.rs
+++ b/tests/mir-opt/copy-prop/issue_107511.rs
@@ -1,3 +1,4 @@
+// ignore-wasm32 compiled with panic=abort by default
// unit-test: CopyProp
// EMIT_MIR issue_107511.main.CopyProp.diff
diff --git a/tests/mir-opt/copy-prop/move_arg.f.CopyProp.diff b/tests/mir-opt/copy-prop/move_arg.f.CopyProp.diff
index d76bf1cfe..650bd66a7 100644
--- a/tests/mir-opt/copy-prop/move_arg.f.CopyProp.diff
+++ b/tests/mir-opt/copy-prop/move_arg.f.CopyProp.diff
@@ -24,7 +24,7 @@
- _3 = g::<T>(move _4, move _5) -> bb1; // scope 1 at $DIR/move_arg.rs:+2:5: +2:12
+ _3 = g::<T>(_1, _1) -> bb1; // scope 1 at $DIR/move_arg.rs:+2:5: +2:12
// mir::Constant
- // + span: $DIR/move_arg.rs:7:5: 7:6
+ // + span: $DIR/move_arg.rs:8:5: 8:6
// + literal: Const { ty: fn(T, T) {g::<T>}, val: Value(<ZST>) }
}
diff --git a/tests/mir-opt/copy-prop/move_arg.rs b/tests/mir-opt/copy-prop/move_arg.rs
index 40ae1d8f4..f88d9a9e7 100644
--- a/tests/mir-opt/copy-prop/move_arg.rs
+++ b/tests/mir-opt/copy-prop/move_arg.rs
@@ -1,3 +1,4 @@
+// ignore-wasm32 compiled with panic=abort by default
// 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.f.CopyProp.diff b/tests/mir-opt/copy-prop/move_projection.f.CopyProp.diff
index 02308beb8..beb85d68a 100644
--- a/tests/mir-opt/copy-prop/move_projection.f.CopyProp.diff
+++ b/tests/mir-opt/copy-prop/move_projection.f.CopyProp.diff
@@ -13,14 +13,14 @@
+ _3 = (_1.0: u8); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ _0 = opaque::<Foo>(_1) -> bb1; // scope 0 at $DIR/move_projection.rs:+6:13: +6:44
// mir::Constant
- // + span: $DIR/move_projection.rs:19:28: 19:34
+ // + span: $DIR/move_projection.rs:20:28: 20:34
// + literal: Const { ty: fn(Foo) -> bool {opaque::<Foo>}, val: Value(<ZST>) }
}
bb1: {
_0 = opaque::<u8>(move _3) -> bb2; // scope 0 at $DIR/move_projection.rs:+9:13: +9:44
// mir::Constant
- // + span: $DIR/move_projection.rs:22:28: 22:34
+ // + span: $DIR/move_projection.rs:23:28: 23:34
// + literal: Const { ty: fn(u8) -> bool {opaque::<u8>}, val: Value(<ZST>) }
}
diff --git a/tests/mir-opt/copy-prop/move_projection.rs b/tests/mir-opt/copy-prop/move_projection.rs
index 2a1bbae99..c158c69e0 100644
--- a/tests/mir-opt/copy-prop/move_projection.rs
+++ b/tests/mir-opt/copy-prop/move_projection.rs
@@ -1,3 +1,4 @@
+// ignore-wasm32 compiled with panic=abort by default
// unit-test: CopyProp
#![feature(custom_mir, core_intrinsics)]
diff --git a/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.diff b/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.diff
new file mode 100644
index 000000000..b4a248245
--- /dev/null
+++ b/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.diff
@@ -0,0 +1,56 @@
+- // MIR for `demiraw` before CopyProp
++ // MIR for `demiraw` after CopyProp
+
+ fn demiraw(_1: u8) -> () {
+ debug x => _1; // in scope 0 at $DIR/reborrow.rs:+0:12: +0:17
+ let mut _0: (); // return place in scope 0 at $DIR/reborrow.rs:+0:23: +0:23
+ let _2: *mut u8; // in scope 0 at $DIR/reborrow.rs:+1:9: +1:10
+ let mut _4: &mut u8; // in scope 0 at $DIR/reborrow.rs:+2:22: +2:29
+ let _6: (); // in scope 0 at $DIR/reborrow.rs:+4:5: +4:14
+ let mut _7: *mut u8; // in scope 0 at $DIR/reborrow.rs:+4:12: +4:13
+ scope 1 {
+ debug a => _2; // in scope 1 at $DIR/reborrow.rs:+1:9: +1:10
+ let _3: &mut u8; // in scope 1 at $DIR/reborrow.rs:+2:9: +2:10
+ scope 2 {
+ debug b => _3; // in scope 2 at $DIR/reborrow.rs:+2:9: +2:10
+ let _5: *mut u8; // in scope 2 at $DIR/reborrow.rs:+3:9: +3:10
+ scope 4 {
+- debug c => _5; // in scope 4 at $DIR/reborrow.rs:+3:9: +3:10
++ debug c => _2; // in scope 4 at $DIR/reborrow.rs:+3:9: +3:10
+ }
+ }
+ scope 3 {
+ }
+ }
+
+ bb0: {
+- StorageLive(_2); // scope 0 at $DIR/reborrow.rs:+1:9: +1:10
+ _2 = &raw mut _1; // scope 0 at $DIR/reborrow.rs:+1:13: +1:23
+ StorageLive(_3); // scope 1 at $DIR/reborrow.rs:+2:9: +2:10
+ StorageLive(_4); // scope 1 at $DIR/reborrow.rs:+2:22: +2:29
+ _4 = &mut (*_2); // scope 3 at $DIR/reborrow.rs:+2:22: +2:29
+ _3 = &mut (*_4); // scope 1 at $DIR/reborrow.rs:+2:22: +2:29
+ StorageDead(_4); // scope 1 at $DIR/reborrow.rs:+2:31: +2:32
+- StorageLive(_5); // scope 2 at $DIR/reborrow.rs:+3:9: +3:10
+- _5 = _2; // scope 2 at $DIR/reborrow.rs:+3:13: +3:14
+ StorageLive(_6); // scope 4 at $DIR/reborrow.rs:+4:5: +4:14
+- StorageLive(_7); // scope 4 at $DIR/reborrow.rs:+4:12: +4:13
+- _7 = _5; // scope 4 at $DIR/reborrow.rs:+4:12: +4:13
+- _6 = opaque::<*mut u8>(move _7) -> bb1; // scope 4 at $DIR/reborrow.rs:+4:5: +4:14
++ _6 = opaque::<*mut u8>(_2) -> bb1; // scope 4 at $DIR/reborrow.rs:+4:5: +4:14
+ // mir::Constant
+ // + span: $DIR/reborrow.rs:39:5: 39:11
+ // + literal: Const { ty: fn(*mut u8) {opaque::<*mut u8>}, val: Value(<ZST>) }
+ }
+
+ bb1: {
+- StorageDead(_7); // scope 4 at $DIR/reborrow.rs:+4:13: +4:14
+ StorageDead(_6); // scope 4 at $DIR/reborrow.rs:+4:14: +4:15
+ _0 = const (); // scope 0 at $DIR/reborrow.rs:+0:23: +5:2
+- StorageDead(_5); // scope 2 at $DIR/reborrow.rs:+5:1: +5:2
+ StorageDead(_3); // scope 1 at $DIR/reborrow.rs:+5:1: +5:2
+- StorageDead(_2); // scope 0 at $DIR/reborrow.rs:+5:1: +5:2
+ return; // scope 0 at $DIR/reborrow.rs:+5:2: +5:2
+ }
+ }
+
diff --git a/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.diff b/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.diff
new file mode 100644
index 000000000..a6a6c05b2
--- /dev/null
+++ b/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.diff
@@ -0,0 +1,52 @@
+- // MIR for `miraw` before CopyProp
++ // MIR for `miraw` after CopyProp
+
+ fn miraw(_1: u8) -> () {
+ debug x => _1; // in scope 0 at $DIR/reborrow.rs:+0:10: +0:15
+ let mut _0: (); // return place in scope 0 at $DIR/reborrow.rs:+0:21: +0:21
+ let _2: *mut u8; // in scope 0 at $DIR/reborrow.rs:+1:9: +1:10
+ let _5: (); // in scope 0 at $DIR/reborrow.rs:+4:5: +4:14
+ let mut _6: *mut u8; // in scope 0 at $DIR/reborrow.rs:+4:12: +4:13
+ scope 1 {
+ debug a => _2; // in scope 1 at $DIR/reborrow.rs:+1:9: +1:10
+ let _3: *mut u8; // in scope 1 at $DIR/reborrow.rs:+2:9: +2:10
+ scope 2 {
+ debug b => _3; // in scope 2 at $DIR/reborrow.rs:+2:9: +2:10
+ let _4: *mut u8; // in scope 2 at $DIR/reborrow.rs:+3:9: +3:10
+ scope 4 {
+- debug c => _4; // in scope 4 at $DIR/reborrow.rs:+3:9: +3:10
++ debug c => _2; // in scope 4 at $DIR/reborrow.rs:+3:9: +3:10
+ }
+ }
+ scope 3 {
+ }
+ }
+
+ bb0: {
+- StorageLive(_2); // scope 0 at $DIR/reborrow.rs:+1:9: +1:10
+ _2 = &raw mut _1; // scope 0 at $DIR/reborrow.rs:+1:13: +1:23
+ StorageLive(_3); // scope 1 at $DIR/reborrow.rs:+2:9: +2:10
+ _3 = &raw mut (*_2); // scope 3 at $DIR/reborrow.rs:+2:22: +2:33
+- StorageLive(_4); // scope 2 at $DIR/reborrow.rs:+3:9: +3:10
+- _4 = _2; // scope 2 at $DIR/reborrow.rs:+3:13: +3:14
+ StorageLive(_5); // scope 4 at $DIR/reborrow.rs:+4:5: +4:14
+- StorageLive(_6); // scope 4 at $DIR/reborrow.rs:+4:12: +4:13
+- _6 = _4; // scope 4 at $DIR/reborrow.rs:+4:12: +4:13
+- _5 = opaque::<*mut u8>(move _6) -> bb1; // scope 4 at $DIR/reborrow.rs:+4:5: +4:14
++ _5 = opaque::<*mut u8>(_2) -> bb1; // scope 4 at $DIR/reborrow.rs:+4:5: +4:14
+ // mir::Constant
+ // + span: $DIR/reborrow.rs:31:5: 31:11
+ // + literal: Const { ty: fn(*mut u8) {opaque::<*mut u8>}, val: Value(<ZST>) }
+ }
+
+ bb1: {
+- StorageDead(_6); // scope 4 at $DIR/reborrow.rs:+4:13: +4:14
+ StorageDead(_5); // scope 4 at $DIR/reborrow.rs:+4:14: +4:15
+ _0 = const (); // scope 0 at $DIR/reborrow.rs:+0:21: +5:2
+- StorageDead(_4); // scope 2 at $DIR/reborrow.rs:+5:1: +5:2
+ StorageDead(_3); // scope 1 at $DIR/reborrow.rs:+5:1: +5:2
+- StorageDead(_2); // scope 0 at $DIR/reborrow.rs:+5:1: +5:2
+ return; // scope 0 at $DIR/reborrow.rs:+5:2: +5:2
+ }
+ }
+
diff --git a/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.diff b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.diff
new file mode 100644
index 000000000..f3d26cc6e
--- /dev/null
+++ b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.diff
@@ -0,0 +1,50 @@
+- // MIR for `remut` before CopyProp
++ // MIR for `remut` after CopyProp
+
+ fn remut(_1: u8) -> () {
+ debug x => _1; // in scope 0 at $DIR/reborrow.rs:+0:10: +0:15
+ let mut _0: (); // return place in scope 0 at $DIR/reborrow.rs:+0:21: +0:21
+ let _2: &mut u8; // in scope 0 at $DIR/reborrow.rs:+1:9: +1:10
+ let _5: (); // in scope 0 at $DIR/reborrow.rs:+4:5: +4:14
+ let mut _6: &mut u8; // in scope 0 at $DIR/reborrow.rs:+4:12: +4:13
+ scope 1 {
+ debug a => _2; // in scope 1 at $DIR/reborrow.rs:+1:9: +1:10
+ let _3: &mut u8; // in scope 1 at $DIR/reborrow.rs:+2:9: +2:10
+ scope 2 {
+ debug b => _3; // in scope 2 at $DIR/reborrow.rs:+2:9: +2:10
+ let _4: &mut u8; // in scope 2 at $DIR/reborrow.rs:+3:9: +3:10
+ scope 3 {
+- debug c => _4; // in scope 3 at $DIR/reborrow.rs:+3:9: +3:10
++ debug c => _2; // in scope 3 at $DIR/reborrow.rs:+3:9: +3:10
+ }
+ }
+ }
+
+ bb0: {
+- StorageLive(_2); // scope 0 at $DIR/reborrow.rs:+1:9: +1:10
+ _2 = &mut _1; // scope 0 at $DIR/reborrow.rs:+1:13: +1:19
+ StorageLive(_3); // scope 1 at $DIR/reborrow.rs:+2:9: +2:10
+ _3 = &mut (*_2); // scope 1 at $DIR/reborrow.rs:+2:13: +2:20
+- StorageLive(_4); // scope 2 at $DIR/reborrow.rs:+3:9: +3:10
+- _4 = move _2; // scope 2 at $DIR/reborrow.rs:+3:13: +3:14
+ StorageLive(_5); // scope 3 at $DIR/reborrow.rs:+4:5: +4:14
+- StorageLive(_6); // scope 3 at $DIR/reborrow.rs:+4:12: +4:13
+- _6 = move _4; // scope 3 at $DIR/reborrow.rs:+4:12: +4:13
+- _5 = opaque::<&mut u8>(move _6) -> bb1; // scope 3 at $DIR/reborrow.rs:+4:5: +4:14
++ _5 = opaque::<&mut u8>(move _2) -> bb1; // scope 3 at $DIR/reborrow.rs:+4:5: +4:14
+ // mir::Constant
+ // + span: $DIR/reborrow.rs:15:5: 15:11
+ // + literal: Const { ty: fn(&mut u8) {opaque::<&mut u8>}, val: Value(<ZST>) }
+ }
+
+ bb1: {
+- StorageDead(_6); // scope 3 at $DIR/reborrow.rs:+4:13: +4:14
+ StorageDead(_5); // scope 3 at $DIR/reborrow.rs:+4:14: +4:15
+ _0 = const (); // scope 0 at $DIR/reborrow.rs:+0:21: +5:2
+- StorageDead(_4); // scope 2 at $DIR/reborrow.rs:+5:1: +5:2
+ StorageDead(_3); // scope 1 at $DIR/reborrow.rs:+5:1: +5:2
+- StorageDead(_2); // scope 0 at $DIR/reborrow.rs:+5:1: +5:2
+ return; // scope 0 at $DIR/reborrow.rs:+5:2: +5:2
+ }
+ }
+
diff --git a/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.diff b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.diff
new file mode 100644
index 000000000..63e42b4dc
--- /dev/null
+++ b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.diff
@@ -0,0 +1,50 @@
+- // MIR for `reraw` before CopyProp
++ // MIR for `reraw` after CopyProp
+
+ fn reraw(_1: u8) -> () {
+ debug x => _1; // in scope 0 at $DIR/reborrow.rs:+0:10: +0:15
+ let mut _0: (); // return place in scope 0 at $DIR/reborrow.rs:+0:21: +0:21
+ let _2: &mut u8; // in scope 0 at $DIR/reborrow.rs:+1:9: +1:10
+ let _5: (); // in scope 0 at $DIR/reborrow.rs:+4:5: +4:14
+ let mut _6: &mut u8; // in scope 0 at $DIR/reborrow.rs:+4:12: +4:13
+ scope 1 {
+ debug a => _2; // in scope 1 at $DIR/reborrow.rs:+1:9: +1:10
+ let _3: *mut u8; // in scope 1 at $DIR/reborrow.rs:+2:9: +2:10
+ scope 2 {
+ debug b => _3; // in scope 2 at $DIR/reborrow.rs:+2:9: +2:10
+ let _4: &mut u8; // in scope 2 at $DIR/reborrow.rs:+3:9: +3:10
+ scope 3 {
+- debug c => _4; // in scope 3 at $DIR/reborrow.rs:+3:9: +3:10
++ debug c => _2; // in scope 3 at $DIR/reborrow.rs:+3:9: +3:10
+ }
+ }
+ }
+
+ bb0: {
+- StorageLive(_2); // scope 0 at $DIR/reborrow.rs:+1:9: +1:10
+ _2 = &mut _1; // scope 0 at $DIR/reborrow.rs:+1:13: +1:19
+ StorageLive(_3); // scope 1 at $DIR/reborrow.rs:+2:9: +2:10
+ _3 = &raw mut (*_2); // scope 1 at $DIR/reborrow.rs:+2:13: +2:24
+- StorageLive(_4); // scope 2 at $DIR/reborrow.rs:+3:9: +3:10
+- _4 = move _2; // scope 2 at $DIR/reborrow.rs:+3:13: +3:14
+ StorageLive(_5); // scope 3 at $DIR/reborrow.rs:+4:5: +4:14
+- StorageLive(_6); // scope 3 at $DIR/reborrow.rs:+4:12: +4:13
+- _6 = move _4; // scope 3 at $DIR/reborrow.rs:+4:12: +4:13
+- _5 = opaque::<&mut u8>(move _6) -> bb1; // scope 3 at $DIR/reborrow.rs:+4:5: +4:14
++ _5 = opaque::<&mut u8>(move _2) -> bb1; // scope 3 at $DIR/reborrow.rs:+4:5: +4:14
+ // mir::Constant
+ // + span: $DIR/reborrow.rs:23:5: 23:11
+ // + literal: Const { ty: fn(&mut u8) {opaque::<&mut u8>}, val: Value(<ZST>) }
+ }
+
+ bb1: {
+- StorageDead(_6); // scope 3 at $DIR/reborrow.rs:+4:13: +4:14
+ StorageDead(_5); // scope 3 at $DIR/reborrow.rs:+4:14: +4:15
+ _0 = const (); // scope 0 at $DIR/reborrow.rs:+0:21: +5:2
+- StorageDead(_4); // scope 2 at $DIR/reborrow.rs:+5:1: +5:2
+ StorageDead(_3); // scope 1 at $DIR/reborrow.rs:+5:1: +5:2
+- StorageDead(_2); // scope 0 at $DIR/reborrow.rs:+5:1: +5:2
+ return; // scope 0 at $DIR/reborrow.rs:+5:2: +5:2
+ }
+ }
+
diff --git a/tests/mir-opt/copy-prop/reborrow.rs b/tests/mir-opt/copy-prop/reborrow.rs
new file mode 100644
index 000000000..91b77966b
--- /dev/null
+++ b/tests/mir-opt/copy-prop/reborrow.rs
@@ -0,0 +1,47 @@
+// ignore-wasm32 compiled with panic=abort by default
+// Check that CopyProp considers reborrows as not mutating the pointer.
+// unit-test: CopyProp
+
+#![feature(raw_ref_op)]
+
+#[inline(never)]
+fn opaque(_: impl Sized) {}
+
+// EMIT_MIR reborrow.remut.CopyProp.diff
+fn remut(mut x: u8) {
+ let a = &mut x;
+ let b = &mut *a; //< this cannot mutate a.
+ let c = a; //< so `c` and `a` can be merged.
+ opaque(c);
+}
+
+// EMIT_MIR reborrow.reraw.CopyProp.diff
+fn reraw(mut x: u8) {
+ let a = &mut x;
+ let b = &raw mut *a; //< this cannot mutate a.
+ let c = a; //< so `c` and `a` can be merged.
+ opaque(c);
+}
+
+// EMIT_MIR reborrow.miraw.CopyProp.diff
+fn miraw(mut x: u8) {
+ 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.
+ opaque(c);
+}
+
+// EMIT_MIR reborrow.demiraw.CopyProp.diff
+fn demiraw(mut x: u8) {
+ let a = &raw mut x;
+ let b = unsafe { &mut *a }; //< this cannot mutate a.
+ let c = a; //< so `c` and `a` can be merged.
+ opaque(c);
+}
+
+fn main() {
+ remut(0);
+ reraw(0);
+ miraw(0);
+ demiraw(0);
+}