Revert "[ADT][ConcurrentHashTable] Change thread_local to LLVM_THREAD_LOCAL inside...
authorAlexey Lapshin <a.v.lapshin@mail.ru>
Thu, 6 Apr 2023 02:55:26 +0000 (04:55 +0200)
committerAlexey Lapshin <a.v.lapshin@mail.ru>
Thu, 6 Apr 2023 02:55:26 +0000 (04:55 +0200)
This reverts commit 9ef701318b4590e1fa8bb61906d5957d7b1f6a2f.

llvm/unittests/ADT/ConcurrentHashtableTest.cpp

index b76ace2..8138633 100644 (file)
@@ -36,27 +36,19 @@ protected:
   std::array<char, 0x20> ExtraData;
 };
 
-static LLVM_THREAD_LOCAL BumpPtrAllocator *ThreadLocalAllocator = nullptr;
+static thread_local BumpPtrAllocator ThreadLocalAllocator;
 class PerThreadAllocator : public AllocatorBase<PerThreadAllocator> {
 public:
   inline LLVM_ATTRIBUTE_RETURNS_NONNULL void *Allocate(size_t Size,
                                                        size_t Alignment) {
-    return getAllocatorPtr()->Allocate(Size, Align(Alignment));
+    return ThreadLocalAllocator.Allocate(Size, Align(Alignment));
   }
-  inline size_t getBytesAllocated() {
-    return getAllocatorPtr()->getBytesAllocated();
+  inline size_t getBytesAllocated() const {
+    return ThreadLocalAllocator.getBytesAllocated();
   }
 
   // Pull in base class overloads.
   using AllocatorBase<PerThreadAllocator>::Allocate;
-
-protected:
-  BumpPtrAllocator *getAllocatorPtr() {
-    if (ThreadLocalAllocator == nullptr)
-      ThreadLocalAllocator = new BumpPtrAllocator();
-
-    return ThreadLocalAllocator;
-  }
 } Allocator;
 
 TEST(ConcurrentHashTableTest, AddStringEntries) {