[llvm-commits] [llvm] r137264 - /llvm/trunk/include/llvm/Analysis/LoopIterator.h
Andrew Trick
atrick at apple.com
Wed Aug 10 15:55:39 PDT 2011
Author: atrick
Date: Wed Aug 10 17:55:39 2011
New Revision: 137264
URL: http://llvm.org/viewvc/llvm-project?rev=137264&view=rev
Log:
Cleanup. Remove an extraneous GraphTraits specialization.
Modified:
llvm/trunk/include/llvm/Analysis/LoopIterator.h
Modified: llvm/trunk/include/llvm/Analysis/LoopIterator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopIterator.h?rev=137264&r1=137263&r2=137264&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopIterator.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopIterator.h Wed Aug 10 17:55:39 2011
@@ -109,27 +109,11 @@
}
};
-/// Define a graph of blocks within a loop. Allows LoopBlocksTraversal to
-/// use the generic po_iterator with specialized GraphTraits.
-struct LoopBlocksGraph {
- Loop *L;
-
- LoopBlocksGraph(Loop *Container) : L(Container) {}
-};
-
-template<> struct GraphTraits<LoopBlocksGraph> :
- public GraphTraits<BasicBlock*> {
-
- static BasicBlock *getEntryNode(LoopBlocksGraph G) {
- return G.L->getHeader();
- }
-};
-
/// Traverse the blocks in a loop using a depth-first search.
class LoopBlocksTraversal {
public:
/// Graph traversal iterator.
- typedef po_iterator<LoopBlocksGraph, LoopBlocksTraversal, true> POTIterator;
+ typedef po_iterator<BasicBlock*, LoopBlocksTraversal, true> POTIterator;
private:
LoopBlocksDFS &DFS;
@@ -144,10 +128,12 @@
/// finishPostorder to record the DFS result.
POTIterator begin() {
assert(DFS.PostBlocks.empty() && "Need clear DFS result before traversing");
- return po_ext_begin(LoopBlocksGraph(DFS.L), *this);
+ assert(DFS.L->getNumBlocks() && "po_iterator cannot handle an empty graph");
+ return po_ext_begin(DFS.L->getHeader(), *this);
}
POTIterator end() {
- return po_ext_end(LoopBlocksGraph(DFS.L), *this);
+ // po_ext_end interface requires a basic block, but ignores its value.
+ return po_ext_end(DFS.L->getHeader(), *this);
}
/// Called by po_iterator upon reaching a block via a CFG edge. If this block
More information about the llvm-commits
mailing list