From 72cd63ce28c50c8c72e009df03dfec608802450e 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) --- src/jitlayers.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/jitlayers.h b/src/jitlayers.h index 85cbb2cf8ec28..ba2e81879a44b 100644 --- a/src/jitlayers.h +++ b/src/jitlayers.h @@ -306,7 +306,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) {