1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[LICM] Cleanup duplicated code. [NFCI]

llvm-svn: 352093
This commit is contained in:
Alina Sbirlea 2019-01-24 19:57:30 +00:00
parent 5724a0a24f
commit 4e9cf8d6ea

View File

@ -148,7 +148,8 @@ static void eraseInstruction(Instruction &I, ICFLoopSafetyInfo &SafetyInfo,
AliasSetTracker *AST, MemorySSAUpdater *MSSAU);
static void moveInstructionBefore(Instruction &I, Instruction &Dest,
ICFLoopSafetyInfo &SafetyInfo);
ICFLoopSafetyInfo &SafetyInfo,
MemorySSAUpdater *MSSAU);
namespace {
struct LoopInvariantCodeMotion {
@ -866,12 +867,7 @@ bool llvm::hoistRegion(DomTreeNode *N, AliasAnalysis *AA, LoopInfo *LI,
LLVM_DEBUG(dbgs() << "LICM rehoisting to "
<< HoistPoint->getParent()->getName()
<< ": " << *I << "\n");
moveInstructionBefore(*I, *HoistPoint, *SafetyInfo);
if (MSSAU)
if (MemoryUseOrDef *OldMemAcc = cast_or_null<MemoryUseOrDef>(
MSSAU->getMemorySSA()->getMemoryAccess(I)))
MSSAU->moveToPlace(OldMemAcc, HoistPoint->getParent(),
MemorySSA::End);
moveInstructionBefore(*I, *HoistPoint, *SafetyInfo, MSSAU);
HoistPoint = I;
Changed = true;
}
@ -1314,10 +1310,15 @@ static void eraseInstruction(Instruction &I, ICFLoopSafetyInfo &SafetyInfo,
}
static void moveInstructionBefore(Instruction &I, Instruction &Dest,
ICFLoopSafetyInfo &SafetyInfo) {
ICFLoopSafetyInfo &SafetyInfo,
MemorySSAUpdater *MSSAU) {
SafetyInfo.removeInstruction(&I);
SafetyInfo.insertInstructionTo(&I, Dest.getParent());
I.moveBefore(&Dest);
if (MSSAU)
if (MemoryUseOrDef *OldMemAcc = cast_or_null<MemoryUseOrDef>(
MSSAU->getMemorySSA()->getMemoryAccess(&I)))
MSSAU->moveToPlace(OldMemAcc, Dest->getParent(), MemorySSA::End);
}
static Instruction *sinkThroughTriviallyReplaceablePHI(
@ -1553,17 +1554,10 @@ static void hoist(Instruction &I, const DominatorTree *DT, const Loop *CurLoop,
if (isa<PHINode>(I))
// Move the new node to the end of the phi list in the destination block.
moveInstructionBefore(I, *Dest->getFirstNonPHI(), *SafetyInfo);
moveInstructionBefore(I, *Dest->getFirstNonPHI(), *SafetyInfo, MSSAU);
else
// Move the new node to the destination block, before its terminator.
moveInstructionBefore(I, *Dest->getTerminator(), *SafetyInfo);
if (MSSAU) {
// If moving, I just moved a load or store, so update MemorySSA.
MemoryUseOrDef *OldMemAcc = cast_or_null<MemoryUseOrDef>(
MSSAU->getMemorySSA()->getMemoryAccess(&I));
if (OldMemAcc)
MSSAU->moveToPlace(OldMemAcc, Dest, MemorySSA::End);
}
moveInstructionBefore(I, *Dest->getTerminator(), *SafetyInfo, MSSAU);
// Do not retain debug locations when we are moving instructions to different
// basic blocks, because we want to avoid jumpy line tables. Calls, however,