1 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.8 -std=c++1y -S -emit-llvm %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-windows-gnu -std=c++1y -S -emit-llvm %s -o - | FileCheck %s --check-prefix=MINGW
3
4 // CHECK: @a = internal thread_local global
5 // CHECK: @_Z2vtIiE = linkonce_odr thread_local global i32 5
6 // CHECK: @_ZZ3inlvE3loc = linkonce_odr thread_local global i32 0
7 // CHECK: @_tlv_atexit({{.*}}@_ZN1AD1Ev
8 // CHECK: call cxx_fast_tlscc i32* @_ZTW3ext()
9 // CHECK: declare cxx_fast_tlscc i32* @_ZTW3ext()
10 // CHECK-DAG: define weak_odr hidden cxx_fast_tlscc i32* @_ZTW2vtIiE()
11 // CHECK-DAG: define weak_odr hidden cxx_fast_tlscc i32* @_ZTW2vtIvE()
12 // CHECK-DAG: define {{.*}} @_ZTW1a
13
14 // MINGW-DAG: define weak_odr hidden i32* @_ZTW2vtIiE() {{.*}} comdat
15 // MINGW-DAG: define weak_odr hidden i32* @_ZTW2vtIvE() {{.*}} comdat
16
17 struct A {
18 ~A();
19 };
20
21 thread_local A a;
22
23 extern thread_local int ext;
get_ext()24 int &get_ext() { return ext; }
25
26 template <typename T>
27 thread_local int vt = 5;
28
get_vt()29 int get_vt() { return vt<int>; }
30
inl()31 inline int &inl() {
32 thread_local int loc;
33 return loc;
34 }
use_inl()35 int &use_inl() { return inl(); }
36
37 template int vt<void>;
get_vt_void()38 int &get_vt_void() { return vt<void>; }
39