Skip to content

Commit 884a65a

Browse files
committed
[Support] Replace Windows __declspec(thread) with thread_local for LLVM_THREAD_LOCAL
Windows minimum host tools version is now VS2017, which supports C++11 thread_local so use this for LLVM_THREAD_LOCAL instead of declspec(thread). According to [1], thread_local is implemented with declspec(thread) so this should be NFC. [1] https://docs.microsoft.com/en-us/cpp/cpp/thread?view=vs-2017 Differential Revision: https://reviews.llvm.org/D72399
1 parent 93a4ded commit 884a65a

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

llvm/include/llvm/Support/Compiler.h

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -512,19 +512,15 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
512512
/// extern globals, and static globals.
513513
///
514514
/// This is essentially an extremely restricted analog to C++11's thread_local
515-
/// support, and uses that when available. However, it falls back on
516-
/// platform-specific or vendor-provided extensions when necessary. These
517-
/// extensions don't support many of the C++11 thread_local's features. You
518-
/// should only use this for PODs that you can statically initialize to
519-
/// some constant value. In almost all circumstances this is most appropriate
520-
/// for use with a pointer, integer, or small aggregation of pointers and
521-
/// integers.
515+
/// support. It uses thread_local if available, falling back on gcc __thread
516+
/// if not. __thread doesn't support many of the C++11 thread_local's
517+
/// features. You should only use this for PODs that you can statically
518+
/// initialize to some constant value. In almost all circumstances this is most
519+
/// appropriate for use with a pointer, integer, or small aggregation of
520+
/// pointers and integers.
522521
#if LLVM_ENABLE_THREADS
523-
#if __has_feature(cxx_thread_local)
522+
#if __has_feature(cxx_thread_local) || defined(_MSC_VER)
524523
#define LLVM_THREAD_LOCAL thread_local
525-
#elif defined(_MSC_VER)
526-
// MSVC supports this with a __declspec.
527-
#define LLVM_THREAD_LOCAL __declspec(thread)
528524
#else
529525
// Clang, GCC, and other compatible compilers used __thread prior to C++11 and
530526
// we only need the restricted functionality that provides.

0 commit comments

Comments
 (0)