[clang] [WebAssembly] Generate invokes with llvm.wasm.(re)throw (PR #128105)
Heejin Ahn via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 24 23:56:10 PST 2025
================
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fexceptions -fcxx-exceptions -target-feature +reference-types -target-feature +exception-handling -target-feature +multivalue -exception-model=wasm -emit-llvm -o - %s | FileCheck %s
+
+// Check if __builtin_wasm_throw and __builtin_wasm_rethrow are correctly
+// invoked when placed in try-catch.
+
+void throw_in_try(void *obj) {
+ try {
+ __builtin_wasm_throw(0, obj);
+ } catch (...) {
+ }
+ // CHECK: invoke void @llvm.wasm.throw(i32 0, ptr %{{.*}})
+}
+
+void rethrow_in_try() {
+ try {
+ __builtin_wasm_rethrow();
----------------
aheejin wrote:
This code actually does not make sense because this call is not within a `catch`, but this test only has the purpose of checking whether `invoke` is generated and does not go through the backend, so it should be fine
(As I said in the PR description, we don't use this builtin for our C++ implementation, but I didn't remove this because other people might want to use it)
https://github.com/llvm/llvm-project/pull/128105
More information about the cfe-commits
mailing list