summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/building/custom
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /tests/mir-opt/building/custom
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/mir-opt/building/custom')
-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
3 files changed, 106 insertions, 4 deletions
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)
+ }
+ )
+}