[all-commits] [llvm/llvm-project] 072e2a: [MS] Implement on-demand TLS initialization for Mi...
Maurice Heumann via All-commits
all-commits at lists.llvm.org
Thu Jan 13 21:24:23 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 072e2a7c67b74b8bde35f78ac0b0b13a269380f8
https://github.com/llvm/llvm-project/commit/072e2a7c67b74b8bde35f78ac0b0b13a269380f8
Author: Maurice Heumann <MauriceHeumann at gmail.com>
Date: 2022-01-13 (Thu, 13 Jan 2022)
Changed paths:
M clang/include/clang/Basic/LangOptions.h
M clang/lib/CodeGen/CGCXXABI.cpp
M clang/lib/CodeGen/CGCXXABI.h
M clang/lib/CodeGen/ItaniumCXXABI.cpp
M clang/lib/CodeGen/MicrosoftCXXABI.cpp
M clang/test/CodeGenCXX/ms-thread_local.cpp
Log Message:
-----------
[MS] Implement on-demand TLS initialization for Microsoft CXX ABI
TLS initializers, for example constructors of thread-local variables, don't necessarily get called. If a thread was created before a module is loaded, the module's TLS initializers are not executed for this particular thread.
This is why Microsoft added support for dynamic TLS initialization. Before every use of thread-local variables, a check is added that runs the module's TLS initializers on-demand.
To do this, the method `__dyn_tls_on_demand_init` gets called. Internally, it simply calls `__dyn_tls_init`.
No additional TLS initializer that sets the guard needs to be emitted, as the guard always gets set by `__dyn_tls_init`.
The guard is also checked again within `__dyn_tls_init`. This makes our check redundant, however, as Microsoft's compiler also emits this check, the behaviour is adopted here.
Reviewed By: majnemer
Differential Revision: https://reviews.llvm.org/D115456
More information about the All-commits
mailing list