Skip to content

Commit f2668d2

Browse files
committed
Auto merge of rust-lang#144225 - purplesyringa:unwinding-intrinsics, r=nikic
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. Closes rust-lang#132416. `@rustbot` label +T-compiler +A-panic
2 parents 7fac5a8 + 73a96a2 commit f2668d2

File tree

1 file changed

+10
-0
lines changed
  • stdarch/crates/core_arch/src/wasm32

1 file changed

+10
-0
lines changed

stdarch/crates/core_arch/src/wasm32/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,16 @@ unsafe extern "C-unwind" {
191191
// #[cfg_attr(test, assert_instr(throw, TAG = 0, ptr = core::ptr::null_mut()))]
192192
#[inline]
193193
#[unstable(feature = "wasm_exception_handling_intrinsics", issue = "122465")]
194+
// FIXME: Since this instruction unwinds, `core` built with `-C panic=unwind`
195+
// cannot be linked with `-C panic=abort` programs. But that's not
196+
// entirely supported anyway, because runtimes without EH support won't
197+
// be able to handle `try` blocks in `-C panic=unwind` crates either.
198+
// We ship `-C panic=abort` `core`, so this doesn't affect users
199+
// directly. Resolving this will likely require patching out both `try`
200+
// and `throw` instructions, at which point we can look into whitelisting
201+
// this function in the compiler to allow linking.
202+
// See https://github.com/rust-lang/rust/issues/118168.
203+
#[allow(ffi_unwind_calls)]
194204
pub unsafe fn throw<const TAG: i32>(ptr: *mut u8) -> ! {
195205
static_assert!(TAG == 0); // LLVM only supports tag 0 == C++ right now.
196206
wasm_throw(TAG, ptr)

0 commit comments

Comments
 (0)