From 465ff74aa3cfd8c991f7cd86c0850dae2cd80ca4 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Sun, 19 Nov 2023 22:03:15 -0500 Subject: [PATCH] jitlayers: reduce excess alignment of #52182 (#52210) (cherry picked from commit 72cd63ce28c50c8c72e009df03dfec608802450e) --- src/jitlayers.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/jitlayers.h b/src/jitlayers.h index b5160ba1863e8..f57861fa56794 100644 --- a/src/jitlayers.h +++ b/src/jitlayers.h @@ -312,7 +312,9 @@ class MaxAlignedAllocImpl // the returned pointer, this is >= alignof(std::max_align_t), which is too // small often to actually use. const size_t MaxAlignment = JL_CACHE_BYTE_ALIGNMENT; - return Align(std::min((size_t)llvm::PowerOf2Ceil(Size), MaxAlignment)); + if (Size <= offset) + return Align(1); + return Align(std::min((size_t)llvm::PowerOf2Ceil(Size - offset), MaxAlignment)); } LLVM_ATTRIBUTE_RETURNS_NONNULL void *Allocate(size_t Size, Align Alignment) {