[PATCH] D72399: [Support] Replace Windows __declspec(thread) with thread_local in LLVM_THREAD_LOCAL

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 15 15:15:22 PST 2020


dexonsmith added a comment.

In D72399#1822902 <https://reviews.llvm.org/D72399#1822902>, @rnk wrote:

> In D72399#1821475 <https://reviews.llvm.org/D72399#1821475>, @russell.gallop wrote:
>
> > > Honestly, if `__thread` is available, I wonder if LLVM should prefer that, since it implements the check that the variable is trivially constructible/destructible. But, that has no bearing on which declspec to use.
> >
> > Is "trivially constructible/destructible" actually a requirement for this? I thought that restriction was due to host platforms which didn't support C++11 thread_local (hence if/when every platform supported C++11 thread_local then the restriction would go away).
>
>
> Yes, LLVM still supports platforms which do not support C++11 thread_local, so for LLVM, there is still a requirement that things be trivially constructible/destructible. If we used `__thread` when available, the compiler would enforce that check earlier, rather than letting the contributor commit, push, and find out about this requirement from a buildbot.


IIRC, `__thread` is more efficient than `thread_local` when it's valid, since `thread_local` uses dynamic synchronization even when there are no dynamic initializers.  We should prefer `__thread` when it's available.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72399/new/

https://reviews.llvm.org/D72399





More information about the llvm-commits mailing list