[llvm] r346472 - [NFC] Add utility function for SafetyInfo updates for moveBefore
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 8 21:39:04 PST 2018
Author: mkazantsev
Date: Thu Nov 8 21:39:04 2018
New Revision: 346472
URL: http://llvm.org/viewvc/llvm-project?rev=346472&view=rev
Log:
[NFC] Add utility function for SafetyInfo updates for moveBefore
Modified:
llvm/trunk/lib/Transforms/Scalar/LICM.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=346472&r1=346471&r2=346472&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Thu Nov 8 21:39:04 2018
@@ -126,6 +126,9 @@ CloneInstructionInExitBlock(Instruction
static void eraseInstruction(Instruction &I, ICFLoopSafetyInfo &SafetyInfo,
AliasSetTracker *AST);
+static void moveInstructionBefore(Instruction &I, Instruction &Dest,
+ ICFLoopSafetyInfo &SafetyInfo);
+
namespace {
struct LoopInvariantCodeMotion {
using ASTrackerMapTy = DenseMap<Loop *, std::unique_ptr<AliasSetTracker>>;
@@ -890,6 +893,13 @@ static void eraseInstruction(Instruction
I.eraseFromParent();
}
+static void moveInstructionBefore(Instruction &I, Instruction &Dest,
+ ICFLoopSafetyInfo &SafetyInfo) {
+ SafetyInfo.removeInstruction(&I);
+ SafetyInfo.insertInstructionTo(Dest.getParent());
+ I.moveBefore(&Dest);
+}
+
static Instruction *sinkThroughTriviallyReplaceablePHI(
PHINode *TPN, Instruction *I, LoopInfo *LI,
SmallDenseMap<BasicBlock *, Instruction *, 32> &SunkCopies,
@@ -1118,10 +1128,8 @@ static void hoist(Instruction &I, const
!SafetyInfo->isGuaranteedToExecute(I, DT, CurLoop))
I.dropUnknownNonDebugMetadata();
- SafetyInfo->removeInstruction(&I);
- SafetyInfo->insertInstructionTo(Preheader);
// Move the new node to the Preheader, before its terminator.
- I.moveBefore(Preheader->getTerminator());
+ moveInstructionBefore(I, *Preheader->getTerminator(), *SafetyInfo);
// Do not retain debug locations when we are moving instructions to different
// basic blocks, because we want to avoid jumpy line tables. Calls, however,
More information about the llvm-commits
mailing list