Improve code generation for thread_local variables:
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 12 Sep 2019 20:00:24 +0000 (20:00 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 12 Sep 2019 20:00:24 +0000 (20:00 +0000)
commit00223827a952f66e7426c9881a2a4229e59bb019
tree7d6bebd7f9e0b0771e5e4be030d10dbaac73311f
parent5806022904bc447525a02cff796c9bbbd02b0444
Improve code generation for thread_local variables:

Summary:
 * Don't bother using a thread wrapper when the variable is known to
   have constant initialization.
 * Emit the thread wrapper as discardable-if-unused in TUs that don't
   contain a definition of the thread_local variable.
 * Don't emit the thread wrapper at all if the thread_local variable
   is unused and discardable; it will be emitted by all TUs that need
   it.

Reviewers: rjmccall, jdoerfert

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D67429

llvm-svn: 371767
clang/include/clang/Basic/Linkage.h
clang/lib/CodeGen/CGCXXABI.h
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/test/CodeGenCXX/cxx11-thread-local.cpp
clang/test/CodeGenCXX/cxx2a-thread-local-constinit.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/tls-init-funcs.cpp
clang/test/CodeGenCXX/windows-on-arm-itanium-thread-local.cpp [moved from clang/test/CodeGen/windows-on-arm-itanium-thread-local.c with 52% similarity]
clang/test/OpenMP/parallel_copyin_codegen.cpp