comparison clang/test/CodeGen/tls-model.cpp @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents
children
comparison
equal deleted inserted replaced
173:0572611fdcc8 207:2e18cbf3894f
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;
13 int f() {
14 static int __thread y;
15 return y++;
16 }
17 int __thread __attribute__((tls_model("initial-exec"))) z;
18
19 struct S {
20 S();
21 ~S();
22 };
23 struct T {
24 ~T();
25 };
26
27 struct S thread_local s1;
28 struct T thread_local t1;
29
30 // Note that unlike normal C uninitialized global variables,
31 // uninitialized TLS variables do NOT have COMMON linkage.
32
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
41
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
50
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
59
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