Even though `__builtin_wasm_throw`, which is lowered down to
`llvm.wasm.throw`, throws,
```cpp
try {
__builtin_wasm_throw(0, obj);
} catch (...) {
}
```
does not generate `invoke`. This is because we have assumed the
intrinsic cannot be invoked, which doesn't make much sense. (See #128104
for the historical context)
#128104 made `llvm.wasm.throw` intrinsic invokable in the backend. This
actually generates `invoke`s in Clang for `__builtin_wasm_throw`.
While we're at it, this also generates `invoke`s for
`__builtin_wasm_rethrow`, which is actually not used anywhere in C++
support. I haven't deleted it just in case in may have uses later. (For
example, to support rethrow functionality that carries stack trace with
exnref)
Depends on #128104 for the CI to pass.
Fixes #124710.
21 lines
634 B
C++
21 lines
634 B
C++
// 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();
|
|
} catch (...) {
|
|
}
|
|
// CHECK: invoke void @llvm.wasm.rethrow()
|
|
}
|