Go to file
Guanzhong Chen 0a8d4df799 [WebAssembly] Compile all TLS on Emscripten as local-exec
Summary:
Currently, on Emscripten, dynamic linking is not supported with threads.
This means that if thread-local storage is used, it must be used in a
statically-linked executable. Hence, local-exec is the only possible model.

This diff compiles all TLS variables to use local-exec on Emscripten as a
temporary measure until dynamic linking is supported with threads.

The goal for this is to allow C++ types with constructors to be thread-local.

Currently, when `clang` compiles a `thread_local` variable with a constructor,
it generates `__tls_guard` variable:

    @__tls_guard = internal thread_local global i8 0, align 1

As no TLS model is specified, this is treated as general-dynamic, which we do
not support (and cannot support without implementing dynamic linking support
with threads in Emscripten). As a result, any C++ constructor in `thread_local`
variables would not compile.

By compiling all `thread_local` as local-exec, `__tls_guard` will compile and
we can support C++ constructors with TLS without implementing dynamic linking
with threads.

Depends on D64537

Reviewers: tlively, aheejin, sbc100

Reviewed By: aheejin

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

Tags: #llvm

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

llvm-svn: 366275
2019-07-16 22:22:08 +00:00
clang [WebAssembly] Implement thread-local storage (local-exec model) 2019-07-16 22:00:45 +00:00
clang-tools-extra [clang-tidy] initial version of readability-convert-member-functions-to-static 2019-07-16 21:19:00 +00:00
compiler-rt [TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.6 2019-07-16 20:41:04 +00:00
debuginfo-tests Make nrvo-string test more robust. 2019-06-27 20:38:37 +00:00
libclc travis: Add LLVM-8 build 2019-03-27 21:28:31 +00:00
libcxx [libcxx] Rejigger test for destroying delete feature-test macros 2019-07-16 21:13:40 +00:00
libcxxabi [libcxxabi] Don't process exceptions in cxa_handlers when they're disabled 2019-07-12 19:10:59 +00:00
libunwind [libunwind] Fix Unwind-EHABI.cpp:getByte on big-endian targets 2019-07-09 15:29:06 +00:00
lld Add REQUIRES: x86 to safeseh-no.s test for x86 2019-07-16 22:01:30 +00:00
lldb [Symbol] Remove unused fields from ClangASTContext 2019-07-16 21:05:08 +00:00
llgo IR: Support parsing numeric block ids, and emit them in textual output. 2019-03-22 18:27:13 +00:00
llvm [WebAssembly] Compile all TLS on Emscripten as local-exec 2019-07-16 22:22:08 +00:00
openmp [OpenMP] Move header inclusion out of 'extern "C"' 2019-07-16 17:16:43 +00:00
parallel-libs Fix typos throughout the license files that somehow I and my reviewers 2019-01-21 09:52:34 +00:00
polly [NFC][ScopBuilder] Move addUserContext to ScopBuilder 2019-07-16 21:29:06 +00:00
pstl [pstl] Use std::transform_reduce instead of hand-rolled implementation 2019-07-16 17:29:09 +00:00
.arcconfig Update monorepo .arcconfig with new project callsign. 2019-01-31 14:34:59 +00:00
.clang-format Add .clang-tidy and .clang-format files to the toplevel of the 2019-01-29 16:43:16 +00:00
.clang-tidy Disable tidy checks with too many hits 2019-02-01 11:20:13 +00:00
.gitignore Add a reduced copy of the llvm .gitignore 2019-04-09 00:52:49 +00:00
README.md

README.md

The LLVM Compiler Infrastructure

This directory and its subdirectories contain source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and runtime environments.