about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/mir-opt/instsimplify/simplify_repeat.repeat_once_to_aggregate.InstSimplify-after-simplifycfg.diff18
-rw-r--r--tests/mir-opt/instsimplify/simplify_repeat.rs13
-rw-r--r--tests/mir-opt/remove_zsts.get_union.PreCodegen.after.mir10
-rw-r--r--tests/mir-opt/remove_zsts.remove_generic_array.RemoveZsts.diff29
-rw-r--r--tests/mir-opt/remove_zsts.rs14
5 files changed, 72 insertions, 12 deletions
diff --git a/tests/mir-opt/instsimplify/simplify_repeat.repeat_once_to_aggregate.InstSimplify-after-simplifycfg.diff b/tests/mir-opt/instsimplify/simplify_repeat.repeat_once_to_aggregate.InstSimplify-after-simplifycfg.diff
new file mode 100644
index 00000000000..a5e3ddbc57e
--- /dev/null
+++ b/tests/mir-opt/instsimplify/simplify_repeat.repeat_once_to_aggregate.InstSimplify-after-simplifycfg.diff
@@ -0,0 +1,18 @@
+- // MIR for `repeat_once_to_aggregate` before InstSimplify-after-simplifycfg
++ // MIR for `repeat_once_to_aggregate` after InstSimplify-after-simplifycfg
+  
+  fn repeat_once_to_aggregate(_1: T) -> [T; 1] {
+      debug x => _1;
+      let mut _0: [T; 1];
+      let mut _2: T;
+  
+      bb0: {
+          StorageLive(_2);
+          _2 = copy _1;
+-         _0 = [move _2; 1];
++         _0 = [move _2];
+          StorageDead(_2);
+          return;
+      }
+  }
+  
diff --git a/tests/mir-opt/instsimplify/simplify_repeat.rs b/tests/mir-opt/instsimplify/simplify_repeat.rs
new file mode 100644
index 00000000000..359f66710b2
--- /dev/null
+++ b/tests/mir-opt/instsimplify/simplify_repeat.rs
@@ -0,0 +1,13 @@
+//@ test-mir-pass: InstSimplify-after-simplifycfg
+//@ compile-flags: -C panic=abort
+#![crate_type = "lib"]
+
+// EMIT_MIR simplify_repeat.repeat_once_to_aggregate.InstSimplify-after-simplifycfg.diff
+pub fn repeat_once_to_aggregate<T: Copy>(x: T) -> [T; 1] {
+    // CHECK-LABEL: fn repeat_once_to_aggregate(
+    // CHECK-NOT: [move {{_[0-9]+}}; 1]
+    // CHECK: _0 = [move {{_[0-9]+}}];
+    // CHECK-NOT: [move {{_[0-9]+}}; 1]
+
+    [x; 1]
+}
diff --git a/tests/mir-opt/remove_zsts.get_union.PreCodegen.after.mir b/tests/mir-opt/remove_zsts.get_union.PreCodegen.after.mir
deleted file mode 100644
index 5886a5bfeea..00000000000
--- a/tests/mir-opt/remove_zsts.get_union.PreCodegen.after.mir
+++ /dev/null
@@ -1,10 +0,0 @@
-// MIR for `get_union` after PreCodegen
-
-fn get_union() -> Foo {
-    let mut _0: Foo;
-
-    bb0: {
-        _0 = Foo { x: const () };
-        return;
-    }
-}
diff --git a/tests/mir-opt/remove_zsts.remove_generic_array.RemoveZsts.diff b/tests/mir-opt/remove_zsts.remove_generic_array.RemoveZsts.diff
new file mode 100644
index 00000000000..97ff88cc812
--- /dev/null
+++ b/tests/mir-opt/remove_zsts.remove_generic_array.RemoveZsts.diff
@@ -0,0 +1,29 @@
+- // MIR for `remove_generic_array` before RemoveZsts
++ // MIR for `remove_generic_array` after RemoveZsts
+  
+  fn remove_generic_array(_1: T) -> () {
+      debug x => _1;
+      let mut _0: ();
+      let _2: [T; 0];
+      let mut _3: T;
+      scope 1 {
+-         debug a => _2;
++         debug a => const ZeroSized: [T; 0];
+      }
+  
+      bb0: {
+-         StorageLive(_2);
++         nop;
+          StorageLive(_3);
+          _3 = copy _1;
+-         _2 = [];
++         nop;
+          StorageDead(_3);
+-         _0 = const ();
+-         StorageDead(_2);
++         nop;
++         nop;
+          return;
+      }
+  }
+  
diff --git a/tests/mir-opt/remove_zsts.rs b/tests/mir-opt/remove_zsts.rs
index e33a272fe16..d3db1c20142 100644
--- a/tests/mir-opt/remove_zsts.rs
+++ b/tests/mir-opt/remove_zsts.rs
@@ -1,15 +1,25 @@
-// skip-filecheck
+//@ test-mir-pass: RemoveZsts
+
 union Foo {
     x: (),
     y: u64,
 }
 
 // EMIT_MIR remove_zsts.get_union.RemoveZsts.diff
-// EMIT_MIR remove_zsts.get_union.PreCodegen.after.mir
 fn get_union() -> Foo {
+    // CHECK-LABEL: fn get_union
+    // CHECK: _0 = Foo { x: const () };
     Foo { x: () }
 }
 
+// EMIT_MIR remove_zsts.remove_generic_array.RemoveZsts.diff
+fn remove_generic_array<T: Copy>(x: T) {
+    // CHECK-LABEL: fn remove_generic_array
+    // CHECK: debug a => const ZeroSized: [T; 0];
+    // CHECK-NOT: = [];
+    let a = [x; 0];
+}
+
 fn main() {
     get_union();
 }