about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-12-03 17:43:48 -0500
committerGitHub <noreply@github.com>2017-12-03 17:43:48 -0500
commit94dbbacd45702d32c67c0d3be8d4874eadf300c8 (patch)
treee038092ff6aa90fae8b840d0b4976a3afe3e62ce /src/test
parent7c4f74d16e80a584a648425b9dec1b413d0584cf (diff)
parent17d6631c02a297b187d75817b4cfe4d2b3c6c9de (diff)
Rollup merge of #46462 - sinkuu:copyprop_reg2, r=arielb1
Fix CopyPropagation regression (2)

Remaining part of MIR copyprop regression by (I think) #45380, which I missed in #45753.

```rust
fn foo(mut x: i32) -> i32 {
    let y = x;
    x = 123; // `x` is assigned only once in MIR, but cannot be propagated to `y`
    y
}
```

So any assignment to an argument cannot be propagated.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/mir-opt/copy_propagation_arg.rs76
1 files changed, 50 insertions, 26 deletions
diff --git a/src/test/mir-opt/copy_propagation_arg.rs b/src/test/mir-opt/copy_propagation_arg.rs
index 017fac6a6a1..35bb231df5a 100644
--- a/src/test/mir-opt/copy_propagation_arg.rs
+++ b/src/test/mir-opt/copy_propagation_arg.rs
@@ -30,42 +30,43 @@ fn baz(mut x: i32) {
     x = x;
 }
 
+fn arg_src(mut x: i32) -> i32 {
+    let y = x;
+    x = 123; // Don't propagate this assignment to `y`
+    y
+}
+
 fn main() {
     // Make sure the function actually gets instantiated.
     foo(0);
     bar(0);
     baz(0);
+    arg_src(0);
 }
 
 // END RUST SOURCE
 // START rustc.foo.CopyPropagation.before.mir
 // bb0: {
-//     StorageLive(_2);
-//     StorageLive(_3);
+//     ...
 //     _3 = _1;
 //     _2 = const dummy(move _3) -> bb1;
 // }
 // bb1: {
-//     StorageDead(_3);
+//     ...
 //     _1 = move _2;
-//     StorageDead(_2);
-//     _0 = ();
-//     return;
+//     ...
 // }
 // END rustc.foo.CopyPropagation.before.mir
 // START rustc.foo.CopyPropagation.after.mir
 // bb0: {
-//     StorageLive(_2);
-//     nop;
-//     nop;
-//     _2 = const dummy(move _1) -> bb1;
+//     ...
+//     _3 = _1;
+//     _2 = const dummy(move _3) -> bb1;
 // }
 // bb1: {
-//     nop;
+//     ...
 //     _1 = move _2;
-//     StorageDead(_2);
-//     _0 = ();
-//     return;
+//     ...
 // }
 // END rustc.foo.CopyPropagation.after.mir
 // START rustc.bar.CopyPropagation.before.mir
@@ -83,15 +84,14 @@ fn main() {
 // END rustc.bar.CopyPropagation.before.mir
 // START rustc.bar.CopyPropagation.after.mir
 // bb0: {
-//     nop;
-//     nop;
-//     _2 = const dummy(move _1) -> bb1;
+//     ...
+//     _3 = _1;
+//     _2 = const dummy(move _3) -> bb1;
 // }
 // bb1: {
-//     nop;
+//     ...
 //     _1 = const 5u8;
-//     _0 = ();
-//     return;
+//     ...
 // }
 // END rustc.bar.CopyPropagation.after.mir
 // START rustc.baz.CopyPropagation.before.mir
@@ -106,11 +106,35 @@ fn main() {
 // END rustc.baz.CopyPropagation.before.mir
 // START rustc.baz.CopyPropagation.after.mir
 // bb0: {
-//     nop;
-//     nop;
-//     nop;
-//     nop;
-//     _0 = ();
-//     return;
+//     ...
+//     _2 = _1;
+//     _1 = move _2;
+//     ...
 // }
 // END rustc.baz.CopyPropagation.after.mir
+// START rustc.arg_src.CopyPropagation.before.mir
+// bb0: {
+//       ...
+//       _3 = _1;
+//       _2 = move _3;
+//       ...
+//       _1 = const 123i32;
+//       ...
+//       _4 = _2;
+//       _0 = move _4;
+//       ...
+//       return;
+//   }
+// END rustc.arg_src.CopyPropagation.before.mir
+// START rustc.arg_src.CopyPropagation.after.mir
+// bb0: {
+//     ...
+//     _3 = _1;
+//     ...
+//     _1 = const 123i32;
+//     ...
+//     _0 = move _3;
+//     ...
+//     return;
+// }
+// END rustc.arg_src.CopyPropagation.after.mir