diff options
| author | Alisa Sireneva <me@purplesyringa.moe> | 2025-01-28 14:37:40 +0300 |
|---|---|---|
| committer | Alisa Sireneva <me@purplesyringa.moe> | 2025-02-06 18:21:13 +0300 |
| commit | a983b58b0c174a5fb68ba506a2560c71849555b7 (patch) | |
| tree | 64bbf01bae11de9baca31f5e09d49387e8dfb47d /tests/codegen | |
| parent | 66d6064f9eb888018775e08f84747ee6f39ba28e (diff) | |
| download | rust-a983b58b0c174a5fb68ba506a2560c71849555b7.tar.gz rust-a983b58b0c174a5fb68ba506a2560c71849555b7.zip | |
Generate correct terminate block under Wasm EH
This fixes failing LLVM assertions during insnsel. Improves #135665.
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/terminating-catchpad.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/codegen/terminating-catchpad.rs b/tests/codegen/terminating-catchpad.rs new file mode 100644 index 00000000000..17d88796300 --- /dev/null +++ b/tests/codegen/terminating-catchpad.rs @@ -0,0 +1,37 @@ +//@ revisions: emscripten wasi seh +//@[emscripten] compile-flags: --target wasm32-unknown-emscripten -Z emscripten-wasm-eh +//@[wasi] compile-flags: --target wasm32-wasip1 -C panic=unwind +//@[seh] compile-flags: --target x86_64-pc-windows-msvc +//@[emscripten] needs-llvm-components: webassembly +//@[wasi] needs-llvm-components: webassembly +//@[seh] needs-llvm-components: x86 + +// Ensure a catch-all generates: +// - `catchpad ... [ptr null]` on Wasm (otherwise LLVM gets confused) +// - `catchpad ... [ptr null, i32 64, ptr null]` on Windows (otherwise we catch SEH exceptions) + +#![feature(no_core, lang_items, rustc_attrs)] +#![crate_type = "lib"] +#![no_std] +#![no_core] + +#[lang = "sized"] +trait Sized {} + +unsafe extern "C-unwind" { + safe fn unwinds(); +} + +#[lang = "panic_cannot_unwind"] +fn panic_cannot_unwind() -> ! { + loop {} +} + +#[no_mangle] +#[rustc_nounwind] +pub fn doesnt_unwind() { + // emscripten: %catchpad = catchpad within %catchswitch [ptr null] + // wasi: %catchpad = catchpad within %catchswitch [ptr null] + // seh: %catchpad = catchpad within %catchswitch [ptr null, i32 64, ptr null] + unwinds(); +} |
