Skip to content

Commit 83263ee

Browse files
pchintalapudiKristofferC
authored andcommitted
Fix MemorySSA bug, broken julia-licm test (#49900)
1 parent 9e94f66 commit 83263ee

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

src/llvm-julia-licm.cpp

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ static void eraseInstruction(Instruction &I,
5151
//Stolen and modified from LICM.cpp
5252
static void moveInstructionBefore(Instruction &I, Instruction &Dest,
5353
MemorySSAUpdater &MSSAU,
54-
ScalarEvolution *SE) {
54+
ScalarEvolution *SE,
55+
MemorySSA::InsertionPlace Place = MemorySSA::BeforeTerminator) {
5556
I.moveBefore(&Dest);
5657
if (MSSAU.getMemorySSA())
5758
if (MemoryUseOrDef *OldMemAcc = cast_or_null<MemoryUseOrDef>(
5859
MSSAU.getMemorySSA()->getMemoryAccess(&I)))
5960
MSSAU.moveToPlace(OldMemAcc, Dest.getParent(),
60-
MemorySSA::BeforeTerminator);
61+
Place);
6162
if (SE)
6263
SE->forgetValue(&I);
6364
}
@@ -227,7 +228,7 @@ struct JuliaLICM : public JuliaPassContext {
227228
continue;
228229
}
229230
++SunkPreserveEnd;
230-
moveInstructionBefore(*call, *exit_pts[0], MSSAU, SE);
231+
moveInstructionBefore(*call, *exit_pts[0], MSSAU, SE, MemorySSA::Beginning);
231232
for (unsigned i = 1; i < exit_pts.size(); i++) {
232233
// Clone exit
233234
auto CI = CallInst::Create(call, {}, exit_pts[i]);
@@ -290,20 +291,6 @@ struct JuliaLICM : public JuliaPassContext {
290291
}
291292
changed = true;
292293
}
293-
IRBuilder<> builder(preheader->getTerminator());
294-
builder.SetCurrentDebugLocation(call->getDebugLoc());
295-
auto obj_i8 = builder.CreateBitCast(call, Type::getInt8PtrTy(call->getContext(), call->getType()->getPointerAddressSpace()));
296-
// Note that this alignment is assuming the GC allocates at least pointer-aligned memory
297-
auto align = Align(DL.getPointerSize(0));
298-
auto clear_obj = builder.CreateMemSet(obj_i8, ConstantInt::get(Type::getInt8Ty(call->getContext()), 0), call->getArgOperand(1), align);
299-
if (MSSAU.getMemorySSA()) {
300-
auto alloc_mdef = MSSAU.getMemorySSA()->getMemoryAccess(call);
301-
assert(isa<MemoryDef>(alloc_mdef) && "Expected alloc to be associated with a memory def!");
302-
auto clear_mdef = MSSAU.createMemoryAccessAfter(clear_obj, nullptr, alloc_mdef);
303-
assert(isa<MemoryDef>(clear_mdef) && "Expected memset to be associated with a memory def!");
304-
(void) clear_mdef;
305-
}
306-
changed = true;
307294
}
308295
}
309296
}

0 commit comments

Comments
 (0)