[llvm] r344587 - [NFC] Turn isGuaranteedToExecute into a method
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 15 23:34:53 PDT 2018
Author: mkazantsev
Date: Mon Oct 15 23:34:53 2018
New Revision: 344587
URL: http://llvm.org/viewvc/llvm-project?rev=344587&view=rev
Log:
[NFC] Turn isGuaranteedToExecute into a method
Modified:
llvm/trunk/include/llvm/Analysis/MustExecute.h
llvm/trunk/lib/Analysis/MustExecute.cpp
llvm/trunk/lib/Transforms/Scalar/LICM.cpp
llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
Modified: llvm/trunk/include/llvm/Analysis/MustExecute.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MustExecute.h?rev=344587&r1=344586&r2=344587&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/MustExecute.h (original)
+++ llvm/trunk/include/llvm/Analysis/MustExecute.h Mon Oct 15 23:34:53 2018
@@ -82,15 +82,14 @@ public:
/// LoopSafetyInfo. Some callers rely on this fact.
void computeLoopSafetyInfo(Loop *);
+ /// Returns true if the instruction in a loop is guaranteed to execute at
+ /// least once (under the assumption that the loop is entered).
+ bool isGuaranteedToExecute(const Instruction &Inst, const DominatorTree *DT,
+ const Loop *CurLoop) const;
+
LoopSafetyInfo() = default;
};
-/// Returns true if the instruction in a loop is guaranteed to execute at least
-/// once (under the assumption that the loop is entered).
-bool isGuaranteedToExecute(const Instruction &Inst, const DominatorTree *DT,
- const Loop *CurLoop,
- const LoopSafetyInfo *SafetyInfo);
-
}
#endif
Modified: llvm/trunk/lib/Analysis/MustExecute.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MustExecute.cpp?rev=344587&r1=344586&r2=344587&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MustExecute.cpp (original)
+++ llvm/trunk/lib/Analysis/MustExecute.cpp Mon Oct 15 23:34:53 2018
@@ -176,9 +176,9 @@ bool LoopSafetyInfo::allLoopPathsLeadToB
/// Returns true if the instruction in a loop is guaranteed to execute at least
/// once.
-bool llvm::isGuaranteedToExecute(const Instruction &Inst,
- const DominatorTree *DT, const Loop *CurLoop,
- const LoopSafetyInfo *SafetyInfo) {
+bool LoopSafetyInfo::isGuaranteedToExecute(const Instruction &Inst,
+ const DominatorTree *DT,
+ const Loop *CurLoop) const {
// We have to check to make sure that the instruction dominates all
// of the exit blocks. If it doesn't, then there is a path out of the loop
// which does not execute this instruction, so we can't hoist it.
@@ -191,17 +191,17 @@ bool llvm::isGuaranteedToExecute(const I
// Inst unless we can prove that Inst comes before the potential implicit
// exit. At the moment, we use a (cheap) hack for the common case where
// the instruction of interest is the first one in the block.
- return !SafetyInfo->headerMayThrow() ||
- Inst.getParent()->getFirstNonPHIOrDbg() == &Inst;
+ return !headerMayThrow() ||
+ Inst.getParent()->getFirstNonPHIOrDbg() == &Inst;
// Somewhere in this loop there is an instruction which may throw and make us
// exit the loop.
- if (SafetyInfo->anyBlockMayThrow())
+ if (anyBlockMayThrow())
return false;
// If there is a path from header to exit or latch that doesn't lead to our
// instruction's block, return false.
- if (!SafetyInfo->allLoopPathsLeadToBlock(CurLoop, Inst.getParent(), DT))
+ if (!allLoopPathsLeadToBlock(CurLoop, Inst.getParent(), DT))
return false;
return true;
@@ -242,7 +242,7 @@ static bool isMustExecuteIn(const Instru
// caller actually gets the full power at the moment.
LoopSafetyInfo LSI;
LSI.computeLoopSafetyInfo(L);
- return isGuaranteedToExecute(I, DT, L, &LSI) ||
+ return LSI.isGuaranteedToExecute(I, DT, L) ||
isGuaranteedToExecuteForEveryIteration(&I, L);
}
Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=344587&r1=344586&r2=344587&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Mon Oct 15 23:34:53 2018
@@ -1116,7 +1116,7 @@ static void hoist(Instruction &I, const
// The check on hasMetadataOtherThanDebugLoc is to prevent us from burning
// time in isGuaranteedToExecute if we don't actually have anything to
// drop. It is a compile time optimization, not required for correctness.
- !isGuaranteedToExecute(I, DT, CurLoop, SafetyInfo))
+ !SafetyInfo->isGuaranteedToExecute(I, DT, CurLoop))
I.dropUnknownNonDebugMetadata();
// Move the new node to the Preheader, before its terminator.
@@ -1150,7 +1150,7 @@ static bool isSafeToExecuteUnconditional
return true;
bool GuaranteedToExecute =
- isGuaranteedToExecute(Inst, DT, CurLoop, SafetyInfo);
+ SafetyInfo->isGuaranteedToExecute(Inst, DT, CurLoop);
if (!GuaranteedToExecute) {
auto *LI = dyn_cast<LoadInst>(&Inst);
@@ -1408,7 +1408,7 @@ bool llvm::promoteLoopAccessesToScalars(
if (!DereferenceableInPH || !SafeToInsertStore ||
(InstAlignment > Alignment)) {
- if (isGuaranteedToExecute(*UI, DT, CurLoop, SafetyInfo)) {
+ if (SafetyInfo->isGuaranteedToExecute(*UI, DT, CurLoop)) {
DereferenceableInPH = true;
SafeToInsertStore = true;
Alignment = std::max(Alignment, InstAlignment);
Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=344587&r1=344586&r2=344587&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Mon Oct 15 23:34:53 2018
@@ -721,7 +721,7 @@ bool LoopUnswitch::processCurrentLoop()
// This is a workaround for the discrepancy between LLVM IR and MSan
// semantics. See PR28054 for more details.
if (SanitizeMemory &&
- !isGuaranteedToExecute(*TI, DT, currentLoop, &SafetyInfo))
+ !SafetyInfo.isGuaranteedToExecute(*TI, DT, currentLoop))
continue;
if (BranchInst *BI = dyn_cast<BranchInst>(TI)) {
More information about the llvm-commits
mailing list