about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAntoine Martin <antoine97.martin@gmail.com>2020-10-01 10:08:09 +0200
committerAntoine Martin <antoine97.martin@gmail.com>2020-10-01 10:08:09 +0200
commit268f786d3c188160620b81abe988f29adc6a62e6 (patch)
tree7abb5695cd54972514b3883145b6658df46f6bed /src
parentf0d407ed0fe6604d44cc3fbcfba8bd1fa65f8f9c (diff)
Add test for multiple terminator optimization
Diffstat (limited to 'src')
-rw-r--r--src/test/mir-opt/multiple_return_terminators.rs14
-rw-r--r--src/test/mir-opt/multiple_return_terminators.test.MultipleReturnTerminators.diff30
2 files changed, 44 insertions, 0 deletions
diff --git a/src/test/mir-opt/multiple_return_terminators.rs b/src/test/mir-opt/multiple_return_terminators.rs
new file mode 100644
index 00000000000..b73a51d4835
--- /dev/null
+++ b/src/test/mir-opt/multiple_return_terminators.rs
@@ -0,0 +1,14 @@
+// compile-flags: -Z mir-opt-level=3
+// EMIT_MIR multiple_return_terminators.test.MultipleReturnTerminators.diff
+
+fn test(x: bool) {
+    if x {
+        // test
+    } else {
+        // test
+    }
+}
+
+fn main() {
+    test(true)
+}
diff --git a/src/test/mir-opt/multiple_return_terminators.test.MultipleReturnTerminators.diff b/src/test/mir-opt/multiple_return_terminators.test.MultipleReturnTerminators.diff
new file mode 100644
index 00000000000..997c021d2ef
--- /dev/null
+++ b/src/test/mir-opt/multiple_return_terminators.test.MultipleReturnTerminators.diff
@@ -0,0 +1,30 @@
+- // MIR for `test` before MultipleReturnTerminators
++ // MIR for `test` after MultipleReturnTerminators
+  
+  fn test(_1: bool) -> () {
+      debug x => _1;                       // in scope 0 at $DIR/multiple_return_terminators.rs:4:9: 4:10
+      let mut _0: ();                      // return place in scope 0 at $DIR/multiple_return_terminators.rs:4:18: 4:18
+      let mut _2: bool;                    // in scope 0 at $DIR/multiple_return_terminators.rs:5:8: 5:9
+  
+      bb0: {
+          StorageLive(_2);                 // scope 0 at $DIR/multiple_return_terminators.rs:5:8: 5:9
+          _2 = _1;                         // scope 0 at $DIR/multiple_return_terminators.rs:5:8: 5:9
+          switchInt(_2) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/multiple_return_terminators.rs:5:5: 9:6
+      }
+  
+      bb1: {
+          _0 = const ();                   // scope 0 at $DIR/multiple_return_terminators.rs:7:12: 9:6
+          goto -> bb3;                     // scope 0 at $DIR/multiple_return_terminators.rs:5:5: 9:6
+      }
+  
+      bb2: {
+          _0 = const ();                   // scope 0 at $DIR/multiple_return_terminators.rs:5:10: 7:6
+          goto -> bb3;                     // scope 0 at $DIR/multiple_return_terminators.rs:5:5: 9:6
+      }
+  
+      bb3: {
+          StorageDead(_2);                 // scope 0 at $DIR/multiple_return_terminators.rs:10:1: 10:2
+          return;                          // scope 0 at $DIR/multiple_return_terminators.rs:10:2: 10:2
+      }
+  }
+