[lld] [lld] lld::makeThreadLocal: omit `thread_local` when threads disabled (PR #72057)

Keith Winstein via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 13 18:41:29 PST 2023


https://github.com/keithw updated https://github.com/llvm/llvm-project/pull/72057

>From d6ad22add196fe4d6e9bc9182cfb6705faa3721d Mon Sep 17 00:00:00 2001
From: Yuhan Deng <yhdeng at stanford.edu>
Date: Thu, 2 Feb 2023 14:16:14 -0800
Subject: [PATCH] [lld] lld::makeThreadLocal: omit thread_local when threads
 disabled

Co-authored-by: Keith Winstein <keithw at cs.stanford.edu>
---
 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..412fe88da03cff8 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