From 1c54f1da79a68b22cb093f5bfaed3f8bbdc2b966 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 21 Jun 2001 05:26:15 +0000 Subject: [PATCH] Implement the new Interval::isLoop method Implement destructor to free memory git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/Interval.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/Analysis/Interval.cpp b/lib/Analysis/Interval.cpp index ac4846ae620..05cfa7560b2 100644 --- a/lib/Analysis/Interval.cpp +++ b/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 static inline void deleter(T *Ptr) { delete Ptr; } + +// Destructor - Free memory +IntervalPartition::~IntervalPartition() { + for_each(begin(), end(), deleter); +} + + // getNodeHeader - Given a source graph node and the source graph, return the // BasicBlock that is the header node. This is the opposite of // getSourceGraphNode. -- 2.34.1