Skip to content

Commit 5b345e1

Browse files
committed
fix mssa updates
1 parent b0a8eae commit 5b345e1

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

llvm/lib/Transforms/Scalar/LICM.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,15 @@ static Instruction *cloneInstructionInExitBlock(
209209
static void eraseInstruction(Instruction &I, ICFLoopSafetyInfo &SafetyInfo,
210210
MemorySSAUpdater &MSSAU);
211211

212-
static void moveInstructionBefore(Instruction &I, BasicBlock::iterator Dest,
213-
ICFLoopSafetyInfo &SafetyInfo,
214-
MemorySSAUpdater &MSSAU, ScalarEvolution *SE);
212+
static void moveInstructionBefore(
213+
Instruction &I, BasicBlock::iterator Dest, ICFLoopSafetyInfo &SafetyInfo,
214+
MemorySSAUpdater &MSSAU, ScalarEvolution *SE,
215+
MemorySSA::InsertionPlace Point = MemorySSA::BeforeTerminator);
215216

216217
static bool sinkUnusedInvariantsFromPreheaderToExit(
217218
Loop *L, AAResults *AA, ICFLoopSafetyInfo *SafetyInfo,
218219
MemorySSAUpdater &MSSAU, ScalarEvolution *SE, DominatorTree *DT,
219-
SinkAndHoistLICMFlags &SinkFlags);
220+
SinkAndHoistLICMFlags &SinkFlags, OptimizationRemarkEmitter *ORE);
220221

221222
static void foreachMemoryAccess(MemorySSA *MSSA, Loop *L,
222223
function_ref<void(Instruction *)> Fn);
@@ -550,7 +551,7 @@ bool LoopInvariantCodeMotion::runOnLoop(Loop *L, AAResults *AA, LoopInfo *LI,
550551
// pressure.
551552
Flags.setIsSink(true);
552553
Changed |= sinkUnusedInvariantsFromPreheaderToExit(L, AA, &SafetyInfo, MSSAU,
553-
SE, DT, Flags);
554+
SE, DT, Flags, ORE);
554555

555556
if (VerifyMemorySSA)
556557
MSSA->verifyMemorySSA();
@@ -1468,15 +1469,14 @@ static void eraseInstruction(Instruction &I, ICFLoopSafetyInfo &SafetyInfo,
14681469

14691470
static void moveInstructionBefore(Instruction &I, BasicBlock::iterator Dest,
14701471
ICFLoopSafetyInfo &SafetyInfo,
1471-
MemorySSAUpdater &MSSAU,
1472-
ScalarEvolution *SE) {
1472+
MemorySSAUpdater &MSSAU, ScalarEvolution *SE,
1473+
MemorySSA::InsertionPlace Point) {
14731474
SafetyInfo.removeInstruction(&I);
14741475
SafetyInfo.insertInstructionTo(&I, Dest->getParent());
14751476
I.moveBefore(*Dest->getParent(), Dest);
14761477
if (MemoryUseOrDef *OldMemAcc = cast_or_null<MemoryUseOrDef>(
14771478
MSSAU.getMemorySSA()->getMemoryAccess(&I)))
1478-
MSSAU.moveToPlace(OldMemAcc, Dest->getParent(),
1479-
MemorySSA::BeforeTerminator);
1479+
MSSAU.moveToPlace(OldMemAcc, Dest->getParent(), Point);
14801480
if (SE)
14811481
SE->forgetBlockAndLoopDispositions(&I);
14821482
}
@@ -1487,7 +1487,7 @@ static void moveInstructionBefore(Instruction &I, BasicBlock::iterator Dest,
14871487
static bool sinkUnusedInvariantsFromPreheaderToExit(
14881488
Loop *L, AAResults *AA, ICFLoopSafetyInfo *SafetyInfo,
14891489
MemorySSAUpdater &MSSAU, ScalarEvolution *SE, DominatorTree *DT,
1490-
SinkAndHoistLICMFlags &SinkFlags) {
1490+
SinkAndHoistLICMFlags &SinkFlags, OptimizationRemarkEmitter *ORE) {
14911491
BasicBlock *ExitBlock = L->getExitBlock();
14921492
if (!ExitBlock)
14931493
return false;
@@ -1536,7 +1536,7 @@ static bool sinkUnusedInvariantsFromPreheaderToExit(
15361536
continue;
15371537

15381538
moveInstructionBefore(I, ExitBlock->getFirstInsertionPt(), *SafetyInfo,
1539-
MSSAU, SE);
1539+
MSSAU, SE, MemorySSA::Beginning);
15401540
MadeAnyChanges = true;
15411541
}
15421542

llvm/test/Transforms/IndVarSimplify/sink-alloca.ll renamed to llvm/test/Transforms/LICM/sink-alloca.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
; RUN: opt < %s -passes=indvars -S | FileCheck %s
1+
; RUN: opt < %s -passes=licm -verify-memoryssa -S | FileCheck %s
22
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
33
target triple = "i386-apple-darwin10.0"
44

55
; PR4775
6-
; Indvars shouldn't sink the alloca out of the entry block, even though
6+
; LICM shouldn't sink the alloca out of the entry block, even though
77
; it's not used until after the loop.
88
define i32 @main() nounwind {
99
; CHECK: entry:
@@ -25,7 +25,7 @@ while.end: ; preds = %while.cond
2525
declare i32 @bar()
2626

2727
; <rdar://problem/10352360>
28-
; Indvars shouldn't sink the first alloca between the stacksave and stackrestore
28+
; LICM shouldn't sink the first alloca between the stacksave and stackrestore
2929
; intrinsics.
3030
declare ptr @a(...)
3131
declare ptr @llvm.stacksave() nounwind

llvm/test/Transforms/LICM/sink-from-preheader.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt < %s -passes=licm -S | FileCheck %s
2+
; RUN: opt < %s -passes=licm -verify-memoryssa -S | FileCheck %s
33
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
44
target triple = "i386-apple-darwin10.0"
55

llvm/test/Transforms/LICM/sink-trapping.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt < %s -passes=licm -S | FileCheck %s
1+
; RUN: opt < %s -passes=licm -verify-memoryssa -S | FileCheck %s
22

33
declare i1 @b()
44

0 commit comments

Comments
 (0)