summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/Interval.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-06-21 05:26:15 +0000
committerChris Lattner <sabre@nondot.org>2001-06-21 05:26:15 +0000
commitd79faa35afaea7f00d624dfa3f38485efe1cb852 (patch)
treeda580e59b319a858307f44fa7e29afd30f09082c /llvm/lib/Analysis/Interval.cpp
parentd52706daa85424c02c8dfeec216a533fce2b0dac (diff)
downloadbcm5719-llvm-d79faa35afaea7f00d624dfa3f38485efe1cb852.tar.gz
bcm5719-llvm-d79faa35afaea7f00d624dfa3f38485efe1cb852.zip
Implement the new Interval::isLoop method
Implement destructor to free memory llvm-svn: 51
Diffstat (limited to 'llvm/lib/Analysis/Interval.cpp')
-rw-r--r--llvm/lib/Analysis/Interval.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/Interval.cpp b/llvm/lib/Analysis/Interval.cpp
index ac4846ae620..05cfa7560b2 100644
--- a/llvm/lib/Analysis/Interval.cpp
+++ b/llvm/lib/Analysis/Interval.cpp
@@ -12,6 +12,35 @@
using namespace cfg;
+//===----------------------------------------------------------------------===//
+// Interval Implementation
+//===----------------------------------------------------------------------===//
+
+// isLoop - Find out if there is a back edge in this interval...
+//
+bool Interval::isLoop() const {
+ // There is a loop in this interval iff one of the predecessors of the header
+ // node lives in the interval.
+ for (BasicBlock::pred_iterator I = pred_begin(HeaderNode),
+ E = pred_end(HeaderNode); I != E; ++I) {
+ if (contains(*I)) return true;
+ }
+ return false;
+}
+
+
+//===----------------------------------------------------------------------===//
+// IntervalPartition Implementation
+//===----------------------------------------------------------------------===//
+
+template <class T> static inline void deleter(T *Ptr) { delete Ptr; }
+
+// Destructor - Free memory
+IntervalPartition::~IntervalPartition() {
+ for_each(begin(), end(), deleter<cfg::Interval>);
+}
+
+
// getNodeHeader - Given a source graph node and the source graph, return the
// BasicBlock that is the header node. This is the opposite of
// getSourceGraphNode.
OpenPOWER on IntegriCloud