summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/building
diff options
context:
space:
mode:
Diffstat (limited to 'tests/mir-opt/building')
-rw-r--r--tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir11
-rw-r--r--tests/mir-opt/building/custom/terminators.rs8
-rw-r--r--tests/mir-opt/building/custom/unwind_action.rs68
-rw-r--r--tests/mir-opt/building/custom/unwind_terminate.rs34
4 files changed, 115 insertions, 6 deletions
diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir
index 396e4a378..59e275124 100644
--- a/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir
+++ b/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir
@@ -14,7 +14,7 @@
Static,
),
source_info: SourceInfo {
- span: $DIR/async_await.rs:16:9: 16:14 (#8),
+ span: $DIR/async_await.rs:16:5: 16:14 (#9),
scope: scope[0],
},
ignore_for_traits: false,
@@ -32,7 +32,7 @@
Static,
),
source_info: SourceInfo {
- span: $DIR/async_await.rs:17:9: 17:14 (#10),
+ span: $DIR/async_await.rs:17:5: 17:14 (#11),
scope: scope[0],
},
ignore_for_traits: false,
@@ -178,6 +178,10 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:15:18: 18:2}>,
StorageLive(_20);
_20 = ();
_0 = Poll::<()>::Pending;
+ StorageDead(_3);
+ StorageDead(_4);
+ StorageDead(_19);
+ StorageDead(_20);
discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2}))) = 3;
return;
}
@@ -276,6 +280,9 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:15:18: 18:2}>,
StorageLive(_36);
_36 = ();
_0 = Poll::<()>::Pending;
+ StorageDead(_21);
+ StorageDead(_35);
+ StorageDead(_36);
discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2}))) = 4;
return;
}
diff --git a/tests/mir-opt/building/custom/terminators.rs b/tests/mir-opt/building/custom/terminators.rs
index 9e442e0f9..a83a6c074 100644
--- a/tests/mir-opt/building/custom/terminators.rs
+++ b/tests/mir-opt/building/custom/terminators.rs
@@ -13,7 +13,7 @@ fn ident<T>(t: T) -> T {
fn direct_call(x: i32) -> i32 {
mir!(
{
- Call(RET = ident(x), retblock)
+ Call(RET = ident(x), retblock, UnwindContinue())
}
retblock = {
@@ -27,7 +27,7 @@ fn direct_call(x: i32) -> i32 {
fn indirect_call(x: i32, f: fn(i32) -> i32) -> i32 {
mir!(
{
- Call(RET = f(x), retblock)
+ Call(RET = f(x), retblock, UnwindContinue())
}
retblock = {
@@ -49,7 +49,7 @@ impl<'a> Drop for WriteOnDrop<'a> {
fn drop_first<'a>(a: WriteOnDrop<'a>, b: WriteOnDrop<'a>) {
mir!(
{
- Drop(a, retblock)
+ Drop(a, retblock, UnwindContinue())
}
retblock = {
@@ -64,7 +64,7 @@ fn drop_first<'a>(a: WriteOnDrop<'a>, b: WriteOnDrop<'a>) {
fn drop_second<'a>(a: WriteOnDrop<'a>, b: WriteOnDrop<'a>) {
mir!(
{
- Drop(b, retblock)
+ Drop(b, retblock, UnwindContinue())
}
retblock = {
diff --git a/tests/mir-opt/building/custom/unwind_action.rs b/tests/mir-opt/building/custom/unwind_action.rs
new file mode 100644
index 000000000..e3c4ffac3
--- /dev/null
+++ b/tests/mir-opt/building/custom/unwind_action.rs
@@ -0,0 +1,68 @@
+// compile-flags: --crate-type=lib
+// edition:2021
+// needs-unwind
+#![feature(custom_mir, core_intrinsics)]
+use core::intrinsics::mir::*;
+
+// CHECK-LABEL: fn a()
+// CHECK: bb0: {
+// CHECK-NEXT: a() -> [return: bb1, unwind unreachable];
+#[custom_mir(dialect = "runtime", phase = "optimized")]
+pub fn a() {
+ mir!(
+ {
+ Call(RET = a(), bb1, UnwindUnreachable())
+ }
+ bb1 = {
+ Return()
+ }
+ )
+}
+
+// CHECK-LABEL: fn b()
+// CHECK: bb0: {
+// CHECK-NEXT: b() -> [return: bb1, unwind continue];
+#[custom_mir(dialect = "runtime", phase = "optimized")]
+pub fn b() {
+ mir!(
+ {
+ Call(RET = b(), bb1, UnwindContinue())
+ }
+ bb1 = {
+ Return()
+ }
+ )
+}
+
+// CHECK-LABEL: fn c()
+// CHECK: bb0: {
+// CHECK-NEXT: c() -> [return: bb1, unwind terminate(abi)];
+#[custom_mir(dialect = "runtime", phase = "optimized")]
+pub fn c() {
+ mir!(
+ {
+ Call(RET = c(), bb1, UnwindTerminate(ReasonAbi))
+ }
+ bb1 = {
+ Return()
+ }
+ )
+}
+
+// CHECK-LABEL: fn d()
+// CHECK: bb0: {
+// CHECK-NEXT: d() -> [return: bb1, unwind: bb2];
+#[custom_mir(dialect = "runtime", phase = "optimized")]
+pub fn d() {
+ mir!(
+ {
+ Call(RET = d(), bb1, UnwindCleanup(bb2))
+ }
+ bb1 = {
+ Return()
+ }
+ bb2 (cleanup) = {
+ UnwindResume()
+ }
+ )
+}
diff --git a/tests/mir-opt/building/custom/unwind_terminate.rs b/tests/mir-opt/building/custom/unwind_terminate.rs
new file mode 100644
index 000000000..efdf2ddb1
--- /dev/null
+++ b/tests/mir-opt/building/custom/unwind_terminate.rs
@@ -0,0 +1,34 @@
+// compile-flags: --crate-type=lib
+// edition:2021
+#![feature(custom_mir, core_intrinsics)]
+use core::intrinsics::mir::*;
+
+// CHECK-LABEL: fn f()
+// CHECK: bb1 (cleanup): {
+// CHECK-NEXT: terminate(abi);
+#[custom_mir(dialect = "runtime", phase = "optimized")]
+pub fn f() {
+ mir!(
+ {
+ Return()
+ }
+ bb1(cleanup) = {
+ UnwindTerminate(ReasonAbi)
+ }
+ )
+}
+
+// CHECK-LABEL: fn g()
+// CHECK: bb1 (cleanup): {
+// CHECK-NEXT: terminate(cleanup);
+#[custom_mir(dialect = "runtime", phase = "optimized")]
+pub fn g() {
+ mir!(
+ {
+ Return()
+ }
+ bb1(cleanup) = {
+ UnwindTerminate(ReasonInCleanup)
+ }
+ )
+}