llvm-project/clang/test
Guanzhong Chen 42bba4b852 [WebAssembly] Implement thread-local storage (local-exec model)
Summary:
Thread local variables are placed inside a `.tdata` segment. Their symbols are
offsets from the start of the segment. The address of a thread local variable
is computed as `__tls_base` + the offset from the start of the segment.

`.tdata` segment is a passive segment and `memory.init` is used once per thread
to initialize the thread local storage.

`__tls_base` is a wasm global. Since each thread has its own wasm instance,
it is effectively thread local. Currently, `__tls_base` must be initialized
at thread startup, and so cannot be used with dynamic libraries.

`__tls_base` is to be initialized with a new linker-synthesized function,
`__wasm_init_tls`, which takes as an argument a block of memory to use as the
storage for thread locals. It then initializes the block of memory and sets
`__tls_base`. As `__wasm_init_tls` will handle the memory initialization,
the memory does not have to be zeroed.

To help allocating memory for thread-local storage, a new compiler intrinsic
is introduced: `__builtin_wasm_tls_size()`. This instrinsic function returns
the size of the thread-local storage for the current function.

The expected usage is to run something like the following upon thread startup:

    __wasm_init_tls(malloc(__builtin_wasm_tls_size()));

Reviewers: tlively, aheejin, kripken, sbc100

Subscribers: dschuff, jgravelle-google, hiraditya, sunfish, jfb, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D64537

llvm-svn: 366272
2019-07-16 22:00:45 +00:00
..
ARCMT
AST Dump actual line numbers when dumping the AST to JSON. 2019-07-12 16:53:57 +00:00
ASTMerge [ASTImporter] Store import errors for Decls 2019-06-25 08:00:51 +00:00
Analysis [OPENMP]Add support for analysis of if clauses. 2019-07-16 14:51:46 +00:00
CXX [Concepts] Concept definitions (D40381) 2019-07-10 21:25:49 +00:00
ClangScanDeps [clang-scan-deps] use `-Wno-error` when scanning for dependencies 2019-07-03 18:01:32 +00:00
CodeCompletion Re-land "[CodeComplete] Improve overload handling for C++ qualified and ref-qualified methods." 2019-06-10 15:17:52 +00:00
CodeGen [WebAssembly] Implement thread-local storage (local-exec model) 2019-07-16 22:00:45 +00:00
CodeGenCUDA [clang] Preserve names of addrspacecast'ed values. 2019-07-10 17:10:05 +00:00
CodeGenCXX CodeGet: Init 32bit pointers with 0xFFFFFFFF 2019-07-12 17:21:55 +00:00
CodeGenCoroutines
CodeGenObjC [Sema] Diagnose default-initialization, destruction, and copying of 2019-07-13 01:47:15 +00:00
CodeGenObjCXX [clang][NewPM] Add -fno-experimental-new-pass-manager to tests 2019-06-21 16:03:06 +00:00
CodeGenOpenCL [OpenCL] Fixing sampler initialisations for C++ mode. 2019-07-16 14:57:32 +00:00
CodeGenOpenCLCXX [OpenCL][PR41727] Prevent ICE on global dtors 2019-07-15 11:58:10 +00:00
Coverage Re-check in clang support gun asm goto after fixing tests. 2019-06-03 15:57:25 +00:00
CoverageMapping Fix clang tests broken by r353547 that depend on InstrProf 2019-02-10 20:17:07 +00:00
Driver [Driver] Don't pass --dynamic-linker to ld on Solaris 2019-07-16 11:06:43 +00:00
FixIt [c++20] P0780R2: Support pack-expansion of init-captures. 2019-05-21 20:10:50 +00:00
Format [clang-format][tests] Explicitly specify style in some tests 2019-07-12 15:56:18 +00:00
Frontend [clang][NewPM] Fixing remaining -O0 tests that are broken under new PM 2019-06-19 17:41:30 +00:00
Headers XFAIL clang/test/Headers/max_align.c on i686 2019-07-09 21:06:34 +00:00
Import [ASTImporter] Copy Argument Passing Restrictions setting when importing a CXXRecordDecl definition 2019-04-26 18:51:28 +00:00
Index This reverts commit 632a36bfcfc8273c1861f04ff6758d863c47c784. 2019-07-13 06:27:35 +00:00
Integration
InterfaceStubs [NFC] Fix for InterfaceStubs tests (adding REQUIRES: x86-registered-target). 2019-06-20 18:28:21 +00:00
Layout P0840R2: support for [[no_unique_address]] attribute 2019-06-20 20:44:45 +00:00
Lexer ARM MTE stack sanitizer. 2019-07-15 20:02:23 +00:00
Misc [SystemZ] Add support for new cpu architecture - arch13 2019-07-12 18:14:51 +00:00
Modules [Driver] Add float-divide-by-zero back to supported sanitizers after D63793/rC365272 2019-07-10 00:30:02 +00:00
OpenMP [OPENMP]Add support for analysis of if clauses. 2019-07-16 14:51:46 +00:00
PCH [Sema] Diagnose default-initialization, destruction, and copying of 2019-07-13 01:47:15 +00:00
Parser [Concepts] Concept definitions (D40381) 2019-07-10 21:25:49 +00:00
Preprocessor Change a lit test to permit vendor specific clang version 2019-07-16 02:05:52 +00:00
Profile Revert "[clang][NewPM] Fix broken profile test" 2019-06-29 00:10:22 +00:00
Refactor
Rewriter
Sema fix unnamed fiefield issue and add tests for __builtin_preserve_access_index intrinsic 2019-07-16 17:24:33 +00:00
SemaCUDA [HIP] Support attribute hip_pinned_shadow 2019-06-26 03:47:37 +00:00
SemaCXX ARM MTE stack sanitizer. 2019-07-15 20:02:23 +00:00
SemaObjC [Sema] Diagnose default-initialization, destruction, and copying of 2019-07-13 01:47:15 +00:00
SemaObjCXX If capturing a variable fails, add a capture anyway (and mark it 2019-05-28 23:09:44 +00:00
SemaOpenCL AMDGPU: Add DS GWS sema builtins 2019-06-20 21:33:57 +00:00
SemaOpenCLCXX [OpenCL] Deduce addr space for pointee of dependent types in instantiation. 2019-07-15 13:02:21 +00:00
SemaTemplate [SemaTemplate] Fix uncorrected typos after pack expansion 2019-07-16 10:30:21 +00:00
TableGen
Templight
Tooling Recommit r363298 "[lit] Disable test on darwin when building shared libs." 2019-06-15 20:09:54 +00:00
Unit [lit] Set shlibpath_var on AIX 2019-03-29 23:33:04 +00:00
VFS
clang-rename
.clang-format
CMakeLists.txt Fix breakage introduced by D60974 2019-07-01 21:57:31 +00:00
TestRunner.sh
cxx-sections.data
lit.cfg.py Fix a Python3 compatibility error 2019-07-11 21:45:48 +00:00
lit.site.cfg.py.in [clang][NewPM] Fixing remaining -O0 tests that are broken under new PM 2019-06-19 17:41:30 +00:00
make_test_dirs.pl