about summary refs log tree commit diff
path: root/tests/mir-opt/inline
diff options
context:
space:
mode:
authorJakob Degen <jakob.e.degen@gmail.com>2023-05-10 03:23:07 -0700
committerJakob Degen <jakob.e.degen@gmail.com>2023-05-20 17:45:50 -0700
commit60cc72cf7be596650a0dac5f74887f7e4eefae40 (patch)
tree18aa17828d9b41f733671e9352e281c040f17bbf /tests/mir-opt/inline
parentfe76e14955329df4bc54aab78c297e58fe58c115 (diff)
downloadrust-60cc72cf7be596650a0dac5f74887f7e4eefae40.tar.gz
rust-60cc72cf7be596650a0dac5f74887f7e4eefae40.zip
Don't inline functions with unsized args
Diffstat (limited to 'tests/mir-opt/inline')
-rw-r--r--tests/mir-opt/inline/unsized_argument.caller.Inline.diff50
-rw-r--r--tests/mir-opt/inline/unsized_argument.rs15
2 files changed, 65 insertions, 0 deletions
diff --git a/tests/mir-opt/inline/unsized_argument.caller.Inline.diff b/tests/mir-opt/inline/unsized_argument.caller.Inline.diff
new file mode 100644
index 00000000000..745f2bb193a
--- /dev/null
+++ b/tests/mir-opt/inline/unsized_argument.caller.Inline.diff
@@ -0,0 +1,50 @@
+- // MIR for `caller` before Inline
++ // MIR for `caller` after Inline
+  
+  fn caller(_1: Box<[i32]>) -> () {
+      debug x => _1;                       // in scope 0 at $DIR/unsized_argument.rs:+0:11: +0:12
+      let mut _0: ();                      // return place in scope 0 at $DIR/unsized_argument.rs:+0:26: +0:26
+      let _2: ();                          // in scope 0 at $DIR/unsized_argument.rs:+1:5: +1:15
+      let mut _3: std::boxed::Box<[i32]>;  // in scope 0 at $DIR/unsized_argument.rs:+1:13: +1:14
+      let mut _4: ();                      // in scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15
+      let mut _5: ();                      // in scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15
+      let mut _6: ();                      // in scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15
+      let mut _7: *const [i32];            // in scope 0 at $DIR/unsized_argument.rs:+1:13: +1:14
+  
+      bb0: {
+          StorageLive(_2);                 // scope 0 at $DIR/unsized_argument.rs:+1:5: +1:15
+          StorageLive(_3);                 // scope 0 at $DIR/unsized_argument.rs:+1:13: +1:14
+          _3 = move _1;                    // scope 0 at $DIR/unsized_argument.rs:+1:13: +1:14
+          _7 = (((_3.0: std::ptr::Unique<[i32]>).0: std::ptr::NonNull<[i32]>).0: *const [i32]); // scope 0 at $DIR/unsized_argument.rs:+1:5: +1:15
+          _2 = callee(move (*_7)) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/unsized_argument.rs:+1:5: +1:15
+                                           // mir::Constant
+                                           // + span: $DIR/unsized_argument.rs:9:5: 9:11
+                                           // + literal: Const { ty: fn([i32]) {callee}, val: Value(<ZST>) }
+      }
+  
+      bb1: {
+          StorageDead(_3);                 // scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15
+          StorageDead(_2);                 // scope 0 at $DIR/unsized_argument.rs:+1:15: +1:16
+          _0 = const ();                   // scope 0 at $DIR/unsized_argument.rs:+0:26: +2:2
+          return;                          // scope 0 at $DIR/unsized_argument.rs:+2:2: +2:2
+      }
+  
+      bb2 (cleanup): {
+          resume;                          // scope 0 at $DIR/unsized_argument.rs:+0:1: +2:2
+      }
+  
+      bb3: {
+          _4 = alloc::alloc::box_free::<[i32], std::alloc::Global>(move (_3.0: std::ptr::Unique<[i32]>), move (_3.1: std::alloc::Global)) -> bb1; // scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15
+                                           // mir::Constant
+                                           // + span: $DIR/unsized_argument.rs:9:14: 9:15
+                                           // + literal: Const { ty: unsafe fn(Unique<[i32]>, std::alloc::Global) {alloc::alloc::box_free::<[i32], std::alloc::Global>}, val: Value(<ZST>) }
+      }
+  
+      bb4 (cleanup): {
+          _6 = alloc::alloc::box_free::<[i32], std::alloc::Global>(move (_3.0: std::ptr::Unique<[i32]>), move (_3.1: std::alloc::Global)) -> [return: bb2, unwind terminate]; // scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15
+                                           // mir::Constant
+                                           // + span: $DIR/unsized_argument.rs:9:14: 9:15
+                                           // + literal: Const { ty: unsafe fn(Unique<[i32]>, std::alloc::Global) {alloc::alloc::box_free::<[i32], std::alloc::Global>}, val: Value(<ZST>) }
+      }
+  }
+  
diff --git a/tests/mir-opt/inline/unsized_argument.rs b/tests/mir-opt/inline/unsized_argument.rs
new file mode 100644
index 00000000000..b2c51407fd5
--- /dev/null
+++ b/tests/mir-opt/inline/unsized_argument.rs
@@ -0,0 +1,15 @@
+// needs-unwind
+#![feature(unsized_fn_params)]
+
+#[inline(always)]
+fn callee(y: [i32]) {}
+
+// EMIT_MIR unsized_argument.caller.Inline.diff
+fn caller(x: Box<[i32]>) {
+    callee(*x);
+}
+
+fn main() {
+    let b = Box::new([1]);
+    caller(b);
+}