From 6e2b2bd7b174826ed164e86a20159489e4aca552 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Fri, 17 Nov 2023 14:21:55 +0000 Subject: [PATCH] jitlayers: reduce excess alignment of #52182 --- 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) {