]> granicus.if.org Git - clang/commitdiff
[WebAssembly] Restore __builtin_wasm_rethrow builtin
authorHeejin Ahn <aheejin@gmail.com>
Sat, 16 Sep 2017 01:07:43 +0000 (01:07 +0000)
committerHeejin Ahn <aheejin@gmail.com>
Sat, 16 Sep 2017 01:07:43 +0000 (01:07 +0000)
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
lib/CodeGen/CGBuiltin.cpp
test/CodeGen/builtins-wasm.c

index e9d8ea63256536093850017161cc1963f88f63a4..19318dcebb9ec2f6f76436da021ee215c6882892 100644 (file)
@@ -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
index 3e353ea7eca6318a6de065b57faebb8df3fc4952..27403cb30d1353dd2173ab853d3d99134d0f4880 100644 (file)
@@ -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;
index 2361fdf40ce39873aa056d9d65cf84d9fb26ea3b..e0f72d2e503417517fec56432486aa276cfd0912 100644 (file)
@@ -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()
+}