Commit ddc2c9a
committed
[WebAssembly] Make llvm.wasm.throw invokable
`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 a 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.1 parent 7c24041 commit ddc2c9a
File tree
4 files changed
+47
-8
lines changed- llvm
- lib
- CodeGen
- SelectionDAG
- IR
- test/CodeGen/WebAssembly
4 files changed
+47
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3360 | 3360 | | |
3361 | 3361 | | |
3362 | 3362 | | |
| 3363 | + | |
| 3364 | + | |
| 3365 | + | |
| 3366 | + | |
| 3367 | + | |
| 3368 | + | |
| 3369 | + | |
| 3370 | + | |
| 3371 | + | |
| 3372 | + | |
| 3373 | + | |
| 3374 | + | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
| 3378 | + | |
3363 | 3379 | | |
3364 | | - | |
3365 | | - | |
3366 | | - | |
3367 | 3380 | | |
3368 | 3381 | | |
3369 | 3382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
| 204 | + | |
| 205 | + | |
208 | 206 | | |
209 | 207 | | |
210 | 208 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5203 | 5203 | | |
5204 | 5204 | | |
5205 | 5205 | | |
| 5206 | + | |
5206 | 5207 | | |
5207 | 5208 | | |
5208 | 5209 | | |
5209 | | - | |
| 5210 | + | |
| 5211 | + | |
5210 | 5212 | | |
5211 | 5213 | | |
5212 | 5214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
569 | 595 | | |
570 | 596 | | |
571 | 597 | | |
| |||
0 commit comments