diff --git a/llvm/unittests/ADT/ConcurrentHashtableTest.cpp b/llvm/unittests/ADT/ConcurrentHashtableTest.cpp index b76ace23120f69..8138633bc6de92 100644 --- a/llvm/unittests/ADT/ConcurrentHashtableTest.cpp +++ b/llvm/unittests/ADT/ConcurrentHashtableTest.cpp @@ -36,27 +36,19 @@ class String { std::array ExtraData; }; -static LLVM_THREAD_LOCAL BumpPtrAllocator *ThreadLocalAllocator = nullptr; +static thread_local BumpPtrAllocator ThreadLocalAllocator; class PerThreadAllocator : public AllocatorBase { 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::Allocate; - -protected: - BumpPtrAllocator *getAllocatorPtr() { - if (ThreadLocalAllocator == nullptr) - ThreadLocalAllocator = new BumpPtrAllocator(); - - return ThreadLocalAllocator; - } } Allocator; TEST(ConcurrentHashTableTest, AddStringEntries) {