private:
friend class LoopInfo;
inline Loop(const BasicBlock *BB) { Blocks.push_back(BB); LoopDepth = 0; }
+ ~Loop() {
+ for (unsigned i = 0, e = SubLoops.size(); i != e; ++i)
+ delete SubLoops[i];
+ }
void setLoopDepth(unsigned Level) {
LoopDepth = Level;
- for (unsigned i = 0; i < SubLoops.size(); ++i)
+ for (unsigned i = 0, e = SubLoops.size(); i != e; ++i)
SubLoops[i]->setLoopDepth(Level+1);
}
};
//===----------------------------------------------------------------------===//
// LoopInfo - This class builds and contains all of the top level loop
-// structures in the specified method.
+// structures in the specified function.
//
-class LoopInfo : public MethodPass {
+class LoopInfo : public FunctionPass {
// BBMap - Mapping of basic blocks to the inner most loop they occur in
std::map<const BasicBlock *, Loop*> BBMap;
std::vector<Loop*> TopLevelLoops;
// LoopInfo ctor - Calculate the natural loop information for a CFG
LoopInfo(AnalysisID id) { assert(id == ID); }
+ ~LoopInfo() { releaseMemory(); }
const std::vector<Loop*> &getTopLevelLoops() const { return TopLevelLoops; }
bool isLoopExit(const BasicBlock *BB) const;
#endif
- // runOnMethod - Pass framework implementation
- virtual bool runOnMethod(Function *F);
+ // runOnFunction - Pass framework implementation
+ virtual bool runOnFunction(Function *F);
+
+ virtual void releaseMemory();
- // getAnalysisUsageInfo - Provide loop info, require dominator set
+ // getAnalysisUsage - Provide loop info, require dominator set
//
- virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
- Pass::AnalysisSet &Destroyed,
- Pass::AnalysisSet &Provided);
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const;
+
private:
void Calculate(const DominatorSet &DS);
Loop *ConsiderForLoop(const BasicBlock *BB, const DominatorSet &DS);