Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / gcc / testsuite / g++.dg / tls / thread_local-cse.C
1 // Test for CSE of the wrapper function: we should only call it once
2 // for the two references to ir.
3 // { dg-do run }
4 // { dg-options "-std=c++11 -O -fno-inline -save-temps" }
5 // { dg-add-options tls }
6 // { dg-require-effective-target tls_runtime }
7 // { dg-final { scan-assembler-times "call *_ZTW2ir" 1 { xfail *-*-* } } }
8 // { dg-final cleanup-saved-temps }
9
10 // XFAILed until the back end supports a way to mark a function as cseable
11 // though not pure.
12
13 int f() { return 42; }
14
15 thread_local int ir = f();
16
17 int main()
18 {
19   return ir + ir - 84;
20 }