summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2011-08-10 01:59:05 +0000
committerAndrew Trick <atrick@apple.com>2011-08-10 01:59:05 +0000
commit2d31ae3d9dfb153f081a5521374b2b42befd50a1 (patch)
tree556cd60801e7ff953f76e136f5138e332d2f1cab /lib
parent155a92a4918f290e56869bec6360fd8dd6e3950d (diff)
downloadllvm-2d31ae3d9dfb153f081a5521374b2b42befd50a1.tar.gz
llvm-2d31ae3d9dfb153f081a5521374b2b42befd50a1.tar.bz2
llvm-2d31ae3d9dfb153f081a5521374b2b42befd50a1.tar.xz
Cleanup. Added LoopBlocksDFS::perform for simple clients.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137195 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/LoopInfo.cpp13
-rw-r--r--lib/Transforms/Utils/LoopUnroll.cpp9
2 files changed, 15 insertions, 7 deletions
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp
index cfe71d18a4..528b3cf87b 100644
--- a/lib/Analysis/LoopInfo.cpp
+++ b/lib/Analysis/LoopInfo.cpp
@@ -18,6 +18,7 @@
#include "llvm/Constants.h"
#include "llvm/Instructions.h"
#include "llvm/Analysis/Dominators.h"
+#include "llvm/Analysis/LoopIterator.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/CommandLine.h"
@@ -417,3 +418,15 @@ void LoopInfo::print(raw_ostream &OS, const Module*) const {
LI.print(OS);
}
+//===----------------------------------------------------------------------===//
+// LoopBlocksDFS implementation
+//
+
+/// Traverse the loop blocks and store the DFS result.
+/// Useful for clients that just want the final DFS result and don't need to
+/// visit blocks during the initial traversal.
+void LoopBlocksDFS::perform(LoopInfo *LI) {
+ LoopBlocksTraversal Traversal(*this, LI);
+ for (LoopBlocksTraversal::POTIterator POI = Traversal.begin(),
+ POE = Traversal.end(); POI != POE; ++POI) ;
+}
diff --git a/lib/Transforms/Utils/LoopUnroll.cpp b/lib/Transforms/Utils/LoopUnroll.cpp
index f17098fd39..6b2f9efe15 100644
--- a/lib/Transforms/Utils/LoopUnroll.cpp
+++ b/lib/Transforms/Utils/LoopUnroll.cpp
@@ -230,13 +230,8 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, unsigned TripCount,
// reverse postorder so that LastValueMap contains the correct value at each
// exit.
LoopBlocksDFS DFS(L);
- {
- // Traverse the loop blocks using depth-first search to record RPO numbers
- // for each block in the DFS result.
- LoopBlocksTraversal Traversal(DFS, LI);
- for (LoopBlocksTraversal::POTIterator POI = Traversal.begin(),
- POE = Traversal.end(); POI != POE; ++POI);
- }
+ DFS.perform(LI);
+
// Stash the DFS iterators before adding blocks to the loop.
LoopBlocksDFS::RPOIterator BlockBegin = DFS.beginRPO();
LoopBlocksDFS::RPOIterator BlockEnd = DFS.endRPO();