Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / cxx11-thread-local-reference.cpp
blobcd5a18f39060e88d685bb69926d6ea25745d375b
1 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck --check-prefixes=CHECK,LINUX_AIX %s
2 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple powerpc64-unknown-aix-xcoff | FileCheck --check-prefixes=CHECK,LINUX_AIX %s
3 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-apple-darwin12 | FileCheck --check-prefix=CHECK --check-prefix=DARWIN %s
5 int &f();
7 // LINUX_AIX: @r ={{.*}} thread_local global ptr null
8 // DARWIN: @r = internal thread_local global ptr null
9 thread_local int &r = f();
11 // LINUX_AIX: @_ZTH1r ={{.*}} alias void (), ptr @__tls_init
12 // DARWIN: @_ZTH1r = internal alias void (), ptr @__tls_init
14 int &g() { return r; }
16 // CHECK: define {{.*}} @[[R_INIT:.*]]()
17 // CHECK: call noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_Z1fv()
18 // CHECK: %[[R_ADDR:.+]] = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @r)
19 // CHECK: store ptr %{{.*}}, ptr %[[R_ADDR]], align 8
21 // CHECK-LABEL: define{{.*}} nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_Z1gv()
22 // LINUX_AIX: call ptr @_ZTW1r()
23 // DARWIN: call cxx_fast_tlscc ptr @_ZTW1r()
24 // CHECK: ret ptr %{{.*}}
26 // LINUX_AIX: define weak_odr hidden noundef ptr @_ZTW1r() [[ATTR0:#[0-9]+]]{{( comdat)?}} {
27 // DARWIN: define cxx_fast_tlscc noundef ptr @_ZTW1r() [[ATTR1:#[0-9]+]] {
28 // LINUX_AIX: call void @_ZTH1r()
29 // DARWIN: call cxx_fast_tlscc void @_ZTH1r()
30 // CHECK: %[[R_ADDR2:.+]] = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @r)
31 // CHECK: load ptr, ptr %[[R_ADDR2]], align 8
32 // CHECK: ret ptr %{{.*}}
34 // LINUX_AIX-LABEL: define internal void @__tls_init()
35 // DARWIN-LABEL: define internal cxx_fast_tlscc void @__tls_init()
36 // CHECK: call void @[[R_INIT]]()
38 // LINUX_AIX: attributes [[ATTR0]] = { {{.*}}"target-features"{{.*}} }
39 // DARWIN: attributes [[ATTR1]] = { {{.*}}nounwind{{.*}}"target-features"{{.*}} }