Fix Darwin 'constinit thread_local' variables.
authorJames Y Knight <jyknight@google.com>
Wed, 27 May 2020 13:55:29 +0000 (09:55 -0400)
committerJames Y Knight <jyknight@google.com>
Wed, 27 May 2020 15:59:30 +0000 (11:59 -0400)
commitaca3d067efe194539efd1e0fcf03820a2c377753
tree669b87babb26aa9749360fadb256b50262a26586
parent6022efb0e9cbb350f7b690acd0cfa4b87b1dfe87
Fix Darwin 'constinit thread_local' variables.

Unlike other platforms using ItaniumCXXABI, Darwin does not allow the
creation of a thread-wrapper function for a variable in the TU of
users. Because of this, it can set the linkage of the thread-local
symbol to internal, with the assumption that no TUs other than the one
defining the variable will need it.

However, constinit thread_local variables do not require the use of
the thread-wrapper call, so users reference the variable
directly. Thus, it must not be converted to internal, or users will
get a link failure.

This was a regression introduced by the optimization in
00223827a952f66e7426c9881a2a4229e59bb019.

Differential Revision: https://reviews.llvm.org/D80417
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCXX/cxx2a-thread-local-constinit.cpp