Skip to content

Commit

Permalink
Initialize hoisted object allocations (#49584)
Browse files Browse the repository at this point in the history
(cherry picked from commit 5032a1a)
  • Loading branch information
pchintalapudi authored and KristofferC committed May 8, 2023
1 parent 145779c commit 792d907
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/llvm-julia-licm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,20 @@ struct JuliaLICM : public JuliaPassContext {
}
changed = true;
}
IRBuilder<> builder(preheader->getTerminator());
builder.SetCurrentDebugLocation(call->getDebugLoc());
auto obj_i8 = builder.CreateBitCast(call, Type::getInt8PtrTy(call->getContext(), call->getType()->getPointerAddressSpace()));
// Note that this alignment is assuming the GC allocates at least pointer-aligned memory
auto align = Align(DL.getPointerSize(0));
auto clear_obj = builder.CreateMemSet(obj_i8, ConstantInt::get(Type::getInt8Ty(call->getContext()), 0), call->getArgOperand(1), align);
if (MSSAU.getMemorySSA()) {
auto alloc_mdef = MSSAU.getMemorySSA()->getMemoryAccess(call);
assert(isa<MemoryDef>(alloc_mdef) && "Expected alloc to be associated with a memory def!");
auto clear_mdef = MSSAU.createMemoryAccessAfter(clear_obj, nullptr, alloc_mdef);
assert(isa<MemoryDef>(clear_mdef) && "Expected memset to be associated with a memory def!");
(void) clear_mdef;
}
changed = true;
}
}
}
Expand Down

0 comments on commit 792d907

Please sign in to comment.