Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / Linux / static_tls.cpp
blob8ef6ba4d44d344df003a653c3fcdb058b0849065
1 // REQUIRES: asan-64-bits
2 // Regression test: __tls_get_addr interceptor must recognize static TLS.
3 //
4 // RUN: %clangxx_asan -DSHARED %s -shared -o %t-so.so -fPIC
5 // RUN: %clangxx_asan %s -ldl -pthread -o %t %t-so.so
6 // RUN: %env_asan_opts=verbosity=2 %run %t 2>&1 | FileCheck %s
8 // CHECK: before
9 // CHECK: __tls_get_addr: static tls
10 // CHECK: after
12 // XFAIL: target=aarch64{{.*}}
13 // binutils 2.26 has a change that causes this test to fail on powerpc64.
14 // UNSUPPORTED: target=powerpc64{{.*}}
16 /// We call __tls_get_addr early in GetTls to work around an issue for glibc<2.25,
17 /// so we don't get a log for f().
18 // REQUIRES: glibc-2.27
20 #ifndef SHARED
21 #include <stdio.h>
23 unsigned *f();
24 int main(int argc, char *argv[]) {
25 fprintf(stderr, "before\n");
26 f();
27 fprintf(stderr, "after\n");
28 return 0;
30 #else // SHARED
31 static __thread unsigned ThreadLocal;
32 unsigned *f() {
33 return &ThreadLocal;
35 #endif