diff options
| author | Amanieu d'Antras <amanieu@gmail.com> | 2019-12-26 10:37:48 -0500 |
|---|---|---|
| committer | Amanieu d'Antras <amanieu@gmail.com> | 2020-03-02 11:43:07 +0000 |
| commit | 919c5fe6b9e052eb243e0e7ceb99d2e6986b4115 (patch) | |
| tree | 30b700e6f42b97283d243d8dfb0c21de50995f45 | |
| parent | 1920f817caf65e5ffb95628b15cedb8aa54a8ae8 (diff) | |
| download | rust-919c5fe6b9e052eb243e0e7ceb99d2e6986b4115.tar.gz rust-919c5fe6b9e052eb243e0e7ceb99d2e6986b4115.zip | |
Test catch_unwind vanishing
We execpt the try intrinsic to be a direct call if in -Cpanic=abort mode, and that catch_unwind optimizes out if calling a function that does not unwind.
| -rw-r--r-- | src/test/codegen/catch-unwind.rs | 19 | ||||
| -rw-r--r-- | src/test/codegen/try-panic-abort.rs | 17 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/test/codegen/catch-unwind.rs b/src/test/codegen/catch-unwind.rs new file mode 100644 index 00000000000..3c9bc35d1c8 --- /dev/null +++ b/src/test/codegen/catch-unwind.rs @@ -0,0 +1,19 @@ +// compile-flags: -O + +#![crate_type = "lib"] + +extern "C" { + fn bar(); +} + +// CHECK-LABEL: @foo +#[no_mangle] +pub unsafe fn foo() -> i32 { + // CHECK: call void @bar + // CHECK: ret i32 0 + std::panic::catch_unwind(|| { + bar(); + 0 + }) + .unwrap() +} diff --git a/src/test/codegen/try-panic-abort.rs b/src/test/codegen/try-panic-abort.rs new file mode 100644 index 00000000000..9bc89a32157 --- /dev/null +++ b/src/test/codegen/try-panic-abort.rs @@ -0,0 +1,17 @@ +// compile-flags: -C panic=abort -O + +#![crate_type = "lib"] +#![feature(unwind_attributes, core_intrinsics)] + +extern "C" { + #[unwind(allow)] + fn bar(data: *mut u8); +} + +// CHECK-LABEL: @foo +#[no_mangle] +pub unsafe fn foo() -> i32 { + // CHECK: call void @bar + // CHECK: ret i32 0 + std::intrinsics::r#try(|x| bar(x), 0 as *mut u8, 0 as *mut u8) +} |
