File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -36,19 +36,27 @@ class String {
3636 std::array<char , 0x20 > ExtraData;
3737};
3838
39- static thread_local BumpPtrAllocator ThreadLocalAllocator;
39+ static LLVM_THREAD_LOCAL BumpPtrAllocator * ThreadLocalAllocator = nullptr ;
4040class PerThreadAllocator : public AllocatorBase <PerThreadAllocator> {
4141public:
4242 inline LLVM_ATTRIBUTE_RETURNS_NONNULL void *Allocate (size_t Size,
4343 size_t Alignment) {
44- return ThreadLocalAllocator. Allocate (Size, Align (Alignment));
44+ return getAllocatorPtr ()-> Allocate (Size, Align (Alignment));
4545 }
46- inline size_t getBytesAllocated () const {
47- return ThreadLocalAllocator. getBytesAllocated ();
46+ inline size_t getBytesAllocated () {
47+ return getAllocatorPtr ()-> getBytesAllocated ();
4848 }
4949
5050 // Pull in base class overloads.
5151 using AllocatorBase<PerThreadAllocator>::Allocate;
52+
53+ protected:
54+ BumpPtrAllocator *getAllocatorPtr () {
55+ if (ThreadLocalAllocator == nullptr )
56+ ThreadLocalAllocator = new BumpPtrAllocator ();
57+
58+ return ThreadLocalAllocator;
59+ }
5260} Allocator;
5361
5462TEST (ConcurrentHashTableTest, AddStringEntries) {
You can’t perform that action at this time.
0 commit comments