[PATCH] D59352: [WebAssembly] Make rethrow take an except_ref type argument

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 14 03:38:11 PDT 2019


aheejin created this revision.
aheejin added a reviewer: dschuff.
Herald added subscribers: llvm-commits, sunfish, jgravelle-google, sbc100.
Herald added a project: LLVM.

In the new wasm EH proposal, `rethrow` takes an `except_ref` argument.
This change was missing in D57134 <https://reviews.llvm.org/D57134> (r352598).

This patch adds `llvm.wasm.rethrow.in.catch` intrinsic. This is an
intrinsic that's gonna eventually be lowered to wasm `rethrow`
instruction, but this intrinsic can appear only within a catchpad or a
cleanuppad scope. Also this intrinsic needs to be invokable - otherwise
EH pad successor for it will not be correctly generated in clang.

This also adds lowering logic for this intrinsic in
`SelectionDAGBuilder::visitInvoke`. This routine is basically a
specialized and simplified version of
`SelectionDAGBuilder::visitTargetIntrinsic`, but we can't use it
because if is only for `CallInst`s.

This deletes the previous `llvm.wasm.rethrow` intrinsic and related
tests, which was meant to be used within a `__cxa_rethrow` library
function. Turned out this needs some more logic, so the intrinsic for
this purpose will be added later.

LateEHPrepare takes a result value of `catch` and inserts it into
matching `rethrow` as an argument.

`RETHROW_IN_CATCH` is a pseudo instruction that serves as a link between
`llvm.wasm.rethrow.in.catch` and the real wasm `rethrow` instruction. To
generate a `rethrow` instruction, we need an `except_ref` argument,
which is generated from `catch` instruction. But `catch` instrutions are
added in LateEHPrepare pass, so we use `RETHROW_IN_CATCH`, which takes
no argument, until we are able to correctly lower it to `rethrow` in
LateEHPrepare.


Repository:
  rL LLVM

https://reviews.llvm.org/D59352

Files:
  include/llvm/IR/IntrinsicsWebAssembly.td
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  lib/CodeGen/WasmEHPrepare.cpp
  lib/IR/Verifier.cpp
  lib/Target/WebAssembly/WebAssemblyInstrControl.td
  lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
  test/CodeGen/WebAssembly/cfg-stackify-eh.ll
  test/CodeGen/WebAssembly/exception.ll
  test/CodeGen/WebAssembly/wasmehprepare.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59352.190586.patch
Type: text/x-patch
Size: 18888 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190314/ee2d19dc/attachment.bin>


More information about the llvm-commits mailing list