@@ -6187,11 +6187,22 @@ static void emit_upsilonnode(jl_codectx_t &ctx, ssize_t phic, jl_value_t *val)
61876187 vi.pTIndex , Align (1 ), true );
61886188 }
61896189 else if (vi.value .V && !vi.value .constant && vi.value .typ != jl_bottom_type) {
6190- assert (vi.value .ispointer ());
6191- Type *T = cast<AllocaInst>(vi.value .V )->getAllocatedType ();
6192- if (CountTrackedPointers (T).count ) {
6190+ assert (vi.value .inline_roots || vi.value .ispointer ());
6191+ if (vi.value .inline_roots ) {
61936192 // memory optimization: make gc pointers re-initialized to NULL
6194- ctx.builder .CreateStore (Constant::getNullValue (T), vi.value .V , true );
6193+ AllocaInst *ssaroots = cast<AllocaInst>(vi.value .inline_roots );
6194+ size_t nroots = cast<ConstantInt>(ssaroots->getArraySize ())->getZExtValue ();
6195+ auto T_prjlvalue = ssaroots->getAllocatedType ();
6196+ if (auto AT = dyn_cast<ArrayType>(T_prjlvalue)) {
6197+ nroots *= AT->getNumElements ();
6198+ T_prjlvalue = AT->getElementType ();
6199+ }
6200+ assert (T_prjlvalue == ctx.types ().T_prjlvalue );
6201+ Value *nullval = Constant::getNullValue (T_prjlvalue);
6202+ auto stack_ai = jl_aliasinfo_t::fromTBAA (ctx, ctx.tbaa ().tbaa_stack );
6203+ for (size_t i = 0 ; i < nroots; i++) {
6204+ stack_ai.decorateInst (ctx.builder .CreateAlignedStore (nullval, emit_ptrgep (ctx, ssaroots, i * sizeof (void *)), ssaroots->getAlign (), true ));
6205+ }
61956206 }
61966207 }
61976208 }
@@ -9598,15 +9609,17 @@ static jl_llvm_functions_t
95989609
95999610 if (ctx.vaSlot > 0 ) {
96009611 // remove VA allocation if we never referenced it
9612+ assert (ctx.slots [ctx.vaSlot ].isSA && ctx.slots [ctx.vaSlot ].isArgument );
96019613 Instruction *root = cast_or_null<Instruction>(ctx.slots [ctx.vaSlot ].boxroot );
96029614 if (root) {
9603- Instruction *store_value = NULL ;
96049615 bool have_real_use = false ;
96059616 for (Use &U : root->uses ()) {
96069617 User *RU = U.getUser ();
96079618 if (StoreInst *SRU = dyn_cast<StoreInst>(RU)) {
9608- if (!store_value)
9609- store_value = dyn_cast<Instruction>(SRU->getValueOperand ());
9619+ assert (isa<ConstantPointerNull>(SRU->getValueOperand ()) || SRU->getValueOperand () == restTuple);
9620+ }
9621+ else if (MemSetInst *MSI = dyn_cast<MemSetInst>(RU)) {
9622+ assert (MSI->getValue () == ctx.builder .getInt8 (0 ));
96109623 }
96119624 else if (isa<DbgInfoIntrinsic>(RU)) {
96129625 }
@@ -9628,7 +9641,6 @@ static jl_llvm_functions_t
96289641 if (use)
96299642 use->eraseFromParent ();
96309643 root->eraseFromParent ();
9631- assert (!store_value || store_value == restTuple);
96329644 restTuple->eraseFromParent ();
96339645 }
96349646 }
0 commit comments