about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff1
-rw-r--r--src/test/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff75
-rw-r--r--src/test/mir-opt/dead-store-elimination/cycle.rs22
-rw-r--r--src/test/mir-opt/dead-store-elimination/provenance_soundness.pointer_to_int.DeadStoreElimination.diff35
-rw-r--r--src/test/mir-opt/dead-store-elimination/provenance_soundness.retags.DeadStoreElimination.diff14
-rw-r--r--src/test/mir-opt/dead-store-elimination/provenance_soundness.rs18
-rw-r--r--src/test/mir-opt/dest-prop/copy_propagation_arg.arg_src.DestinationPropagation.diff2
-rw-r--r--src/test/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff2
8 files changed, 167 insertions, 2 deletions
diff --git a/src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff b/src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff
index bbde6ad4b63..cd4b471b28c 100644
--- a/src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff
+++ b/src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff
@@ -99,6 +99,7 @@
           _13 = const 64_u32;              // scope 8 at $DIR/const_debuginfo.rs:21:13: 21:22
           StorageDead(_15);                // scope 8 at $DIR/const_debuginfo.rs:21:21: 21:22
           StorageDead(_14);                // scope 8 at $DIR/const_debuginfo.rs:21:21: 21:22
+          nop;                             // scope 0 at $DIR/const_debuginfo.rs:8:11: 22:2
           StorageDead(_13);                // scope 8 at $DIR/const_debuginfo.rs:22:1: 22:2
           StorageDead(_12);                // scope 7 at $DIR/const_debuginfo.rs:22:1: 22:2
           StorageDead(_11);                // scope 6 at $DIR/const_debuginfo.rs:22:1: 22:2
