| Issue |
124710
|
| Summary |
llvm.wasm.throw is inconsistently considered non-unwinding or invocable
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
purplesyringa
|
1. Miscompiled:
```cpp
void loud();
void throw_and_catch(void *ex) {
try {
__builtin_wasm_throw(0, ex);
} catch (...) {
loud();
}
}
```
The generated IR is
```llvm
define hidden void @throw_and_catch(void*)(ptr noundef %ex) {
entry:
%ex.addr = alloca ptr, align 4
store ptr %ex, ptr %ex.addr, align 4
%0 = load ptr, ptr %ex.addr, align 4
call void @llvm.wasm.throw(i32 0, ptr %0)
ret void
}
```
without a catchpad. This is most likely a frontend bug.
https://godbolt.org/z/Po668Yxaz
2. Broken IR:
```cpp
void loud();
void my_throw(void *ex) {
__builtin_wasm_throw(0, ex);
}
void throw_and_catch(void *ex) {
try {
my_throw(ex);
} catch (...) {
loud();
}
}
```
InlinerPass replaces
```llvm
invoke void @my_throw(void*)(ptr noundef %ex)
to label %try.cont unwind label %catch.dispatch
```
(correct, working) with
```llvm
invoke void @llvm.wasm.throw(i32 0, ptr %ex)
to label %.noexc unwind label %catch.dispatch
```
(broken, `llvm.wasm.throw` cannot be invoked), which halts the backend.
https://godbolt.org/z/rMEd1x79z
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs