[llvm] r313322 - Refactor collectChildrenInLoop to LoopUtils [NFC]
Alina Sbirlea via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 14 17:04:16 PDT 2017
Author: asbirlea
Date: Thu Sep 14 17:04:16 2017
New Revision: 313322
URL: http://llvm.org/viewvc/llvm-project?rev=313322&view=rev
Log:
Refactor collectChildrenInLoop to LoopUtils [NFC]
Summary: Move to LoopUtils method that collects all children of a node inside a loop.
Reviewers: majnemer, sanjoy
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D37870
Modified:
llvm/trunk/include/llvm/Transforms/Utils/LoopUtils.h
llvm/trunk/lib/Transforms/Scalar/LICM.cpp
llvm/trunk/lib/Transforms/Utils/LoopUtils.cpp
Modified: llvm/trunk/include/llvm/Transforms/Utils/LoopUtils.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/LoopUtils.h?rev=313322&r1=313321&r2=313322&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/LoopUtils.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/LoopUtils.h Thu Sep 14 17:04:16 2017
@@ -455,6 +455,11 @@ bool promoteLoopAccessesToScalars(const
Loop *, AliasSetTracker *, LoopSafetyInfo *,
OptimizationRemarkEmitter *);
+/// Does a BFS from a given node to all of its children inside a given loop.
+/// The returned vector of nodes includes the starting point.
+SmallVector<DomTreeNode *, 16> collectChildrenInLoop(DomTreeNode *N,
+ const Loop *CurLoop);
+
/// \brief Computes safety information for a loop
/// checks loop body & header for the possibility of may throw
/// exception, it takes LoopSafetyInfo and loop as argument.
Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=313322&r1=313321&r2=313322&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Thu Sep 14 17:04:16 2017
@@ -345,29 +345,6 @@ bool LoopInvariantCodeMotion::runOnLoop(
return Changed;
}
-// Does a BFS from a given node to all of its children inside a given loop.
-// The returned vector of nodes includes the starting point.
-static SmallVector<DomTreeNode *, 16>
-collectChildrenInLoop(DomTreeNode *N, const Loop *CurLoop) {
- SmallVector<DomTreeNode *, 16> Worklist;
- auto add_region_to_worklist = [&](DomTreeNode *DTN) {
- // Only include subregions in the top level loop.
- BasicBlock *BB = DTN->getBlock();
- if (CurLoop->contains(BB))
- Worklist.push_back(DTN);
- };
-
- add_region_to_worklist(N);
-
- for (size_t I = 0; I < Worklist.size(); I++) {
- DomTreeNode *DTN = Worklist[I];
- for (DomTreeNode *Child : DTN->getChildren())
- add_region_to_worklist(Child);
- }
-
- return Worklist;
-}
-
/// Walk the specified region of the CFG (defined by all blocks dominated by
/// the specified block, and that are in the current loop) in reverse depth
/// first order w.r.t the DominatorTree. This allows us to visit uses before
Modified: llvm/trunk/lib/Transforms/Utils/LoopUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopUtils.cpp?rev=313322&r1=313321&r2=313322&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopUtils.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LoopUtils.cpp Thu Sep 14 17:04:16 2017
@@ -1116,6 +1116,27 @@ Optional<const MDOperand *> llvm::findSt
return None;
}
+/// Does a BFS from a given node to all of its children inside a given loop.
+/// The returned vector of nodes includes the starting point.
+SmallVector<DomTreeNode *, 16>
+llvm::collectChildrenInLoop(DomTreeNode *N, const Loop *CurLoop) {
+ SmallVector<DomTreeNode *, 16> Worklist;
+ auto AddRegionToWorklist = [&](DomTreeNode *DTN) {
+ // Only include subregions in the top level loop.
+ BasicBlock *BB = DTN->getBlock();
+ if (CurLoop->contains(BB))
+ Worklist.push_back(DTN);
+ };
+
+ AddRegionToWorklist(N);
+
+ for (size_t I = 0; I < Worklist.size(); I++)
+ for (DomTreeNode *Child : Worklist[I]->getChildren())
+ AddRegionToWorklist(Child);
+
+ return Worklist;
+}
+
/// Returns true if the instruction in a loop is guaranteed to execute at least
/// once.
bool llvm::isGuaranteedToExecute(const Instruction &Inst,
More information about the llvm-commits
mailing list