[llvm] [Allocator] Keep bump pointer at a minimum alignment (PR #203718)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 14 13:54:12 PDT 2026
================
@@ -388,7 +400,11 @@ using BumpPtrAllocator = BumpPtrAllocatorImpl<>;
/// This allows calling the destructor in DestroyAll() and when the allocator is
/// destroyed.
template <typename T> class SpecificBumpPtrAllocator {
- BumpPtrAllocator Allocator;
+ // DestroyAll() walks objects at a fixed sizeof(T) stride, so it needs tight
+ // packing: MinAlign=1 disables the default size rounding.
+ using BumpPtrAllocatorTy =
+ BumpPtrAllocatorImpl<MallocAllocator, 4096, 4096, 128, /*MinAlign=*/1>;
----------------
MaskRay wrote:
alignof(T) is indeed better. Switched to `std::min(alignof(T), alignof(std::max_align_t))` since fresh slabs don't provide an alignment larger than `alignof(std::max_align_t)`
https://github.com/llvm/llvm-project/pull/203718
More information about the llvm-commits
mailing list