Teach clang to mark thread wrappers for thread_local variables with
hidden visibility when the original variable is marked with hidden
visibility. This is necessary on Darwin which exposes the thread wrapper
instead of the thread variable. The thread wrapper would previously
always be created with default visibility unless it had
linkonce*/weak_odr linkage.
Details
- Reviewers
rjmccall - Commits
- rGc4fa34c39aa7: Merging r351457: --------------------------------------------------------------…
rGc93390b5c54b: TLS: Respect visibility for thread_local variables on Darwin (PR40327)
rL351533: Merging r351457:
rC351457: TLS: Respect visibility for thread_local variables on Darwin (PR40327)
rL351457: TLS: Respect visibility for thread_local variables on Darwin (PR40327)
Diff Detail
- Build Status
Buildable 26944 Build 26943: arc lint + arc unit
Event Timeline
John I took a brief at look at the visibility for templated thread_local variables on Darwin and they looked correct at a glance, though I'm not confident I understand the ABI well enough to understand exactly how the linkonce*/weak_odr case differs between Darwin and other platforms.
(Also includes a fix for a typo I noticed in https://reviews.llvm.org/rC252814)
clang/lib/CodeGen/ItaniumCXXABI.cpp | ||
---|---|---|
2471 | Should we also propagate protected visibility to the wrapper (on non-Darwin targets that support it in the first place)? |
clang/lib/CodeGen/ItaniumCXXABI.cpp | ||
---|---|---|
2471 | isThreadWrapperReplaceable() is only true on Darwin which is why I ignored that possibility. Are you aware of any other platforms that implement an equivalent thread_local ABI? |
clang/lib/CodeGen/ItaniumCXXABI.cpp | ||
---|---|---|
2471 | Or perhaps you meant propagate protected visibility to the wrappers in the non-Darwin isThreadWrapperReplaceable()==false case where they're currently always given hidden visibility? I'm not sure why we would ever pass protected visibility down in that case since hidden should always be preferred, unless we're considering the case of local linkage? |
LGTM.
clang/lib/CodeGen/ItaniumCXXABI.cpp | ||
---|---|---|
2471 | I don't know the thread-local ABIs well enough, it seems. If it's always hidden visibility at best on ELF, it doesn't matter. |
Should we also propagate protected visibility to the wrapper (on non-Darwin targets that support it in the first place)?