-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gccrs: add two more tests to test try-catch (unwind) code generation
gcc/testsuite/ChangeLog: * rust/compile/try-catch-unwind-old.rs: add a test to test the older try intrinsics from plain old Rust to v1.78.0 * rust/compile/try-catch-unwind-new.rs: add a test to test the newer catch_unwind instrinsics since Rust v1.78.0
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// { dg-options "-O2 -w -fdump-tree-optimized" } | ||
#![feature(intrinsics)] | ||
|
||
extern "rust-intrinsic" { | ||
// { dg-final { scan-tree-dump-times "__builtin_eh_pointer" 1 "optimized" } } | ||
fn catch_unwind(try_fn: fn(_: *mut u8), data: *mut u8, catch_fn: fn(_: *mut u8, _: *mut u8)); | ||
} | ||
|
||
extern "C" { | ||
fn try_fn(data: *mut u8); | ||
fn catch_fn(data: *mut u8, ex: *mut u8); | ||
} | ||
|
||
pub fn not_main(d: &mut u8) { | ||
unsafe { | ||
// { dg-final { scan-tree-dump-times "try_fn" 1 "optimized" } } | ||
catch_unwind(try_fn, d, catch_fn); | ||
// { dg-final { scan-tree-dump-times "catch_fn" 1 "optimized" } } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// { dg-options "-O2 -w -fdump-tree-optimized" } | ||
#![feature(intrinsics)] | ||
|
||
extern "rust-intrinsic" { | ||
// { dg-final { scan-tree-dump-times "__builtin_eh_pointer" 1 "optimized" } } | ||
fn r#try(try_fn: fn(_: *mut u8), data: *mut u8, catch_fn: fn(_: *mut u8, _: *mut u8)) -> i32; | ||
} | ||
|
||
extern "C" { | ||
fn try_fn(data: *mut u8); | ||
fn catch_fn(data: *mut u8, ex: *mut u8); | ||
} | ||
|
||
pub fn not_main(d: &mut u8) -> i32 { | ||
unsafe { | ||
// { dg-final { scan-tree-dump-times "try_fn" 1 "optimized" } } | ||
let _: i32 = r#try(try_fn, d, catch_fn); | ||
// { dg-final { scan-tree-dump-times "catch_fn" 1 "optimized" } } | ||
} | ||
42 | ||
} |