Clang generates wasm.get.exception and wasm.get.ehselector
intrinsics, which respectively return a caught exception value (a
pointer to some C++ exception struct) and a selector (an integer value
that tells which C++ catch clause the current exception matches, or
does not match any).
WasmEHPrepare is a pass that does some IR-level preparation before
instruction selection. Previously one of things we did in this pass was
to convert wasm.get.exception intrinsic calls to
wasm.extract.exception intrinsics. Their semantics were the same
except wasm.extract.exception did not have a token argument. We
maintained these two separate intrinsics with the same semantics because
instruction selection couldn't handle token arguments. This
wasm.extract.exception intrinsic was later converted to
extract_exception instruction in instruction selection, which was a
pseudo instruction to implement br_on_exn. Because br_on_exn pushed
an extracted value onto the value stack after the end instruction of a
block, but LLVM does not have a way of modeling that kind of behavior,
so this pseudo instruction was used to pull an extracted value out of
thin air, like this:
block $l0 ... br_on_exn $cpp_exception $l0 ... end extract_exception ;; pushes values onto the stack
In the new spec, we don't need this pseudo instruction anymore because
catch itself returns a value and we don't have br_on_exn anymore. In
the spec catch returns multiple values (like br_on_exn), but here we
assume it only returns a single i32, which is sufficient to support C++.
So this renames wasm.get.exception intrinsic to wasm.catch. Because
this CL does not yet contain instruction selection for wasm.catch
intrinsic, all RUN lines in exception.ll, eh-lsda.ll, and
cfg-stackify-eh.ll, and a single RUN line in wasm-eh.cpp (which is an
end-to-end test from C++ source to assembly) fail. So this CL
temporarily disables those RUN lines, and for those test files without
any valid remaining RUN lines, adds a dummy RUN line to make them
pass. These tests will be reenabled in later CLs.
clang-tidy: warning: namespace 'WebAssembly' not terminated with a closing comment [llvm-namespace-comment]
not useful