diff --git a/src/codegen.cpp b/src/codegen.cpp index 3e0457972cafe..4b611c9a26af9 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -6424,8 +6424,11 @@ 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"); - // CreateAlloca is OK during prologue setup - Value *lv = ctx.builder.CreateAlloca(vtype, NULL, jl_symbol_name(s)); + Value *lv = new AllocaInst(vtype, 0, 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); + } varinfo.value = mark_julia_slot(lv, jt, NULL, tbaa_stack); alloc_def_flag(ctx, varinfo); if (ctx.debug_enabled && varinfo.dinfo) {