From f6dda016eefbf589e41a5015a17f03996fdf70bb Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Sat, 16 Sep 2017 01:07:43 +0000 Subject: [PATCH] [WebAssembly] Restore __builtin_wasm_rethrow builtin Summary: Restore the `__builtin_wasm_rethrow` builtin deleted in D37931. On second thought, it appears it can be used to implement `__cxa_rethrow`. Reviewers: dschuff, sunfish Reviewed By: dschuff Subscribers: jfb, sbc100, jgravelle-google Differential Revision: https://reviews.llvm.org/D37942 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@313430 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/BuiltinsWebAssembly.def | 1 + lib/CodeGen/CGBuiltin.cpp | 4 ++++ test/CodeGen/builtins-wasm.c | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/include/clang/Basic/BuiltinsWebAssembly.def b/include/clang/Basic/BuiltinsWebAssembly.def index e9d8ea6325..19318dcebb 100644 --- a/include/clang/Basic/BuiltinsWebAssembly.def +++ b/include/clang/Basic/BuiltinsWebAssembly.def @@ -23,5 +23,6 @@ BUILTIN(__builtin_wasm_grow_memory, "zz", "n") // Exception handling builtins. BUILTIN(__builtin_wasm_throw, "vUiv*", "r") +BUILTIN(__builtin_wasm_rethrow, "v", "r") #undef BUILTIN diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 3e353ea7ec..27403cb30d 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -9613,6 +9613,10 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID, Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_throw); return Builder.CreateCall(Callee, {Tag, Obj}); } + case WebAssembly::BI__builtin_wasm_rethrow: { + Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_rethrow); + return Builder.CreateCall(Callee); + } default: return nullptr; diff --git a/test/CodeGen/builtins-wasm.c b/test/CodeGen/builtins-wasm.c index 2361fdf40c..e0f72d2e50 100644 --- a/test/CodeGen/builtins-wasm.c +++ b/test/CodeGen/builtins-wasm.c @@ -20,3 +20,9 @@ void f3(unsigned int tag, void *obj) { // WEBASSEMBLY32: call void @llvm.wasm.throw(i32 %{{.*}}, i8* %{{.*}}) // WEBASSEMBLY64: call void @llvm.wasm.throw(i32 %{{.*}}, i8* %{{.*}}) } + +void f4() { + return __builtin_wasm_rethrow(); +// WEBASSEMBLY32: call void @llvm.wasm.rethrow() +// WEBASSEMBLY64: call void @llvm.wasm.rethrow() +} -- 2.40.0