[llvm-commits] CVS: llvm/lib/Analysis/LoopInfo.cpp
Michael Brukman
brukman at cs.uiuc.edu
Fri Oct 11 00:31:03 PDT 2002
Changes in directory llvm/lib/Analysis:
LoopInfo.cpp updated: 1.25 -> 1.26
---
Log message:
Added helper functions in LoopInfo: isLoopExit and numBackEdges.
---
Diffs of the changes:
Index: llvm/lib/Analysis/LoopInfo.cpp
diff -u llvm/lib/Analysis/LoopInfo.cpp:1.25 llvm/lib/Analysis/LoopInfo.cpp:1.26
--- llvm/lib/Analysis/LoopInfo.cpp:1.25 Sun Sep 29 17:59:29 2002
+++ llvm/lib/Analysis/LoopInfo.cpp Fri Oct 11 00:30:13 2002
@@ -24,6 +24,30 @@
return find(Blocks.begin(), Blocks.end(), BB) != Blocks.end();
}
+bool Loop::isLoopExit(const BasicBlock *BB) const {
+ for (BasicBlock::succ_const_iterator SI = succ_begin(BB), SE = succ_end(BB);
+ SI != SE; ++SI) {
+ if (! contains(*SI))
+ return true;
+ }
+ return false;
+}
+
+unsigned Loop::getNumBackEdges() const {
+ unsigned numBackEdges = 0;
+ BasicBlock *header = Blocks.front();
+
+ for (std::vector<BasicBlock*>::const_iterator i = Blocks.begin(), e = Blocks.end();
+ i != e; ++i) {
+ for (BasicBlock::succ_iterator Successor = succ_begin(*i), SEnd = succ_end(*i);
+ Successor != SEnd; ++Successor) {
+ if (header == *Successor)
+ ++numBackEdges;
+ }
+ }
+ return numBackEdges;
+}
+
void Loop::print(std::ostream &OS) const {
OS << std::string(getLoopDepth()*2, ' ') << "Loop Containing: ";
More information about the llvm-commits
mailing list