mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-30 02:25:19 +00:00
Stop a memory leak, and update some comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28693 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -52,7 +52,7 @@ namespace {
|
|||||||
LoopInfo *LI; // Loop information
|
LoopInfo *LI; // Loop information
|
||||||
DominatorTree *DT; // Dominator Tree for the current Function...
|
DominatorTree *DT; // Dominator Tree for the current Function...
|
||||||
DominanceFrontier *DF; // Current Dominance Frontier
|
DominanceFrontier *DF; // Current Dominance Frontier
|
||||||
std::vector<BasicBlock*> *LoopBlocks;
|
std::vector<BasicBlock*> LoopBlocks;
|
||||||
|
|
||||||
virtual bool runOnFunction(Function &F);
|
virtual bool runOnFunction(Function &F);
|
||||||
bool visitSubloop(Loop* L);
|
bool visitSubloop(Loop* L);
|
||||||
@@ -76,8 +76,9 @@ namespace {
|
|||||||
Instruction *getValueDominatingBlock(BasicBlock *BB,
|
Instruction *getValueDominatingBlock(BasicBlock *BB,
|
||||||
std::map<BasicBlock*, Instruction*>& PotDoms);
|
std::map<BasicBlock*, Instruction*>& PotDoms);
|
||||||
|
|
||||||
bool inLoopBlocks(BasicBlock* B) { return std::binary_search(
|
/// inLoop - returns true if the given block is within the current loop
|
||||||
LoopBlocks->begin(), LoopBlocks->end(), B); }
|
const bool inLoop(BasicBlock* B) {
|
||||||
|
return std::binary_search(LoopBlocks.begin(), LoopBlocks.end(), B); }
|
||||||
};
|
};
|
||||||
|
|
||||||
RegisterOpt<LCSSA> X("lcssa", "Loop-Closed SSA Form Pass");
|
RegisterOpt<LCSSA> X("lcssa", "Loop-Closed SSA Form Pass");
|
||||||
@@ -90,7 +91,6 @@ bool LCSSA::runOnFunction(Function &F) {
|
|||||||
LI = &getAnalysis<LoopInfo>();
|
LI = &getAnalysis<LoopInfo>();
|
||||||
DF = &getAnalysis<DominanceFrontier>();
|
DF = &getAnalysis<DominanceFrontier>();
|
||||||
DT = &getAnalysis<DominatorTree>();
|
DT = &getAnalysis<DominatorTree>();
|
||||||
LoopBlocks = new std::vector<BasicBlock*>;
|
|
||||||
|
|
||||||
for (LoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I) {
|
for (LoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I) {
|
||||||
changed |= visitSubloop(*I);
|
changed |= visitSubloop(*I);
|
||||||
@@ -104,9 +104,9 @@ bool LCSSA::visitSubloop(Loop* L) {
|
|||||||
visitSubloop(*I);
|
visitSubloop(*I);
|
||||||
|
|
||||||
// Speed up queries by creating a sorted list of blocks
|
// Speed up queries by creating a sorted list of blocks
|
||||||
LoopBlocks->clear();
|
LoopBlocks.clear();
|
||||||
LoopBlocks->insert(LoopBlocks->end(), L->block_begin(), L->block_end());
|
LoopBlocks.insert(LoopBlocks.end(), L->block_begin(), L->block_end());
|
||||||
std::sort(LoopBlocks->begin(), LoopBlocks->end());
|
std::sort(LoopBlocks.begin(), LoopBlocks.end());
|
||||||
|
|
||||||
SetVector<Instruction*> AffectedValues = getLoopValuesUsedOutsideLoop(L);
|
SetVector<Instruction*> AffectedValues = getLoopValuesUsedOutsideLoop(L);
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ bool LCSSA::visitSubloop(Loop* L) {
|
|||||||
processInstruction(*I, exitBlocks);
|
processInstruction(*I, exitBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true; // FIXME: Should be more intelligent in our return value.
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// processInstruction -
|
/// processInstruction -
|
||||||
@@ -205,7 +205,7 @@ void LCSSA::processInstruction(Instruction* Instr,
|
|||||||
UI != UE; ++UI) {
|
UI != UE; ++UI) {
|
||||||
Instruction* use = cast<Instruction>(*UI);
|
Instruction* use = cast<Instruction>(*UI);
|
||||||
// Don't need to update uses within the loop body.
|
// Don't need to update uses within the loop body.
|
||||||
if (!inLoopBlocks(use->getParent()))
|
if (!inLoop(use->getParent()))
|
||||||
Uses.push_back(use);
|
Uses.push_back(use);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ SetVector<Instruction*> LCSSA::getLoopValuesUsedOutsideLoop(Loop *L) {
|
|||||||
for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E;
|
for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E;
|
||||||
++UI) {
|
++UI) {
|
||||||
BasicBlock *UserBB = cast<Instruction>(*UI)->getParent();
|
BasicBlock *UserBB = cast<Instruction>(*UI)->getParent();
|
||||||
if (!std::binary_search(LoopBlocks->begin(), LoopBlocks->end(), UserBB))
|
if (!std::binary_search(LoopBlocks.begin(), LoopBlocks.end(), UserBB))
|
||||||
{
|
{
|
||||||
AffectedValues.insert(I);
|
AffectedValues.insert(I);
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user