[WebAssembly] Support instruction selection for catching exceptions

Authored by aheejin on May 31 2018, 3:25 PM.


[WebAssembly] Support instruction selection for catching exceptions

This lowers exception catching-related instructions:

  1. Lowers wasm.catch intrinsic to catch instruction
  2. Removes catchpad and cleanuppad instructions; they are not

necessary after isel phase. (MachineBasicBlock::isEHFuncletEntry() or
MachineBasicBlock::isEHPad() can be used instead.)

  1. Lowers catchret and cleanupret instructions to pseudo catchret

and cleanupret instructions in isel, which will be replaced with other
instructions in WebAssemblyExceptionPrepare pass.

  1. Adds 'WebAssemblyExceptionPrepare` pass, which is for running various

transformation for EH. Currently this pass only replaces catchret and
cleanupret instructions into appropriate wasm instructions to make
this patch successfully run until the end.

Currently this does not handle lowering of intrinsics related to LSDA
info generation (wasm.landingpad.index and wasm.lsda), because they
cannot be tested without implementing EHStreamer's wasm-specific
handlers. They are marked as TODO, which is needed to make isel pass.
Also this does not generate try and end_try markers yet, which will
be handled in later patches.

This patch is based on the first wasm EH proposal.

Reviewers: dschuff, majnemer

Subscribers: jfb, sbc100, jgravelle-google, sunfish, llvm-commits

Differential Revision: https://reviews.llvm.org/D44090

llvm-svn: 333705