Skip to content

Commit cafcd7c

Browse files
committed
codegen-opt: fix stack alignment
previously, stack-alignment of, for example, a 12-byte allocation would be computed to be 16-bytes during codegen (because of gc-alignment rounding up), but 8-bytes here (because of this code rounding down)
1 parent 674e64b commit cafcd7c

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

src/llvm-alloc-opt.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -715,10 +715,7 @@ bool AllocOpt::runOnFunction(Function &F)
715715
sz += align;
716716
}
717717
else if (sz > 1) {
718-
align = JL_SMALL_BYTE_ALIGNMENT;
719-
while (sz < align) {
720-
align = align / 2;
721-
}
718+
align = llvm::MinAlign(JL_SMALL_BYTE_ALIGNMENT, llvm::NextPowerOf2(sz));
722719
}
723720
// No debug info for prolog instructions
724721
IRBuilder<> prolog_builder(&entry.front());

0 commit comments

Comments
 (0)