From 4e9b46dcbc54f62f3f0eb179e6bbd8c39b646760 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Tue, 16 Aug 2022 19:51:17 +0000 Subject: [PATCH] Properly declare alloca alignment Turns out when you declare an alloca alignment, it also rounds up the allocated size. Replaces #46322 and #46260 and fixes the same issue. --- src/codegen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index e54dc61fcb6e7..233c492f2e8c2 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -7060,7 +7060,7 @@ static 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, M->getDataLayout().getAllocaAddrSpace(), jl_symbol_name(s), /*InsertBefore*/ctx.topalloca); + Value *lv = new AllocaInst(vtype, M->getDataLayout().getAllocaAddrSpace(), NULL, Align(jl_datatype_align(jt)), jl_symbol_name(s), /*InsertBefore*/ctx.topalloca); if (CountTrackedPointers(vtype).count) { StoreInst *SI = new StoreInst(Constant::getNullValue(vtype), lv, false, Align(sizeof(void*))); SI->insertAfter(ctx.topalloca);