1 // RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
2 // RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -ftls-model=global-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
3 // RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -ftls-model=local-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LD
4 // RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -ftls-model=initial-exec -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-IE
5 // RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -ftls-model=local-exec -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LE
6 //
7 // RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -femulated-tls -emit-llvm -o - 2>&1 | \
8 // RUN: FileCheck %s -check-prefix=CHECK-GD
9
10 int z1 = 0;
11 int z2;
12 int __thread x;
f()13 int f() {
14 static int __thread y;
15 return y++;
16 }
17 int __thread __attribute__((tls_model("initial-exec"))) z;
18
19 // Note that unlike normal C uninitialized global variables,
20 // uninitialized TLS variables do NOT have COMMON linkage.
21
22 // CHECK-GD: @z1 = global i32 0
23 // CHECK-GD: @f.y = internal thread_local global i32 0
24 // CHECK-GD: @z2 = common global i32 0
25 // CHECK-GD: @x = thread_local global i32 0
26 // CHECK-GD: @z = thread_local(initialexec) global i32 0
27
28 // CHECK-LD: @z1 = global i32 0
29 // CHECK-LD: @f.y = internal thread_local(localdynamic) global i32 0
30 // CHECK-LD: @z2 = common global i32 0
31 // CHECK-LD: @x = thread_local(localdynamic) global i32 0
32 // CHECK-LD: @z = thread_local(initialexec) global i32 0
33
34 // CHECK-IE: @z1 = global i32 0
35 // CHECK-IE: @f.y = internal thread_local(initialexec) global i32 0
36 // CHECK-IE: @z2 = common global i32 0
37 // CHECK-IE: @x = thread_local(initialexec) global i32 0
38 // CHECK-IE: @z = thread_local(initialexec) global i32 0
39
40 // CHECK-LE: @z1 = global i32 0
41 // CHECK-LE: @f.y = internal thread_local(localexec) global i32 0
42 // CHECK-LE: @z2 = common global i32 0
43 // CHECK-LE: @x = thread_local(localexec) global i32 0
44 // CHECK-LE: @z = thread_local(initialexec) global i32 0
45