]> granicus.if.org Git - clang/commit
MS ABI: Implement thread_local for global variables
authorDavid Majnemer <david.majnemer@gmail.com>
Sun, 5 Oct 2014 05:05:40 +0000 (05:05 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sun, 5 Oct 2014 05:05:40 +0000 (05:05 +0000)
commit6c9b7bc80ace5c3de55dc117a9022a1257ff798e
treed4a5c57b05cfaadc09df531aae4a687e62a00f6b
parentcec1839edae2ca8a0321dde1ccd47009076d8557
MS ABI: Implement thread_local for global variables

Summary:
This add support for the C++11 feature, thread_local global variables.
The ABI Clang implements is an improvement of the MSVC ABI.  Sadly,
further improvements could be made but not without sacrificing ABI
compatibility.

The feature is implemented as follows:
- All thread_local initialization routines are pointed to from the
  .CRT$XDU section.
- All non-weak thread_local variables have their initialization routines
  call from a single function instead of getting their own .CRT$XDU
  section entry.  This is done to open up optimization opportunities to
  the compiler.
- All weak thread_local variables have their own .CRT$XDU section entry.
  This entry is in a COMDAT with the global variable it is initializing;
  this ensures that we will initialize the global exactly once.
- Destructors are registered in the initialization function using
  __tlregdtor.

Differential Revision: http://reviews.llvm.org/D5597

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219074 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGCXXABI.cpp
lib/CodeGen/CGCXXABI.h
lib/CodeGen/CGDeclCXX.cpp
lib/CodeGen/CGExpr.cpp
lib/CodeGen/CodeGenFunction.h
lib/CodeGen/CodeGenModule.h
lib/CodeGen/ItaniumCXXABI.cpp
lib/CodeGen/MicrosoftCXXABI.cpp
test/CodeGenCXX/ms-thread_local.cpp [new file with mode: 0644]