llvm-project/llvm/lib
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
..
Analysis [InstructionSimplify] Apply sext/trunc after pointer stripping 2019-07-16 01:03:06 +00:00
AsmParser ARM MTE stack sanitizer. 2019-07-15 20:02:23 +00:00
BinaryFormat [Object][XCOFF] Add support for 64-bit file header and section header dumping. 2019-07-09 18:09:11 +00:00
Bitcode ARM MTE stack sanitizer. 2019-07-15 20:02:23 +00:00
Bitstream [Bitcode] Move Bitstream to a separate library 2019-07-03 22:40:07 +00:00
CodeGen DWARF: Skip zero column for inline call sites 2019-07-16 21:15:19 +00:00
DebugInfo Teach `llvm-pdbutil pretty -native` about `-injected-sources` 2019-07-16 18:04:26 +00:00
Demangle llvm-undname: Correctly demangle vararg parameters 2019-06-04 19:10:08 +00:00
ExecutionEngine [ORC] Add custom IR compiler configuration to LLJITBuilder to enable obj caches. 2019-07-10 17:24:24 +00:00
FuzzMutate [opaque pointer types] Pass value type to LoadInst creation. 2019-02-01 20:44:24 +00:00
Fuzzer
IR [Remarks] Simplify and refactor the RemarkParser interface 2019-07-16 15:25:05 +00:00
IRReader [IRReader] Expose getLazyIRModule 2019-02-11 22:01:13 +00:00
LTO Open native file handles to avoid converting from FDs, NFC 2019-07-11 20:29:32 +00:00
LineEditor [CMake] Delete redundant DEPENDS/LINK_LIBS from LineEditor/XRay 2019-06-22 01:50:21 +00:00
Linker Reapply: IR: add optional type to 'byval' function parameters 2019-05-30 18:48:23 +00:00
MC [WebAssembly] Assembler: recognize .init_array as data section. 2019-07-15 18:36:07 +00:00
MCA [MCA] Ignore invalid processor resource writes of zero cycles. NFCI 2019-06-14 13:31:21 +00:00
Object [Object] isNotObjectErrorInvalidFileType: simplify 2019-07-13 09:28:33 +00:00
ObjectYAML [yaml2obj] - Allow overriding the sh_size field. 2019-07-11 12:59:29 +00:00
Option Let unaliased Args track which Alias they were created from, and use that in Arg::getAsString() for diagnostics 2019-07-09 00:34:08 +00:00
Passes Revert "[NewPM] Port Sancov" 2019-07-15 23:18:31 +00:00
ProfileData [Profile] Support raw/indexed profiles larger than 4GB 2019-07-09 22:01:04 +00:00
Remarks Fix -Wreturn-type warning. NFC. 2019-07-16 19:59:08 +00:00
Support Fix parameter name comments using clang-tidy. NFC. 2019-07-16 04:46:31 +00:00
TableGen TableGen: Handle nontrivial foreach range bounds 2019-05-22 21:28:20 +00:00
Target [WebAssembly] Implement thread-local storage (local-exec model) 2019-07-16 22:00:45 +00:00
Testing [Testing] Move clangd::Annotations to llvm testing support 2019-04-25 10:08:31 +00:00
TextAPI Cleanup: llvm::bsearch -> llvm::partition_point after r364719 2019-06-30 11:19:56 +00:00
ToolDrivers [llvm-lib] Add a dependency to intrinsics_gen to the LLVMLibDriver build 2019-07-15 18:15:12 +00:00
Transforms [IndVars] Speculative fix for an assertion failure seen in bots 2019-07-16 18:23:49 +00:00
WindowsManifest
XRay Open native file handles to avoid converting from FDs, NFC 2019-07-11 20:29:32 +00:00
CMakeLists.txt Fix build errors LLVM tests are disabled. 2019-07-11 22:08:35 +00:00
LLVMBuild.txt [Bitcode] Move Bitstream to a separate library 2019-07-03 22:40:07 +00:00