summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/inline/indirect_destination.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/mir-opt/inline/indirect_destination.rs')
-rw-r--r--tests/mir-opt/inline/indirect_destination.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/mir-opt/inline/indirect_destination.rs b/tests/mir-opt/inline/indirect_destination.rs
new file mode 100644
index 000000000..2842e2336
--- /dev/null
+++ b/tests/mir-opt/inline/indirect_destination.rs
@@ -0,0 +1,42 @@
+// Test for inlining with an indirect destination place.
+//
+// unit-test: Inline
+// edition: 2021
+// needs-unwind
+#![crate_type = "lib"]
+#![feature(custom_mir, core_intrinsics)]
+use core::intrinsics::mir::*;
+
+#[custom_mir(dialect = "runtime", phase = "initial")]
+// CHECK-LABEL: fn f(
+// CHECK: bb1: {
+// CHECK-NEXT: StorageLive([[A:.*]]);
+// CHECK-NEXT: [[A]] = &mut (*_1);
+// CHECK-NEXT: StorageLive([[B:.*]]);
+// CHECK-NEXT: [[B]] = const 42_u8;
+// CHECK-NEXT: (*[[A]]) = move [[B]];
+// CHECK-NEXT: StorageDead([[B]]);
+// CHECK-NEXT: StorageDead([[A]]);
+// CHECK-NEXT: goto -> bb1;
+// CHECK-NEXT: }
+pub fn f(a: *mut u8) {
+ mir! {
+ {
+ Goto(bb1)
+ }
+ bb1 = {
+ Call(*a = g(), bb1, UnwindUnreachable())
+ }
+ }
+}
+
+#[custom_mir(dialect = "runtime", phase = "initial")]
+#[inline(always)]
+fn g() -> u8 {
+ mir! {
+ {
+ RET = 42;
+ Return()
+ }
+ }
+}