Revert "Fix: On wasm targets, call panic_in_cleanup if panic occurs in cleanup"

This reverts commit acbfd79acf.
This commit is contained in:
Wesley Wiser
2026-04-01 21:29:42 -05:00
parent 7e46c5f6fb
commit c9d3a00cd1
7 changed files with 24 additions and 138 deletions
-34
View File
@@ -1,34 +0,0 @@
//@ compile-flags: -C panic=unwind -Copt-level=0
//@ needs-unwind
//@ only-wasm32
#![crate_type = "lib"]
// Test that `panic_in_cleanup` is called on webassembly targets when a panic
// occurs in a destructor during unwinding.
extern "Rust" {
fn may_panic();
}
struct PanicOnDrop;
impl Drop for PanicOnDrop {
fn drop(&mut self) {
unsafe { may_panic() }
}
}
// CHECK-LABEL: @double_panic
// CHECK: invoke void @may_panic()
// CHECK: invoke void @{{.+}}drop_in_place{{.+}}
// CHECK: unwind label %[[TERMINATE:.*]]
//
// CHECK: [[TERMINATE]]:
// CHECK: call void @{{.*panic_in_cleanup}}
// CHECK: unreachable
#[no_mangle]
pub fn double_panic() {
let _guard = PanicOnDrop;
unsafe { may_panic() }
}
@@ -9,10 +9,6 @@
// 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)
//
// Unlike on windows, on Wasm, we specifically do want to catch foreign
// exceptions. To catch only C++ exceptions we'd need to call
// @llvm.wasm.get.exception and @llvm.wasm.get.ehselector in the catchpad.
#![feature(no_core, lang_items, rustc_attrs)]
#![crate_type = "lib"]
@@ -40,14 +36,8 @@ fn panic_cannot_unwind() -> ! {
#[no_mangle]
#[rustc_nounwind]
pub fn doesnt_unwind() {
// CHECK: catchswitch within none [label %{{.*}}] unwind to caller
// 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]
//
// We don't call these intrinsics on wasm targets so we generate a catch_all
// instruction which also picks up foreign exceptions
// NOT: @llvm.wasm.get.exception
// NOT: @llvm.wasm.get.ehselector
unwinds();
}