summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-06-05 00:04:33 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-06-05 00:04:33 +0000
commit453b7caaf7f0112a7164cb132db5a39907abf6eb (patch)
tree297385bce7484aae715a795ce0e4ffabe66c07e7 /clang/test/CodeGenCXX
parent577d59bc679d0348ed2f0d6e759fbc728c1f8dbd (diff)
downloadbcm5719-llvm-453b7caaf7f0112a7164cb132db5a39907abf6eb.tar.gz
bcm5719-llvm-453b7caaf7f0112a7164cb132db5a39907abf6eb.zip
PR42111: Use guarded initialization for thread-local variables with
unordered initialization and internal linkage. We'll run their initializers once on each reference, so we need a guard variable even though they only have a single definition. llvm-svn: 362562
Diffstat (limited to 'clang/test/CodeGenCXX')
-rw-r--r--clang/test/CodeGenCXX/cxx1y-variable-template.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/cxx1y-variable-template.cpp b/clang/test/CodeGenCXX/cxx1y-variable-template.cpp
index dd8f28e4299..51d1b54b37a 100644
--- a/clang/test/CodeGenCXX/cxx1y-variable-template.cpp
+++ b/clang/test/CodeGenCXX/cxx1y-variable-template.cpp
@@ -27,4 +27,21 @@ int *p = &n<0>;
// CHECK: @_ZN5OuterIA100_cE5InnerIA20_cE3arrIA3_cEE = linkonce_odr global [123 x i32] zeroinitializer
// CHECK: @_ZGVN5OuterIA100_cE5InnerIA20_cE3arrIA3_cEE = linkonce_odr global
+// CHECK: @_ZTHN7PR4211112_GLOBAL__N_11nILi0EEE = internal alias {{.*}} @[[PR42111_CTOR:.*]]
+
// CHECK: call {{.*}}@_Z8init_arrv
+
+// Ensure that we use guarded initialization for an instantiated thread_local
+// variable with internal linkage.
+namespace PR42111 {
+ int f();
+ namespace { template <int = 0> thread_local int n = f(); }
+ // CHECK: define {{.*}}@[[PR42111_CTOR]](
+ // CHECK: load {{.*}} @_ZGVN7PR4211112_GLOBAL__N_11nILi0EEE
+ // CHECK: icmp eq i8 {{.*}}, 0
+ // CHECK: br i1
+ // CHECK: call i32 @_ZN7PR421111fEv(
+ // CHECK: store i32 {{.*}}, i32* @_ZN7PR4211112_GLOBAL__N_11nILi0EEE
+ // CHECK: store i8 1, i8* @_ZGVN7PR4211112_GLOBAL__N_11nILi0EEE
+ int g() { return n<> + n<>; }
+}
OpenPOWER on IntegriCloud