Remove ADCE's ability to delete loops. This ability is now implemented in a

safer manner by loop deletion.

llvm-svn: 51182
This commit is contained in:
Owen Anderson 2008-05-16 04:34:51 +00:00
parent bdcf408d67
commit c7d6eceb69
1 changed files with 21 additions and 4 deletions

View File

@ -191,10 +191,18 @@ bool ADCE::doADCE() {
// be eliminated later, along with the instructions inside. // be eliminated later, along with the instructions inside.
// //
std::set<BasicBlock*> ReachableBBs; std::set<BasicBlock*> ReachableBBs;
for (df_ext_iterator<BasicBlock*> std::vector<BasicBlock*> Stack;
BBI = df_ext_begin(&Func->front(), ReachableBBs), Stack.push_back(&Func->getEntryBlock());
BBE = df_ext_end(&Func->front(), ReachableBBs); BBI != BBE; ++BBI) {
BasicBlock *BB = *BBI; while (!Stack.empty()) {
BasicBlock* BB = Stack.back();
if (ReachableBBs.count(BB)) {
Stack.pop_back();
continue;
} else {
ReachableBBs.insert(BB);
}
for (BasicBlock::iterator II = BB->begin(), EI = BB->end(); II != EI; ) { for (BasicBlock::iterator II = BB->begin(), EI = BB->end(); II != EI; ) {
Instruction *I = II++; Instruction *I = II++;
if (CallInst *CI = dyn_cast<CallInst>(I)) { if (CallInst *CI = dyn_cast<CallInst>(I)) {
@ -217,6 +225,15 @@ bool ADCE::doADCE() {
++NumInstRemoved; ++NumInstRemoved;
} }
} }
for (succ_iterator SI = succ_begin(BB), SE = succ_end(BB); SI != SE; ++SI) {
// Back edges (as opposed to cross edges) indicate loops, so implicitly
// mark them live.
if (std::find(Stack.begin(), Stack.end(), *SI) != Stack.end())
markInstructionLive(BB->getTerminator());
if (!ReachableBBs.count(*SI))
Stack.push_back(*SI);
}
} }
// Check to ensure we have an exit node for this CFG. If we don't, we won't // Check to ensure we have an exit node for this CFG. If we don't, we won't