r366624 - [WebAssembly] Compute and export TLS block alignment
Guanzhong Chen via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 19 16:34:16 PDT 2019
Author: quantum
Date: Fri Jul 19 16:34:16 2019
New Revision: 366624
URL: http://llvm.org/viewvc/llvm-project?rev=366624&view=rev
Log:
[WebAssembly] Compute and export TLS block alignment
Summary:
Add immutable WASM global `__tls_align` which stores the alignment
requirements of the TLS segment.
Add `__builtin_wasm_tls_align()` intrinsic to get this alignment in Clang.
The expected usage has now changed to:
__wasm_init_tls(memalign(__builtin_wasm_tls_align(),
__builtin_wasm_tls_size()));
Reviewers: tlively, aheejin, sbc100, sunfish, alexcrichton
Reviewed By: tlively
Subscribers: dschuff, jgravelle-google, hiraditya, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D65028
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=366624&r1=366623&r2=366624&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def Fri Jul 19 16:34:16 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_align, "z", "nc", "bulk-memory")
TARGET_BUILTIN(__builtin_wasm_tls_base, "v*", "nU", "bulk-memory")
// Floating point min/max
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=366624&r1=366623&r2=366624&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Jul 19 16:34:16 2019
@@ -13924,6 +13924,11 @@ Value *CodeGenFunction::EmitWebAssemblyB
Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_tls_size, ResultType);
return Builder.CreateCall(Callee);
}
+ case WebAssembly::BI__builtin_wasm_tls_align: {
+ llvm::Type *ResultType = ConvertType(E->getType());
+ Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_tls_align, ResultType);
+ return Builder.CreateCall(Callee);
+ }
case WebAssembly::BI__builtin_wasm_tls_base: {
Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_tls_base);
return Builder.CreateCall(Callee);
Modified: cfe/trunk/test/CodeGen/builtins-wasm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-wasm.c?rev=366624&r1=366623&r2=366624&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtins-wasm.c (original)
+++ cfe/trunk/test/CodeGen/builtins-wasm.c Fri Jul 19 16:34:16 2019
@@ -44,6 +44,12 @@ __SIZE_TYPE__ tls_size() {
// WEBASSEMBLY64: call i64 @llvm.wasm.tls.size.i64()
}
+__SIZE_TYPE__ tls_align() {
+ return __builtin_wasm_tls_align();
+ // WEBASSEMBLY32: call i32 @llvm.wasm.tls.align.i32()
+ // WEBASSEMBLY64: call i64 @llvm.wasm.tls.align.i64()
+}
+
void *tls_base() {
return __builtin_wasm_tls_base();
// WEBASSEMBLY: call i8* @llvm.wasm.tls.base()
More information about the cfe-commits
mailing list