about summary refs log tree commit diff
path: root/tests/codegen-llvm/wasm_exceptions.rs
diff options
context:
space:
mode:
authorAlisa Sireneva <me@purplesyringa.moe>2025-07-15 12:55:46 +0300
committerAlisa Sireneva <me@purplesyringa.moe>2025-07-23 02:17:54 +0300
commited11a396435fc1de59bf40b39789cf8b5c7f5307 (patch)
tree26597747d75ece82e83fe66736d4f04ccaf024dd /tests/codegen-llvm/wasm_exceptions.rs
parenta7a1618e6c835f1f00940ad72203d05808209a0d (diff)
downloadrust-ed11a396435fc1de59bf40b39789cf8b5c7f5307.tar.gz
rust-ed11a396435fc1de59bf40b39789cf8b5c7f5307.zip
Don't special-case llvm.* as nounwind
Certain LLVM intrinsics, such as `llvm.wasm.throw`, can unwind. Marking
them as nounwind causes us to skip cleanup of locals and optimize out
`catch_unwind` under inlining or when `llvm.wasm.throw` is used directly
by user code.

The motivation for forcibly marking llvm.* as nounwind is no longer
present: most intrinsics are linked as `extern "C"` or other
non-unwinding ABIs, so we won't codegen `invoke` for them anyway.
Diffstat (limited to 'tests/codegen-llvm/wasm_exceptions.rs')
-rw-r--r--tests/codegen-llvm/wasm_exceptions.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/codegen-llvm/wasm_exceptions.rs b/tests/codegen-llvm/wasm_exceptions.rs
index 07b8ae6e9d7..796b69b722b 100644
--- a/tests/codegen-llvm/wasm_exceptions.rs
+++ b/tests/codegen-llvm/wasm_exceptions.rs
@@ -2,7 +2,7 @@
 //@ compile-flags: -C panic=unwind -Z emscripten-wasm-eh
 
 #![crate_type = "lib"]
-#![feature(core_intrinsics)]
+#![feature(core_intrinsics, wasm_exception_handling_intrinsics)]
 
 extern "C-unwind" {
     fn may_panic();
@@ -57,3 +57,17 @@ pub fn test_rtry() {
     // CHECK: {{.*}} = catchpad within {{.*}} [ptr null]
     // CHECK: catchret
 }
+
+// Make sure the intrinsic is not inferred as nounwind. This is a regression test for #132416.
+// CHECK-LABEL: @test_intrinsic() {{.*}} @__gxx_wasm_personality_v0
+#[no_mangle]
+pub fn test_intrinsic() {
+    let _log_on_drop = LogOnDrop;
+    unsafe {
+        core::arch::wasm32::throw::<0>(core::ptr::null_mut());
+    }
+
+    // CHECK-NOT: call
+    // CHECK: invoke void @llvm.wasm.throw(i32 noundef 0, ptr noundef null)
+    // CHECK: %cleanuppad = cleanuppad within none []
+}