Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 244a2cf

Browse files
author
Max Kazantsev
committed
[NFC] Add utility function for SafetyInfo updates for moveBefore
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346472 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent b9dd8a3 commit 244a2cf

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/Transforms/Scalar/LICM.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ CloneInstructionInExitBlock(Instruction &I, BasicBlock &ExitBlock, PHINode &PN,
126126
static void eraseInstruction(Instruction &I, ICFLoopSafetyInfo &SafetyInfo,
127127
AliasSetTracker *AST);
128128

129+
static void moveInstructionBefore(Instruction &I, Instruction &Dest,
130+
ICFLoopSafetyInfo &SafetyInfo);
131+
129132
namespace {
130133
struct LoopInvariantCodeMotion {
131134
using ASTrackerMapTy = DenseMap<Loop *, std::unique_ptr<AliasSetTracker>>;
@@ -890,6 +893,13 @@ static void eraseInstruction(Instruction &I, ICFLoopSafetyInfo &SafetyInfo,
890893
I.eraseFromParent();
891894
}
892895

896+
static void moveInstructionBefore(Instruction &I, Instruction &Dest,
897+
ICFLoopSafetyInfo &SafetyInfo) {
898+
SafetyInfo.removeInstruction(&I);
899+
SafetyInfo.insertInstructionTo(Dest.getParent());
900+
I.moveBefore(&Dest);
901+
}
902+
893903
static Instruction *sinkThroughTriviallyReplaceablePHI(
894904
PHINode *TPN, Instruction *I, LoopInfo *LI,
895905
SmallDenseMap<BasicBlock *, Instruction *, 32> &SunkCopies,
@@ -1118,10 +1128,8 @@ static void hoist(Instruction &I, const DominatorTree *DT, const Loop *CurLoop,
11181128
!SafetyInfo->isGuaranteedToExecute(I, DT, CurLoop))
11191129
I.dropUnknownNonDebugMetadata();
11201130

1121-
SafetyInfo->removeInstruction(&I);
1122-
SafetyInfo->insertInstructionTo(Preheader);
11231131
// Move the new node to the Preheader, before its terminator.
1124-
I.moveBefore(Preheader->getTerminator());
1132+
moveInstructionBefore(I, *Preheader->getTerminator(), *SafetyInfo);
11251133

11261134
// Do not retain debug locations when we are moving instructions to different
11271135
// basic blocks, because we want to avoid jumpy line tables. Calls, however,

0 commit comments

Comments
 (0)