summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/LoopAnalysisManager.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2017-01-20 02:41:20 +0000
committerChandler Carruth <chandlerc@gmail.com>2017-01-20 02:41:20 +0000
commitf002264d499ec9b6c69ac1cdfa9b9bd783ad63c6 (patch)
tree9fb1eb9ef5d23c93cb548e2ff91edab7e2cbaef7 /llvm/lib/Analysis/LoopAnalysisManager.cpp
parentefa3185ee49d744086d97d281374227060d8fdf1 (diff)
downloadbcm5719-llvm-f002264d499ec9b6c69ac1cdfa9b9bd783ad63c6.tar.gz
bcm5719-llvm-f002264d499ec9b6c69ac1cdfa9b9bd783ad63c6.zip
[LoopInfo] Add helper methods to compute two useful orderings of the
loops in a function. These are relatively confusing to talk about and compute correctly so it seems really good to write down their implementation in one place. I've replaced one place we needed this in the loop PM infrastructure and I have another place in a pending patch that wants it. We can't quite use this for the core loop PM walk because there we're sometimes working on a sub-forest. I'll add the expected unittests before committing this but wanted to make sure folks were happy with these names / comments. Credit goes to Richard Smith for the idea for naming the order where siblings are in reverse program order but the tree traversal remains preorder. Differential Revision: https://reviews.llvm.org/D28932 llvm-svn: 292569
Diffstat (limited to 'llvm/lib/Analysis/LoopAnalysisManager.cpp')
-rw-r--r--llvm/lib/Analysis/LoopAnalysisManager.cpp22
1 files changed, 4 insertions, 18 deletions
diff --git a/llvm/lib/Analysis/LoopAnalysisManager.cpp b/llvm/lib/Analysis/LoopAnalysisManager.cpp
index 2946baef8ae..e4a0f90b2f7 100644
--- a/llvm/lib/Analysis/LoopAnalysisManager.cpp
+++ b/llvm/lib/Analysis/LoopAnalysisManager.cpp
@@ -31,24 +31,10 @@ bool LoopAnalysisManagerFunctionProxy::Result::invalidate(
FunctionAnalysisManager::Invalidator &Inv) {
// First compute the sequence of IR units covered by this proxy. We will want
// to visit this in postorder, but because this is a tree structure we can do
- // this by building a preorder sequence and walking it in reverse.
- SmallVector<Loop *, 4> PreOrderLoops, PreOrderWorklist;
- // Note that we want to walk the roots in reverse order because we will end
- // up reversing the preorder sequence. However, it happens that the loop nest
- // roots are in reverse order within the LoopInfo object. So we just walk
- // forward here.
- // FIXME: If we change the order of LoopInfo we will want to add a reverse
- // here.
- for (Loop *RootL : *LI) {
- assert(PreOrderWorklist.empty() &&
- "Must start with an empty preorder walk worklist.");
- PreOrderWorklist.push_back(RootL);
- do {
- Loop *L = PreOrderWorklist.pop_back_val();
- PreOrderWorklist.append(L->begin(), L->end());
- PreOrderLoops.push_back(L);
- } while (!PreOrderWorklist.empty());
- }
+ // this by building a preorder sequence and walking it backwards. We also
+ // want siblings in forward program order to match the LoopPassManager so we
+ // get the preorder with siblings reversed.
+ SmallVector<Loop *, 4> PreOrderLoops = LI->getLoopsInReverseSiblingPreorder();
// If this proxy or the loop info is going to be invalidated, we also need
// to clear all the keys coming from that analysis. We also completely blow
OpenPOWER on IntegriCloud