[ELF] Make SyntheticSection parameter order match InputSection
[llvm-project.git] / clang / test / CodeGen / tls-model.cpp
blobf8b9ba465ac855f4b48966f6983eeff9350f4bf4
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
10 int z1 = 0;
11 int z2;
12 int __thread x;
13 int f() {
14 static int __thread y;
15 return y++;
17 int __thread __attribute__((tls_model("initial-exec"))) z;
19 struct S {
20 S();
21 ~S();
23 struct T {
24 ~T();
27 struct S thread_local s1;
28 struct T thread_local t1;
30 // Note that unlike normal C uninitialized global variables,
31 // uninitialized TLS variables do NOT have COMMON linkage.
33 // CHECK-GD: @z1 ={{.*}} global i32 0
34 // CHECK-GD: @z2 ={{.*}} global i32 0
35 // CHECK-GD: @x ={{.*}} thread_local global i32 0
36 // CHECK-GD: @_ZZ1fvE1y = internal thread_local global i32 0
37 // CHECK-GD: @z ={{.*}} thread_local(initialexec) global i32 0
38 // CHECK-GD: @s1 ={{.*}} thread_local global %struct.S zeroinitializer
39 // CHECK-GD: @t1 ={{.*}} thread_local global %struct.T zeroinitializer
40 // CHECK-GD: @__tls_guard = internal thread_local global i8 0
42 // CHECK-LD: @z1 ={{.*}} global i32 0
43 // CHECK-LD: @z2 ={{.*}} global i32 0
44 // CHECK-LD: @x ={{.*}} thread_local(localdynamic) global i32 0
45 // CHECK-LD: @_ZZ1fvE1y = internal thread_local(localdynamic) global i32 0
46 // CHECK-LD: @z ={{.*}} thread_local(initialexec) global i32 0
47 // CHECK-LD: @s1 ={{.*}} thread_local(localdynamic) global %struct.S zeroinitializer
48 // CHECK-LD: @t1 ={{.*}} thread_local(localdynamic) global %struct.T zeroinitializer
49 // CHECK-LD: @__tls_guard = internal thread_local(localdynamic) global i8 0
51 // CHECK-IE: @z1 ={{.*}} global i32 0
52 // CHECK-IE: @z2 ={{.*}} global i32 0
53 // CHECK-IE: @x ={{.*}} thread_local(initialexec) global i32 0
54 // CHECK-IE: @_ZZ1fvE1y = internal thread_local(initialexec) global i32 0
55 // CHECK-IE: @z ={{.*}} thread_local(initialexec) global i32 0
56 // CHECK-IE: @s1 ={{.*}} thread_local(initialexec) global %struct.S zeroinitializer
57 // CHECK-IE: @t1 ={{.*}} thread_local(initialexec) global %struct.T zeroinitializer
58 // CHECK-IE: @__tls_guard = internal thread_local(initialexec) global i8 0
60 // CHECK-LE: @z1 ={{.*}} global i32 0
61 // CHECK-LE: @z2 ={{.*}} global i32 0
62 // CHECK-LE: @x ={{.*}} thread_local(localexec) global i32 0
63 // CHECK-LE: @_ZZ1fvE1y = internal thread_local(localexec) global i32 0
64 // CHECK-LE: @z ={{.*}} thread_local(initialexec) global i32 0
65 // CHECK-LE: @s1 ={{.*}} thread_local(localexec) global %struct.S zeroinitializer
66 // CHECK-LE: @t1 ={{.*}} thread_local(localexec) global %struct.T zeroinitializer
67 // CHECK-LE: @__tls_guard = internal thread_local(localexec) global i8 0