diff --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def b/clang/include/clang/Basic/BuiltinsWebAssembly.def --- a/clang/include/clang/Basic/BuiltinsWebAssembly.def +++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def @@ -38,7 +38,7 @@ // Exception handling builtins. TARGET_BUILTIN(__builtin_wasm_throw, "vIUiv*", "r", "exception-handling") -TARGET_BUILTIN(__builtin_wasm_rethrow_in_catch, "v", "r", "exception-handling") +TARGET_BUILTIN(__builtin_wasm_rethrow, "v", "r", "exception-handling") // Atomic wait and notify. TARGET_BUILTIN(__builtin_wasm_memory_atomic_wait32, "ii*iLLi", "n", "atomics") diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -16583,8 +16583,8 @@ Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_throw); return Builder.CreateCall(Callee, {Tag, Obj}); } - case WebAssembly::BI__builtin_wasm_rethrow_in_catch: { - Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_rethrow_in_catch); + case WebAssembly::BI__builtin_wasm_rethrow: { + Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_rethrow); return Builder.CreateCall(Callee); } case WebAssembly::BI__builtin_wasm_memory_atomic_wait32: { diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -1272,7 +1272,7 @@ assert(RethrowBlock != WasmCatchStartBlock && RethrowBlock->empty()); Builder.SetInsertPoint(RethrowBlock); llvm::Function *RethrowInCatchFn = - CGM.getIntrinsic(llvm::Intrinsic::wasm_rethrow_in_catch); + CGM.getIntrinsic(llvm::Intrinsic::wasm_rethrow); EmitNoreturnRuntimeCallOrInvoke(RethrowInCatchFn, {}); } diff --git a/clang/test/CodeGen/builtins-wasm.c b/clang/test/CodeGen/builtins-wasm.c --- a/clang/test/CodeGen/builtins-wasm.c +++ b/clang/test/CodeGen/builtins-wasm.c @@ -49,10 +49,10 @@ // WEBASSEMBLY64: call void @llvm.wasm.throw(i32 0, i8* %{{.*}}) } -void rethrow_in_catch(void) { - return __builtin_wasm_rethrow_in_catch(); - // WEBASSEMBLY32: call void @llvm.wasm.rethrow.in.catch() - // WEBASSEMBLY64: call void @llvm.wasm.rethrow.in.catch() +void rethrow(void) { + return __builtin_wasm_rethrow(); + // WEBASSEMBLY32: call void @llvm.wasm.rethrow() + // WEBASSEMBLY64: call void @llvm.wasm.rethrow() } int memory_atomic_wait32(int *addr, int expected, long long timeout) { diff --git a/clang/test/CodeGenCXX/wasm-eh.cpp b/clang/test/CodeGenCXX/wasm-eh.cpp --- a/clang/test/CodeGenCXX/wasm-eh.cpp +++ b/clang/test/CodeGenCXX/wasm-eh.cpp @@ -63,7 +63,7 @@ // CHECK-NEXT: br label %[[TRY_CONT_BB]] // CHECK: [[RETHROW_BB]]: -// CHECK-NEXT: call void @llvm.wasm.rethrow.in.catch() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ] +// CHECK-NEXT: call void @llvm.wasm.rethrow() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ] // CHECK-NEXT: unreachable // Single catch-all @@ -233,7 +233,7 @@ // CHECK: catchret from %[[CATCHPAD]] to label %{{.*}} // CHECK: [[RETHROW_BB]]: -// CHECK-NEXT: invoke void @llvm.wasm.rethrow.in.catch() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ] +// CHECK-NEXT: invoke void @llvm.wasm.rethrow() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ] // CHECK-NEXT: to label %[[UNREACHABLE_BB:.*]] unwind label %[[EHCLEANUP_BB1:.*]] // CHECK: [[EHCLEANUP_BB2]]: @@ -297,7 +297,7 @@ // CHECK: catchret from %[[CATCHPAD0]] to label -// CHECK: invoke void @llvm.wasm.rethrow.in.catch() {{.*}} [ "funclet"(token %[[CATCHPAD0]]) ] +// CHECK: invoke void @llvm.wasm.rethrow() {{.*}} [ "funclet"(token %[[CATCHPAD0]]) ] // CHECK: %[[CLEANUPPAD1:.*]] = cleanuppad within %[[CATCHPAD0]] [] // CHECK: cleanupret from %[[CLEANUPPAD1]] unwind label @@ -369,11 +369,11 @@ // CHECK: catchret from %[[CATCHPAD1]] to label -// CHECK: invoke void @llvm.wasm.rethrow.in.catch() {{.*}} [ "funclet"(token %[[CATCHPAD1]]) ] +// CHECK: invoke void @llvm.wasm.rethrow() {{.*}} [ "funclet"(token %[[CATCHPAD1]]) ] // CHECK: catchret from %[[CATCHPAD0]] to label -// CHECK: call void @llvm.wasm.rethrow.in.catch() {{.*}} [ "funclet"(token %[[CATCHPAD0]]) ] +// CHECK: call void @llvm.wasm.rethrow() {{.*}} [ "funclet"(token %[[CATCHPAD0]]) ] // CHECK: unreachable // CHECK: %[[CLEANUPPAD0:.*]] = cleanuppad within %[[CATCHPAD1]] [] diff --git a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td --- a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td +++ b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td @@ -50,9 +50,10 @@ //===----------------------------------------------------------------------===// // throw / rethrow +// The immediate argument is an index to a tag, which is 0 for C++. def int_wasm_throw : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty], [Throws, IntrNoReturn, ImmArg>]>; -def int_wasm_rethrow_in_catch : Intrinsic<[], [], [Throws, IntrNoReturn]>; +def int_wasm_rethrow : Intrinsic<[], [], [Throws, IntrNoReturn]>; // Since wasm does not use landingpad instructions, these instructions return // exception pointer and selector values until we lower them in WasmEHPrepare. diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1637,7 +1637,7 @@ } } -// For wasm, there's alwyas a single catch pad attached to a catchswitch, and +// For wasm, there's always a single catch pad attached to a catchswitch, and // the control flow always stops at the single catch pad, as it does for a // cleanup pad. In case the exception caught is not of the types the catch pad // catches, it will be rethrown by a rethrow. @@ -2785,7 +2785,7 @@ case Intrinsic::experimental_gc_statepoint: LowerStatepoint(cast(I), EHPadBB); break; - case Intrinsic::wasm_rethrow_in_catch: { + 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. @@ -2793,7 +2793,7 @@ Ops.push_back(getRoot()); // inchain const TargetLowering &TLI = DAG.getTargetLoweringInfo(); Ops.push_back( - DAG.getTargetConstant(Intrinsic::wasm_rethrow_in_catch, getCurSDLoc(), + DAG.getTargetConstant(Intrinsic::wasm_rethrow, getCurSDLoc(), TLI.getPointerTy(DAG.getDataLayout()))); SDVTList VTs = DAG.getVTList(ArrayRef({MVT::Other})); // outchain DAG.setRoot(DAG.getNode(ISD::INTRINSIC_VOID, getCurSDLoc(), VTs, Ops)); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -4357,7 +4357,7 @@ F->getIntrinsicID() == Intrinsic::experimental_patchpoint_void || F->getIntrinsicID() == Intrinsic::experimental_patchpoint_i64 || F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint || - F->getIntrinsicID() == Intrinsic::wasm_rethrow_in_catch, + F->getIntrinsicID() == Intrinsic::wasm_rethrow, "Cannot invoke an intrinsic other than donothing, patchpoint, " "statepoint, coro_resume or coro_destroy", &I); diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td @@ -133,10 +133,10 @@ "throw \t$tag", "throw \t$tag", 0x08>; defm RETHROW : I<(outs), (ins EXNREF:$exn), (outs), (ins), [], "rethrow \t$exn", "rethrow", 0x09>; -// Pseudo instruction to be the lowering target of int_wasm_rethrow_in_catch -// intrinsic. Will be converted to the real rethrow instruction later. +// Pseudo instruction to be the lowering target of int_wasm_rethrow intrinsic. +// Will be converted to the real rethrow instruction later. let isPseudo = 1 in -defm RETHROW_IN_CATCH : NRI<(outs), (ins), [(int_wasm_rethrow_in_catch)], +defm RETHROW_IN_CATCH : NRI<(outs), (ins), [(int_wasm_rethrow)], "rethrow_in_catch", 0>; } // isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 diff --git a/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.ll b/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.ll --- a/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.ll +++ b/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.ll @@ -76,7 +76,7 @@ catchret from %1 to label %try.cont rethrow: ; preds = %catch.fallthrough - call void @llvm.wasm.rethrow.in.catch() [ "funclet"(token %1) ] + call void @llvm.wasm.rethrow() [ "funclet"(token %1) ] unreachable try.cont: ; preds = %catch, %catch2, %entry @@ -179,7 +179,7 @@ catchret from %9 to label %try.cont rethrow5: ; preds = %catch.start3 - invoke void @llvm.wasm.rethrow.in.catch() [ "funclet"(token %9) ] + invoke void @llvm.wasm.rethrow() [ "funclet"(token %9) ] to label %unreachable unwind label %ehcleanup9 try.cont: ; preds = %invoke.cont8, %catch @@ -187,7 +187,7 @@ catchret from %1 to label %try.cont11 rethrow: ; preds = %catch.start - call void @llvm.wasm.rethrow.in.catch() [ "funclet"(token %1) ] + call void @llvm.wasm.rethrow() [ "funclet"(token %1) ] unreachable try.cont11: ; preds = %try.cont, %entry @@ -864,7 +864,7 @@ catchret from %1 to label %for.inc rethrow: ; preds = %catch.start - call void @llvm.wasm.rethrow.in.catch() #6 [ "funclet"(token %1) ] + call void @llvm.wasm.rethrow() #6 [ "funclet"(token %1) ] unreachable for.inc: ; preds = %invoke.cont2, %for.body @@ -1093,7 +1093,7 @@ declare i32 @__gxx_wasm_personality_v0(...) declare i8* @llvm.wasm.get.exception(token) declare i32 @llvm.wasm.get.ehselector(token) -declare void @llvm.wasm.rethrow.in.catch() +declare void @llvm.wasm.rethrow() declare i32 @llvm.eh.typeid.for(i8*) declare i8* @__cxa_begin_catch(i8*) declare void @__cxa_end_catch() diff --git a/llvm/test/CodeGen/WebAssembly/exception.ll b/llvm/test/CodeGen/WebAssembly/exception.ll --- a/llvm/test/CodeGen/WebAssembly/exception.ll +++ b/llvm/test/CodeGen/WebAssembly/exception.ll @@ -70,7 +70,7 @@ catchret from %1 to label %try.cont rethrow: ; preds = %catch.start - call void @llvm.wasm.rethrow.in.catch() [ "funclet"(token %1) ] + call void @llvm.wasm.rethrow() [ "funclet"(token %1) ] unreachable try.cont: ; preds = %catch, %entry @@ -258,7 +258,7 @@ catchret from %1 to label %try.cont rethrow: ; preds = %catch.start - call void @llvm.wasm.rethrow.in.catch() [ "funclet"(token %1) ] + call void @llvm.wasm.rethrow() [ "funclet"(token %1) ] unreachable try.cont: ; preds = %invoke.cont1, %entry @@ -368,7 +368,7 @@ declare void @llvm.wasm.throw(i32, i8*) declare i8* @llvm.wasm.get.exception(token) declare i32 @llvm.wasm.get.ehselector(token) -declare void @llvm.wasm.rethrow.in.catch() +declare void @llvm.wasm.rethrow() declare i32 @llvm.eh.typeid.for(i8*) declare i8* @__cxa_begin_catch(i8*) declare void @__cxa_end_catch() diff --git a/llvm/test/CodeGen/WebAssembly/wasmehprepare.ll b/llvm/test/CodeGen/WebAssembly/wasmehprepare.ll --- a/llvm/test/CodeGen/WebAssembly/wasmehprepare.ll +++ b/llvm/test/CodeGen/WebAssembly/wasmehprepare.ll @@ -54,7 +54,7 @@ ; CHECK-NEXT: call i8* @__cxa_begin_catch(i8* %[[EXN]]) rethrow: ; preds = %catch.start - call void @llvm.wasm.rethrow.in.catch() [ "funclet"(token %1) ] + call void @llvm.wasm.rethrow() [ "funclet"(token %1) ] unreachable try.cont: ; preds = %entry, %catch @@ -125,7 +125,7 @@ catchret from %6 to label %try.cont7 rethrow: ; preds = %catch.start3 - call void @llvm.wasm.rethrow.in.catch() [ "funclet"(token %6) ] + call void @llvm.wasm.rethrow() [ "funclet"(token %6) ] unreachable try.cont7: ; preds = %try.cont, %catch4 @@ -189,7 +189,7 @@ catchret from %7 to label %try.cont rethrow5: ; preds = %catch.start3 - invoke void @llvm.wasm.rethrow.in.catch() [ "funclet"(token %7) ] + invoke void @llvm.wasm.rethrow() [ "funclet"(token %7) ] to label %unreachable unwind label %ehcleanup try.cont: ; preds = %catch, %catch6 @@ -197,7 +197,7 @@ catchret from %1 to label %try.cont9 rethrow: ; preds = %catch.start - call void @llvm.wasm.rethrow.in.catch() [ "funclet"(token %1) ] + call void @llvm.wasm.rethrow() [ "funclet"(token %1) ] unreachable try.cont9: ; preds = %entry, %try.cont @@ -274,7 +274,7 @@ catchret from %6 to label %try.cont rethrow: ; preds = %catch.start3 - invoke void @llvm.wasm.rethrow.in.catch() [ "funclet"(token %6) ] + invoke void @llvm.wasm.rethrow() [ "funclet"(token %6) ] to label %unreachable unwind label %ehcleanup try.cont: ; preds = %catch.start, %catch4 @@ -380,7 +380,7 @@ catchret from %14 to label %try.cont rethrow10: ; preds = %catch.start8 - invoke void @llvm.wasm.rethrow.in.catch() [ "funclet"(token %14) ] + invoke void @llvm.wasm.rethrow() [ "funclet"(token %14) ] to label %unreachable unwind label %ehcleanup try.cont: ; preds = %catch.start3, %catch11 @@ -395,7 +395,7 @@ catchret from %1 to label %try.cont19 rethrow: ; preds = %catch.start - call void @llvm.wasm.rethrow.in.catch() [ "funclet"(token %1) ] + call void @llvm.wasm.rethrow() [ "funclet"(token %1) ] unreachable try.cont19: ; preds = %entry, %try.cont16 @@ -604,7 +604,7 @@ declare i32 @llvm.wasm.get.ehselector(token) declare i32 @llvm.eh.typeid.for(i8*) declare void @llvm.wasm.throw(i32, i8*) -declare void @llvm.wasm.rethrow.in.catch() +declare void @llvm.wasm.rethrow() declare i8* @__cxa_begin_catch(i8*) declare void @__cxa_end_catch() declare void @__clang_call_terminate(i8*)