r366475 - [WebAssembly] Implement __builtin_wasm_tls_base intrinsic
Guanzhong Chen via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 18 10:53:22 PDT 2019
Author: quantum
Date: Thu Jul 18 10:53:22 2019
New Revision: 366475
URL: http://llvm.org/viewvc/llvm-project?rev=366475&view=rev
Log:
[WebAssembly] Implement __builtin_wasm_tls_base intrinsic
Summary:
Add `__builtin_wasm_tls_base` so that LeakSanitizer can find the thread-local
block and scan through it for memory leaks.
Reviewers: tlively, aheejin, sbc100
Subscribers: dschuff, jgravelle-google, hiraditya, sunfish, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D64900
Modified:
cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins-wasm.c
Modified: cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def?rev=366475&r1=366474&r2=366475&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def Thu Jul 18 10:53:22 2019
@@ -31,6 +31,7 @@ TARGET_BUILTIN(__builtin_wasm_data_drop,
// Thread-local storage
TARGET_BUILTIN(__builtin_wasm_tls_size, "z", "nc", "bulk-memory")
+TARGET_BUILTIN(__builtin_wasm_tls_base, "v*", "n", "bulk-memory")
// Floating point min/max
BUILTIN(__builtin_wasm_min_f32, "fff", "nc")
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=366475&r1=366474&r2=366475&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jul 18 10:53:22 2019
@@ -13924,6 +13924,10 @@ Value *CodeGenFunction::EmitWebAssemblyB
Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_tls_size, ResultType);
return Builder.CreateCall(Callee);
}
+ case WebAssembly::BI__builtin_wasm_tls_base: {
+ Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_tls_base);
+ return Builder.CreateCall(Callee);
+ }
case WebAssembly::BI__builtin_wasm_throw: {
Value *Tag = EmitScalarExpr(E->getArg(0));
Value *Obj = EmitScalarExpr(E->getArg(1));
Modified: cfe/trunk/test/CodeGen/builtins-wasm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-wasm.c?rev=366475&r1=366474&r2=366475&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtins-wasm.c (original)
+++ cfe/trunk/test/CodeGen/builtins-wasm.c Thu Jul 18 10:53:22 2019
@@ -44,6 +44,11 @@ __SIZE_TYPE__ tls_size() {
// WEBASSEMBLY64: call i64 @llvm.wasm.tls.size.i64()
}
+void *tls_base() {
+ return __builtin_wasm_tls_base();
+ // WEBASSEMBLY: call i8* @llvm.wasm.tls.base()
+}
+
void throw(void *obj) {
return __builtin_wasm_throw(0, obj);
// WEBASSEMBLY32: call void @llvm.wasm.throw(i32 0, i8* %{{.*}})
More information about the cfe-commits
mailing list