[llvm-branch-commits] [llvm] release/23.x: [Allocator] Cap MinAlign at alignof(max_align_t) (#235373) (PR #235386)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sat Oct 24 20:39:28 PDT 2026
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/235386
Backport 0b6b6ed806536c1b170101061ff3eeed91c8f061
Requested by: @MaskRay
>From a84dddef035e884100f0a4b2d029fb28094d083e Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Sat, 24 Oct 2026 20:09:10 -0700
Subject: [PATCH] [Allocator] Cap MinAlign at alignof(max_align_t) (#235373)
alignof(std::max_align_t) is 4 on NetBSD/i386, whose <stddef.h> defines
max_align_t as a union of void *, long double, and long long.
Fix #230782
(cherry picked from commit 0b6b6ed806536c1b170101061ff3eeed91c8f061)
---
llvm/include/llvm/Support/Allocator.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/include/llvm/Support/Allocator.h b/llvm/include/llvm/Support/Allocator.h
index bb0ca118e20157..b5f40ef72cd718 100644
--- a/llvm/include/llvm/Support/Allocator.h
+++ b/llvm/include/llvm/Support/Allocator.h
@@ -64,7 +64,7 @@ LLVM_ABI void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t TotalMemory);
/// CurPtr when the requested alignment is no greater than MinAlign.
template <typename AllocatorT = MallocAllocator, size_t SlabSize = 4096,
size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128,
- size_t MinAlign = 8>
+ size_t MinAlign = std::min<size_t>(8, alignof(std::max_align_t))>
class BumpPtrAllocatorImpl
: public AllocatorBase<BumpPtrAllocatorImpl<
AllocatorT, SlabSize, SizeThreshold, GrowthDelay, MinAlign>>,
More information about the llvm-branch-commits
mailing list