diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-07-11 20:28:10 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-07-11 20:28:10 +0000 |
commit | 9b21c33da44985b59e637ee3a235ad1fb3472c60 (patch) | |
tree | 42666061684dd195d1b58270fd21a276fc9288ff /clang/test/CodeGenCXX/tls-init-funcs.cpp | |
parent | 83510e70a9fd0bd2bbe474f510e037937dd6abc7 (diff) | |
download | llvm-9b21c33da44985b59e637ee3a235ad1fb3472c60.zip llvm-9b21c33da44985b59e637ee3a235ad1fb3472c60.tar.gz llvm-9b21c33da44985b59e637ee3a235ad1fb3472c60.tar.bz2 |
CodeGen: Don't emit a thread-wrapper if we can't touch the backing variable
OS X TLS has all accesses going through the thread-wrapper function and
gives the backing thread-local variable internal linkage. This means
that thread-wrappers must have WeakAnyLinkage so that references to the
internal thread-local variables do not get propagated to other code.
It also means that translation units which do not provide a definition
for the thread-local variable cannot attempt to emit a thread-wrapper
because the thread wrapper will attempt to reference the backing
variable.
Differential Revision: http://reviews.llvm.org/D4109
llvm-svn: 212841
Diffstat (limited to 'clang/test/CodeGenCXX/tls-init-funcs.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/tls-init-funcs.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/clang/test/CodeGenCXX/tls-init-funcs.cpp b/clang/test/CodeGenCXX/tls-init-funcs.cpp index 99fe75f7..d47329c 100644 --- a/clang/test/CodeGenCXX/tls-init-funcs.cpp +++ b/clang/test/CodeGenCXX/tls-init-funcs.cpp @@ -1,11 +1,34 @@ -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.8 -std=c++11 -S -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.8 -std=c++1y -S -emit-llvm %s -o - | FileCheck %s // CHECK: @a = internal thread_local global +// CHECK: @_Z2vtIiE = internal thread_local global i32 5 +// CHECK: @_ZZ3inlvE3loc = linkonce_odr thread_local global i32 0 // CHECK: @_tlv_atexit({{.*}}@_ZN1AD1Ev -// CHECK: define weak hidden {{.*}} @_ZTW1a +// CHECK: call i32* @_ZTW3ext() +// CHECK: declare i32* @_ZTW3ext() +// CHECK: define weak i32* @_ZTW2vtIiE() +// CHECK: define weak i32* @_ZTW2vtIvE() +// CHECK: define {{.*}} @_ZTW1a struct A { ~A(); }; thread_local A a; + +extern thread_local int ext; +int &get_ext() { return ext; } + +template <typename T> +thread_local int vt = 5; + +int get_vt() { return vt<int>; } + +inline int &inl() { + thread_local int loc; + return loc; +} +int &use_inl() { return inl(); } + +template int vt<void>; +int &get_vt_void() { return vt<void>; } |