[lld] [lld] lld::makeThreadLocal: omit `thread_local` when threads disabled (PR #72057)
Keith Winstein via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 12 09:31:21 PST 2023
https://github.com/keithw created https://github.com/llvm/llvm-project/pull/72057
This PR lets lld be used as a library in single-threaded environments without TLS.
>From 3c34949b4a0c7ec19eac52bd652cd80e9e7b8bfc Mon Sep 17 00:00:00 2001
From: Keith Winstein <keithw at cs.stanford.edu>
Date: Sun, 12 Nov 2023 09:20:11 -0800
Subject: [PATCH] [lld] lld::makeThreadLocal: omit thread_local when threads
disabled
---
lld/include/lld/Common/Memory.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lld/include/lld/Common/Memory.h b/lld/include/lld/Common/Memory.h
index c7612a08c6b00db..23e8737bcc207be 100644
--- a/lld/include/lld/Common/Memory.h
+++ b/lld/include/lld/Common/Memory.h
@@ -65,7 +65,11 @@ template <typename T, typename... U> T *make(U &&... args) {
template <typename T>
inline llvm::SpecificBumpPtrAllocator<T> &
getSpecificAllocSingletonThreadLocal() {
+ #if LLVM_ENABLE_THREADS
thread_local SpecificAlloc<T> instance;
+ #else
+ static SpecificAlloc<T> instance;
+ #endif
return instance.alloc;
}
More information about the llvm-commits
mailing list