@@ -51,13 +51,14 @@ static void eraseInstruction(Instruction &I,
51
51
// Stolen and modified from LICM.cpp
52
52
static void moveInstructionBefore (Instruction &I, Instruction &Dest,
53
53
MemorySSAUpdater &MSSAU,
54
- ScalarEvolution *SE) {
54
+ ScalarEvolution *SE,
55
+ MemorySSA::InsertionPlace Place = MemorySSA::BeforeTerminator) {
55
56
I.moveBefore (&Dest);
56
57
if (MSSAU.getMemorySSA ())
57
58
if (MemoryUseOrDef *OldMemAcc = cast_or_null<MemoryUseOrDef>(
58
59
MSSAU.getMemorySSA ()->getMemoryAccess (&I)))
59
60
MSSAU.moveToPlace (OldMemAcc, Dest.getParent (),
60
- MemorySSA::BeforeTerminator );
61
+ Place );
61
62
if (SE)
62
63
SE->forgetValue (&I);
63
64
}
@@ -227,7 +228,7 @@ struct JuliaLICM : public JuliaPassContext {
227
228
continue ;
228
229
}
229
230
++SunkPreserveEnd;
230
- moveInstructionBefore (*call, *exit_pts[0 ], MSSAU, SE);
231
+ moveInstructionBefore (*call, *exit_pts[0 ], MSSAU, SE, MemorySSA::Beginning );
231
232
for (unsigned i = 1 ; i < exit_pts.size (); i++) {
232
233
// Clone exit
233
234
auto CI = CallInst::Create (call, {}, exit_pts[i]);
@@ -290,20 +291,6 @@ struct JuliaLICM : public JuliaPassContext {
290
291
}
291
292
changed = true ;
292
293
}
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 ;
307
294
}
308
295
}
309
296
}
0 commit comments