Debian Codegraph @

clang/test/CIR/CodeGen/tls.c

raw
1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2 // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
3 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll
4 // RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
5 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ogcg.ll
6 // RUN: FileCheck --check-prefix=OGCG --input-file=%t.ogcg.ll %s
7
8 extern __thread int b;
9 // CIR: cir.global "private" external tls_dyn @b : !s32i
10
11 __thread int a;
12 // CIR: cir.global external tls_dyn @a = #cir.int<0> : !s32i
13
14 int c(void) { return *&b; }
15 // CIR: cir.func no_inline dso_local @c() -> !s32i
16 // CIR: %[[TLS_ADDR:.*]] = cir.get_global thread_local @b : !cir.ptr<!s32i>
17
18 // LLVM: @b = external thread_local global i32
19 // LLVM: @a = thread_local global i32 0
20
21 // LLVM-LABEL: @c
22 // LLVM: = call ptr @llvm.threadlocal.address.p0(ptr @b)
23
24 // OGCG: @b = external thread_local{{.*}} global i32
25 // OGCG: @a = thread_local{{.*}} global i32 0
26
27 // OGCG-LABEL: define{{.*}} @c
28 // OGCG: call{{.*}} ptr @llvm.threadlocal.address.p0(ptr{{.*}} @b)
29