[all-commits] [llvm/llvm-project] d2d469: [WebAssembly] Make llvm.wasm.throw invokable (#128...
Heejin Ahn via All-commits
all-commits at lists.llvm.org
Tue Feb 25 09:53:23 PST 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d2d469eb7981885eac188bf7988c72d7e85b2d4e
https://github.com/llvm/llvm-project/commit/d2d469eb7981885eac188bf7988c72d7e85b2d4e
Author: Heejin Ahn <aheejin at gmail.com>
Date: 2025-02-25 (Tue, 25 Feb 2025)
Changed paths:
M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
M llvm/lib/CodeGen/WasmEHPrepare.cpp
M llvm/lib/IR/Verifier.cpp
M llvm/test/CodeGen/WebAssembly/exception.ll
M llvm/test/Verifier/invoke.ll
Log Message:
-----------
[WebAssembly] Make llvm.wasm.throw invokable (#128104)
`llvm.wasm.throw` intrinsic can throw but it was not invokable. Not sure
what the rationale was when it was first written that way, but I think
at least in Emscripten's C++ exception support with the Wasm port of
libunwind, `__builtin_wasm_throw`, which is lowered down to
`llvm.wasm.rethrow`, is used only within `_Unwind_RaiseException`, which
is an one-liner and thus does not need an `invoke`:
https://github.com/emscripten-core/emscripten/blob/720e97f76d6f19e0c6a2d6988988cfe23f0517fb/system/lib/libunwind/src/Unwind-wasm.c#L69
(`_Unwind_RaiseException` is called by `__cxa_throw`, which is generated
by the `throw` C++ keyword)
But this does not address other direct uses of the builtin in C++, whose
use I'm not sure about but is not prohibited. Also other language
frontends may need to use the builtin in different functions, which has
`try`-`catch`es or destructors.
This makes `llvm.wasm.throw` invokable in the backend. To do that, this
adds a custom lowering routine to `SelectionDAGBuilder::visitInvoke`,
like we did for `llvm.wasm.rethrow`.
This does not generate `invoke`s for `__builtin_wasm_throw` yet, which
will be done by a follow-up PR.
Addresses #124710.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list