mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 06:33:24 +00:00
Don't leak all of the Loop objects created...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2196 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1d21f3eb1d
commit
918c4ecb0c
@ -46,10 +46,14 @@ public:
|
|||||||
private:
|
private:
|
||||||
friend class LoopInfo;
|
friend class LoopInfo;
|
||||||
inline Loop(const BasicBlock *BB) { Blocks.push_back(BB); LoopDepth = 0; }
|
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) {
|
void setLoopDepth(unsigned Level) {
|
||||||
LoopDepth = 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);
|
SubLoops[i]->setLoopDepth(Level+1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -69,6 +73,7 @@ public:
|
|||||||
|
|
||||||
// LoopInfo ctor - Calculate the natural loop information for a CFG
|
// LoopInfo ctor - Calculate the natural loop information for a CFG
|
||||||
LoopInfo(AnalysisID id) { assert(id == ID); }
|
LoopInfo(AnalysisID id) { assert(id == ID); }
|
||||||
|
~LoopInfo() { releaseMemory(); }
|
||||||
|
|
||||||
const std::vector<Loop*> &getTopLevelLoops() const { return TopLevelLoops; }
|
const std::vector<Loop*> &getTopLevelLoops() const { return TopLevelLoops; }
|
||||||
|
|
||||||
@ -103,6 +108,8 @@ public:
|
|||||||
// runOnMethod - Pass framework implementation
|
// runOnMethod - Pass framework implementation
|
||||||
virtual bool runOnMethod(Function *F);
|
virtual bool runOnMethod(Function *F);
|
||||||
|
|
||||||
|
virtual void releaseMemory();
|
||||||
|
|
||||||
// getAnalysisUsageInfo - Provide loop info, require dominator set
|
// getAnalysisUsageInfo - Provide loop info, require dominator set
|
||||||
//
|
//
|
||||||
virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
|
virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
|
||||||
|
@ -22,13 +22,21 @@ bool cfg::Loop::contains(const BasicBlock *BB) const {
|
|||||||
return find(Blocks.begin(), Blocks.end(), BB) != Blocks.end();
|
return find(Blocks.begin(), Blocks.end(), BB) != Blocks.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cfg::LoopInfo::releaseMemory() {
|
||||||
|
for (std::vector<Loop*>::iterator I = TopLevelLoops.begin(),
|
||||||
|
E = TopLevelLoops.end(); I != E; ++I)
|
||||||
|
delete *I; // Delete all of the loops...
|
||||||
|
|
||||||
|
BBMap.clear(); // Reset internal state of analysis
|
||||||
|
TopLevelLoops.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// cfg::LoopInfo implementation
|
// cfg::LoopInfo implementation
|
||||||
//
|
//
|
||||||
bool cfg::LoopInfo::runOnMethod(Function *F) {
|
bool cfg::LoopInfo::runOnMethod(Function *F) {
|
||||||
BBMap.clear(); // Reset internal state of analysis
|
releaseMemory();
|
||||||
TopLevelLoops.clear();
|
|
||||||
Calculate(getAnalysis<DominatorSet>()); // Update
|
Calculate(getAnalysis<DominatorSet>()); // Update
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user