[Support] Add PerThreadBumpPtrAllocator class.
authorAlexey Lapshin <a.v.lapshin@mail.ru>
Thu, 4 May 2023 09:50:11 +0000 (11:50 +0200)
committerAlexey Lapshin <a.v.lapshin@mail.ru>
Sat, 6 May 2023 12:35:26 +0000 (14:35 +0200)
commit6ab43f9b87ce982fed7073d91da6c5f027321b53
tree02fae6836239adf2f45bd22ec70c4d6063625118
parent7395f6ae784aada24e490b773b2571f08cf39f37
[Support] Add PerThreadBumpPtrAllocator class.

PerThreadBumpPtrAllocator allows separating allocations by thread id.
That makes allocations race free. It is possible because
ThreadPoolExecutor class creates threads, keeps them until
the destructor of ThreadPoolExecutor is called, and assigns ids
to the threads. Thus PerThreadBumpPtrAllocator should be used with only
threads created by ThreadPoolExecutor. This allocator is useful when
thread safe BumpPtrAllocator is needed.

Reviewed By: MaskRay, dexonsmith, andrewng

Differential Revision: https://reviews.llvm.org/D142318
llvm/include/llvm/DWARFLinkerParallel/StringPool.h
llvm/include/llvm/Support/Parallel.h
llvm/include/llvm/Support/PerThreadBumpPtrAllocator.h [new file with mode: 0644]
llvm/lib/Support/Parallel.cpp
llvm/unittests/ADT/ConcurrentHashtableTest.cpp
llvm/unittests/DWARFLinkerParallel/StringPoolTest.cpp
llvm/unittests/DWARFLinkerParallel/StringTableTest.cpp
llvm/unittests/Support/CMakeLists.txt
llvm/unittests/Support/PerThreadBumpPtrAllocatorTest.cpp [new file with mode: 0644]