[llvm] [WebAssembly] Make llvm.wasm.throw invokable (PR #128104)
Heejin Ahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 20 18:12:54 PST 2025
================
@@ -3360,16 +3360,28 @@ void SelectionDAGBuilder::visitInvoke(const InvokeInst &I) {
case Intrinsic::experimental_gc_statepoint:
LowerStatepoint(cast<GCStatepointInst>(I), EHPadBB);
break;
+ // wasm_throw, wasm_rethrow: This is usually done in visitTargetIntrinsic,
+ // but this intrinsic is special because it can be invoked, so we manually
+ // lower it to a DAG node here.
+ case Intrinsic::wasm_throw: {
+ const TargetLowering &TLI = DAG.getTargetLoweringInfo();
+ std::array<SDValue, 4> Ops = {
+ getControlRoot(), // inchain for the terminator node
+ DAG.getTargetConstant(Intrinsic::wasm_throw, getCurSDLoc(),
+ TLI.getPointerTy(DAG.getDataLayout())),
+ getValue(I.getArgOperand(0)), // tag
+ getValue(I.getArgOperand(1)) // thrown value
+ };
+ SDVTList VTs = DAG.getVTList(ArrayRef<EVT>({MVT::Other})); // outchain
+ DAG.setRoot(DAG.getNode(ISD::INTRINSIC_VOID, getCurSDLoc(), VTs, Ops));
+ break;
+ }
case Intrinsic::wasm_rethrow: {
- // This is usually done in visitTargetIntrinsic, but this intrinsic is
- // special because it can be invoked, so we manually lower it to a DAG
- // node here.
- SmallVector<SDValue, 8> Ops;
- Ops.push_back(getControlRoot()); // inchain for the terminator node
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
- Ops.push_back(
+ std::array<SDValue, 2> Ops = {
+ getControlRoot(), // inchain for the terminator node
DAG.getTargetConstant(Intrinsic::wasm_rethrow, getCurSDLoc(),
- TLI.getPointerTy(DAG.getDataLayout())));
+ TLI.getPointerTy(DAG.getDataLayout()))};
----------------
aheejin wrote:
This just makes the existing `wasm_rethrow` use `std::array` and NFC
https://github.com/llvm/llvm-project/pull/128104
More information about the llvm-commits
mailing list