diff --git a/src/test/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff b/src/test/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff
new file mode 100644
index 00000000000..6037f89086d
--- /dev/null
+++ b/src/test/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff
@@ -0,0 +1,75 @@
+- // MIR for `cycle` before DeadStoreElimination
++ // MIR for `cycle` after DeadStoreElimination
+  
+  fn cycle(_1: i32, _2: i32, _3: i32) -> () {
+      debug x => _1;                       // in scope 0 at $DIR/cycle.rs:9:10: 9:15
+      debug y => _2;                       // in scope 0 at $DIR/cycle.rs:9:22: 9:27
+      debug z => _3;                       // in scope 0 at $DIR/cycle.rs:9:34: 9:39
+      let mut _0: ();                      // return place in scope 0 at $DIR/cycle.rs:9:46: 9:46
+      let mut _4: ();                      // in scope 0 at $DIR/cycle.rs:9:1: 18:2
+      let mut _5: bool;                    // in scope 0 at $DIR/cycle.rs:12:11: 12:17
+      let _6: i32;                         // in scope 0 at $DIR/cycle.rs:13:13: 13:17
+      let mut _7: i32;                     // in scope 0 at $DIR/cycle.rs:14:13: 14:14
+      let mut _8: i32;                     // in scope 0 at $DIR/cycle.rs:15:13: 15:14
+      let mut _9: i32;                     // in scope 0 at $DIR/cycle.rs:16:13: 16:17
+      let mut _10: !;                      // in scope 0 at $DIR/cycle.rs:12:5: 17:6
+      let _11: ();                         // in scope 0 at $DIR/cycle.rs:12:5: 17:6
+      let mut _12: !;                      // in scope 0 at $DIR/cycle.rs:12:5: 17:6
+      scope 1 {
+          debug temp => _6;                // in scope 1 at $DIR/cycle.rs:13:13: 13:17
+      }
+  
+      bb0: {
+          goto -> bb1;                     // scope 0 at $DIR/cycle.rs:12:5: 17:6
+      }
+  
+      bb1: {
+          StorageLive(_5);                 // scope 0 at $DIR/cycle.rs:12:11: 12:17
+          _5 = cond() -> bb2;              // scope 0 at $DIR/cycle.rs:12:11: 12:17
+                                           // mir::Constant
+                                           // + span: $DIR/cycle.rs:12:11: 12:15
+                                           // + literal: Const { ty: fn() -> bool {cond}, val: Value(Scalar(<ZST>)) }
+      }
+  
+      bb2: {
+          switchInt(move _5) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/cycle.rs:12:11: 12:17
+      }
+  
+      bb3: {
+          StorageLive(_6);                 // scope 0 at $DIR/cycle.rs:13:13: 13:17
+-         _6 = _3;                         // scope 0 at $DIR/cycle.rs:13:20: 13:21
++         nop;                             // scope 0 at $DIR/cycle.rs:13:20: 13:21
+          StorageLive(_7);                 // scope 1 at $DIR/cycle.rs:14:13: 14:14
+-         _7 = _2;                         // scope 1 at $DIR/cycle.rs:14:13: 14:14
+-         _3 = move _7;                    // scope 1 at $DIR/cycle.rs:14:9: 14:14
++         nop;                             // scope 1 at $DIR/cycle.rs:14:13: 14:14
++         nop;                             // scope 1 at $DIR/cycle.rs:14:9: 14:14
+          StorageDead(_7);                 // scope 1 at $DIR/cycle.rs:14:13: 14:14
+          StorageLive(_8);                 // scope 1 at $DIR/cycle.rs:15:13: 15:14
+-         _8 = _1;                         // scope 1 at $DIR/cycle.rs:15:13: 15:14
+-         _2 = move _8;                    // scope 1 at $DIR/cycle.rs:15:9: 15:14
++         nop;                             // scope 1 at $DIR/cycle.rs:15:13: 15:14
++         nop;                             // scope 1 at $DIR/cycle.rs:15:9: 15:14
+          StorageDead(_8);                 // scope 1 at $DIR/cycle.rs:15:13: 15:14
+          StorageLive(_9);                 // scope 1 at $DIR/cycle.rs:16:13: 16:17
+-         _9 = _6;                         // scope 1 at $DIR/cycle.rs:16:13: 16:17
+-         _1 = move _9;                    // scope 1 at $DIR/cycle.rs:16:9: 16:17
++         nop;                             // scope 1 at $DIR/cycle.rs:16:13: 16:17
++         nop;                             // scope 1 at $DIR/cycle.rs:16:9: 16:17
+          StorageDead(_9);                 // scope 1 at $DIR/cycle.rs:16:16: 16:17
+-         _4 = const ();                   // scope 0 at $DIR/cycle.rs:12:18: 17:6
++         nop;                             // scope 0 at $DIR/cycle.rs:12:18: 17:6
+          StorageDead(_6);                 // scope 0 at $DIR/cycle.rs:17:5: 17:6
+          StorageDead(_5);                 // scope 0 at $DIR/cycle.rs:17:5: 17:6
+          goto -> bb1;                     // scope 0 at $DIR/cycle.rs:12:5: 17:6
+      }
+  
+      bb4: {
+          StorageLive(_11);                // scope 0 at $DIR/cycle.rs:12:5: 17:6
+          _0 = const ();                   // scope 0 at $DIR/cycle.rs:12:5: 17:6
+          StorageDead(_11);                // scope 0 at $DIR/cycle.rs:17:5: 17:6
+          StorageDead(_5);                 // scope 0 at $DIR/cycle.rs:17:5: 17:6
+          return;                          // scope 0 at $DIR/cycle.rs:18:2: 18:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/dead-store-elimination/cycle.rs b/src/test/mir-opt/dead-store-elimination/cycle.rs
new file mode 100644
index 00000000000..b35ce0bcb5a
--- /dev/null
+++ b/src/test/mir-opt/dead-store-elimination/cycle.rs
@@ -0,0 +1,22 @@
+// unit-test: DeadStoreElimination
+
+#[inline(never)]
+fn cond() -> bool {
+    false
+}
+
+// EMIT_MIR cycle.cycle.DeadStoreElimination.diff
+fn cycle(mut x: i32, mut y: i32, mut z: i32) {
+    // This example is interesting because the non-transitive version of `MaybeLiveLocals` would
+    // report that *all* of these stores are live.
+    while cond() {
+        let temp = z;
+        z = y;
+        y = x;
+        x = temp;
+    }
+}
+
+fn main() {
+    cycle(1, 2, 3);
+}
diff --git a/src/test/mir-opt/dead-store-elimination/provenance_soundness.pointer_to_int.DeadStoreElimination.diff b/src/test/mir-opt/dead-store-elimination/provenance_soundness.pointer_to_int.DeadStoreElimination.diff
new file mode 100644
index 00000000000..2250159c816
--- /dev/null
+++ b/src/test/mir-opt/dead-store-elimination/provenance_soundness.pointer_to_int.DeadStoreElimination.diff
@@ -0,0 +1,35 @@
+- // MIR for `pointer_to_int` before DeadStoreElimination
++ // MIR for `pointer_to_int` after DeadStoreElimination
+  
+  fn pointer_to_int(_1: *mut i32) -> () {
+      debug p => _1;                       // in scope 0 at $DIR/provenance_soundness.rs:7:19: 7:20
+      let mut _0: ();                      // return place in scope 0 at $DIR/provenance_soundness.rs:7:32: 7:32
+      let _2: usize;                       // in scope 0 at $DIR/provenance_soundness.rs:8:9: 8:11
+      let mut _3: *mut i32;                // in scope 0 at $DIR/provenance_soundness.rs:8:14: 8:15
+      let mut _5: *mut i32;                // in scope 0 at $DIR/provenance_soundness.rs:9:14: 9:15
+      scope 1 {
+          debug _x => _2;                  // in scope 1 at $DIR/provenance_soundness.rs:8:9: 8:11
+          let _4: isize;                   // in scope 1 at $DIR/provenance_soundness.rs:9:9: 9:11
+          scope 2 {
+              debug _y => _4;              // in scope 2 at $DIR/provenance_soundness.rs:9:9: 9:11
+          }
+      }
+  
+      bb0: {
+          StorageLive(_2);                 // scope 0 at $DIR/provenance_soundness.rs:8:9: 8:11
+          StorageLive(_3);                 // scope 0 at $DIR/provenance_soundness.rs:8:14: 8:15
+          _3 = _1;                         // scope 0 at $DIR/provenance_soundness.rs:8:14: 8:15
+          _2 = move _3 as usize (Misc);    // scope 0 at $DIR/provenance_soundness.rs:8:14: 8:24
+          StorageDead(_3);                 // scope 0 at $DIR/provenance_soundness.rs:8:23: 8:24
+          StorageLive(_4);                 // scope 1 at $DIR/provenance_soundness.rs:9:9: 9:11
+          StorageLive(_5);                 // scope 1 at $DIR/provenance_soundness.rs:9:14: 9:15
+          _5 = _1;                         // scope 1 at $DIR/provenance_soundness.rs:9:14: 9:15
+          _4 = move _5 as isize (Misc);    // scope 1 at $DIR/provenance_soundness.rs:9:14: 9:24
+          StorageDead(_5);                 // scope 1 at $DIR/provenance_soundness.rs:9:23: 9:24
+          _0 = const ();                   // scope 0 at $DIR/provenance_soundness.rs:7:32: 10:2
+          StorageDead(_4);                 // scope 1 at $DIR/provenance_soundness.rs:10:1: 10:2
+          StorageDead(_2);                 // scope 0 at $DIR/provenance_soundness.rs:10:1: 10:2
+          return;                          // scope 0 at $DIR/provenance_soundness.rs:10:2: 10:2
+      }
+  }
+  
diff --git a/src/test/mir-opt/dead-store-elimination/provenance_soundness.retags.DeadStoreElimination.diff b/src/test/mir-opt/dead-store-elimination/provenance_soundness.retags.DeadStoreElimination.diff
new file mode 100644
index 00000000000..0bfffb6dca3
--- /dev/null
+++ b/src/test/mir-opt/dead-store-elimination/provenance_soundness.retags.DeadStoreElimination.diff
@@ -0,0 +1,14 @@
+- // MIR for `retags` before DeadStoreElimination
++ // MIR for `retags` after DeadStoreElimination
+  
+  fn retags(_1: &mut i32) -> () {
+      debug _r => _1;                      // in scope 0 at $DIR/provenance_soundness.rs:13:11: 13:13
+      let mut _0: ();                      // return place in scope 0 at $DIR/provenance_soundness.rs:13:25: 13:25
+  
+      bb0: {
+          Retag([fn entry] _1);            // scope 0 at $DIR/provenance_soundness.rs:13:1: 13:27
+          _0 = const ();                   // scope 0 at $DIR/provenance_soundness.rs:13:25: 13:27
+          return;                          // scope 0 at $DIR/provenance_soundness.rs:13:27: 13:27
+      }
+  }
+  
diff --git a/src/test/mir-opt/dead-store-elimination/provenance_soundness.rs b/src/test/mir-opt/dead-store-elimination/provenance_soundness.rs
new file mode 100644
index 00000000000..11314e99098
--- /dev/null
+++ b/src/test/mir-opt/dead-store-elimination/provenance_soundness.rs
@@ -0,0 +1,18 @@
+// unit-test: DeadStoreElimination
+// compile-flags: -Zmir-emit-retag
+
+// Test that we don't remove pointer to int casts or retags
+
+// EMIT_MIR provenance_soundness.pointer_to_int.DeadStoreElimination.diff
+fn pointer_to_int(p: *mut i32) {
+    let _x = p as usize;
+    let _y = p as isize;
+}
+
+// EMIT_MIR provenance_soundness.retags.DeadStoreElimination.diff
+fn retags(_r: &mut i32) {}
+
+fn main() {
+    pointer_to_int(&mut 5 as *mut _);
+    retags(&mut 5);
+}
diff --git a/src/test/mir-opt/dest-prop/copy_propagation_arg.arg_src.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/copy_propagation_arg.arg_src.DestinationPropagation.diff
index a5d80e75053..b67e6cb4708 100644
--- a/src/test/mir-opt/dest-prop/copy_propagation_arg.arg_src.DestinationPropagation.diff
+++ b/src/test/mir-opt/dest-prop/copy_propagation_arg.arg_src.DestinationPropagation.diff
@@ -2,7 +2,7 @@
 + // MIR for `arg_src` after DestinationPropagation
   
   fn arg_src(_1: i32) -> i32 {
-      debug x => _1;                       // in scope 0 at $DIR/copy_propagation_arg.rs:27:12: 27:17
+      debug x => const 123_i32;            // in scope 0 at $DIR/copy_propagation_arg.rs:27:12: 27:17
       let mut _0: i32;                     // return place in scope 0 at $DIR/copy_propagation_arg.rs:27:27: 27:30
       let _2: i32;                         // in scope 0 at $DIR/copy_propagation_arg.rs:28:9: 28:10
       scope 1 {
diff --git a/src/test/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff
index 383f00f0125..1b8772b6a68 100644
--- a/src/test/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff
+++ b/src/test/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff
@@ -2,7 +2,7 @@
 + // MIR for `bar` after DestinationPropagation
   
   fn bar(_1: u8) -> () {
-      debug x => _1;                       // in scope 0 at $DIR/copy_propagation_arg.rs:15:8: 15:13
+      debug x => const 5_u8;               // in scope 0 at $DIR/copy_propagation_arg.rs:15:8: 15:13
       let mut _0: ();                      // return place in scope 0 at $DIR/copy_propagation_arg.rs:15:19: 15:19
       let _2: u8;                          // in scope 0 at $DIR/copy_propagation_arg.rs:16:5: 16:13
       let mut _3: u8;                      // in scope 0 at $DIR/copy_propagation_arg.rs:16:11: 16:12