about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorWesley Wiser <wwiser@gmail.com>2020-04-03 18:40:08 -0400
committerWesley Wiser <wwiser@gmail.com>2020-04-15 14:34:23 -0400
commit0e0a71a3931bbfe5c296e9f55adabb2585974c2c (patch)
treed159a0c73621565698edecac4f3a033a85d37266 /src
parentdf768c5c8fcb361c4dc94b4c776d6a78c12862e1 (diff)
downloadrust-0e0a71a3931bbfe5c296e9f55adabb2585974c2c.tar.gz
rust-0e0a71a3931bbfe5c296e9f55adabb2585974c2c.zip
Add test case
Diffstat (limited to 'src')
-rw-r--r--src/test/mir-opt/simplify-locals-fixedpoint.rs15
-rw-r--r--src/test/mir-opt/simplify-locals-fixedpoint/rustc.foo.SimplifyLocals.diff65
2 files changed, 80 insertions, 0 deletions
diff --git a/src/test/mir-opt/simplify-locals-fixedpoint.rs b/src/test/mir-opt/simplify-locals-fixedpoint.rs
new file mode 100644
index 00000000000..aa5bc345359
--- /dev/null
+++ b/src/test/mir-opt/simplify-locals-fixedpoint.rs
@@ -0,0 +1,15 @@
+// compile-flags: -Zmir-opt-level=1
+
+fn foo<T>() {
+    if let (Some(a), None) = (Option::<u8>::None, Option::<T>::None) {
+        if a > 42u8 {
+
+        }
+    }
+}
+
+fn main() {
+    foo::<()>();
+}
+
+// EMIT_MIR rustc.foo.SimplifyLocals.diff
diff --git a/src/test/mir-opt/simplify-locals-fixedpoint/rustc.foo.SimplifyLocals.diff b/src/test/mir-opt/simplify-locals-fixedpoint/rustc.foo.SimplifyLocals.diff
new file mode 100644
index 00000000000..89326e8e3f6
--- /dev/null
+++ b/src/test/mir-opt/simplify-locals-fixedpoint/rustc.foo.SimplifyLocals.diff
@@ -0,0 +1,65 @@
+- // MIR for `foo` before SimplifyLocals
++ // MIR for `foo` after SimplifyLocals
+  
+  fn foo() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/simplify-locals-fixedpoint.rs:3:13: 3:13
+      let mut _1: (std::option::Option<u8>, std::option::Option<T>); // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:30: 4:69
+      let mut _2: std::option::Option<u8>; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:31: 4:49
+      let mut _3: std::option::Option<T>;  // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:51: 4:68
+      let mut _4: isize;                   // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26
+      let mut _5: isize;                   // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20
+      let _6: u8;                          // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19
+      let mut _7: bool;                    // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20
+      let mut _8: u8;                      // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13
+      scope 1 {
+          debug a => _6;                   // in scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19
+      }
+  
+      bb0: {
+          StorageLive(_1);                 // bb0[0]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:30: 4:69
+          StorageLive(_2);                 // bb0[1]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:31: 4:49
+          discriminant(_2) = 0;            // bb0[2]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:31: 4:49
+          StorageLive(_3);                 // bb0[3]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:51: 4:68
+          discriminant(_3) = 0;            // bb0[4]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:51: 4:68
+          (_1.0: std::option::Option<u8>) = move _2; // bb0[5]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:30: 4:69
+          (_1.1: std::option::Option<T>) = move _3; // bb0[6]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:30: 4:69
+          StorageDead(_3);                 // bb0[7]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:68: 4:69
+          StorageDead(_2);                 // bb0[8]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:68: 4:69
+          _5 = discriminant((_1.0: std::option::Option<u8>)); // bb0[9]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20
+          switchInt(move _5) -> [1isize: bb1, otherwise: bb3]; // bb0[10]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20
+      }
+  
+      bb1: {
+          _4 = discriminant((_1.1: std::option::Option<T>)); // bb1[0]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26
+          switchInt(move _4) -> [0isize: bb2, otherwise: bb3]; // bb1[1]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26
+      }
+  
+      bb2: {
+          StorageLive(_6);                 // bb2[0]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19
+          _6 = (((_1.0: std::option::Option<u8>) as Some).0: u8); // bb2[1]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19
+          StorageLive(_7);                 // bb2[2]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20
+          StorageLive(_8);                 // bb2[3]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13
+          _8 = _6;                         // bb2[4]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13
+          _7 = Gt(move _8, const 42u8);    // bb2[5]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20
+                                           // ty::Const
+                                           // + ty: u8
+                                           // + val: Value(Scalar(0x2a))
+                                           // mir::Constant
+                                           // + span: $DIR/simplify-locals-fixedpoint.rs:5:16: 5:20
+                                           // + literal: Const { ty: u8, val: Value(Scalar(0x2a)) }
+          StorageDead(_8);                 // bb2[6]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:19: 5:20
+          StorageDead(_7);                 // bb2[7]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:8:5: 8:6
+          StorageDead(_6);                 // bb2[8]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:8:5: 8:6
+          goto -> bb3;                     // bb2[9]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6
+      }
+  
+      bb3: {
+          drop(_1) -> bb4;                 // bb3[0]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:1: 9:2
+      }
+  
+      bb4: {
+          StorageDead(_1);                 // bb4[0]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:1: 9:2
+          return;                          // bb4[1]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:2: 9:2
+      }
+  }
+