From 29c76db65ca8e017723332c8cb12e14e2d5c1a33 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Tue, 16 Aug 2022 17:29:52 -0400 Subject: [PATCH] Properly declare alloca alignment (#46368) Turns out when you declare an alloca alignment, it also rounds up the allocated size. Replaces #46322 and #46260 and fixes the same issue. (cherry picked from commit e358a17aa806541b23842fd0ef06bacf50491b75) --- src/codegen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index cfd0e7154ce68..79b40513f453c 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -6709,7 +6709,7 @@ static std::pair, jl_llvm_functions_t> Type *vtype = julia_type_to_llvm(ctx, jt, &isboxed); assert(!isboxed); assert(!type_is_ghost(vtype) && "constants should already be handled"); - Value *lv = new AllocaInst(vtype, 0, jl_symbol_name(s), /*InsertBefore*/ctx.pgcstack); + Value *lv = new AllocaInst(vtype, 0, NULL, Align(jl_datatype_align(jt)), jl_symbol_name(s), /*InsertBefore*/ctx.pgcstack); if (CountTrackedPointers(vtype).count) { StoreInst *SI = new StoreInst(Constant::getNullValue(vtype), lv, false, Align(sizeof(void*))); SI->insertAfter(ctx.pgcstack);