mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-19 06:31:18 +00:00
Fix bug: ADCE/2003-06-11-InvalidCFG.ll
This was because we were deleting large chunks of functions without an exit block, because the post-dominance information was not useful. This broke crafty and twolf. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6698 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
02da6c0f08
commit
34e353e560
@ -166,6 +166,16 @@ bool ADCE::doADCE() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check to ensure we have an exit node for this CFG. If we don't, we won't
|
||||||
|
// have any post-dominance information, thus we cannot perform our
|
||||||
|
// transformations safely.
|
||||||
|
//
|
||||||
|
PostDominatorTree &DT = getAnalysis<PostDominatorTree>();
|
||||||
|
if (DT[&Func->getEntryNode()] == 0) {
|
||||||
|
WorkList.clear();
|
||||||
|
return MadeChanges;
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG(std::cerr << "Processing work list\n");
|
DEBUG(std::cerr << "Processing work list\n");
|
||||||
|
|
||||||
// AliveBlocks - Set of basic blocks that we know have instructions that are
|
// AliveBlocks - Set of basic blocks that we know have instructions that are
|
||||||
@ -208,19 +218,18 @@ bool ADCE::doADCE() {
|
|||||||
|
|
||||||
DEBUG(
|
DEBUG(
|
||||||
std::cerr << "Current Function: X = Live\n";
|
std::cerr << "Current Function: X = Live\n";
|
||||||
for (Function::iterator I = Func->begin(), E = Func->end(); I != E; ++I)
|
for (Function::iterator I = Func->begin(), E = Func->end(); I != E; ++I){
|
||||||
|
std::cerr << I->getName() << ":\t"
|
||||||
|
<< (AliveBlocks.count(I) ? "LIVE\n" : "DEAD\n");
|
||||||
for (BasicBlock::iterator BI = I->begin(), BE = I->end(); BI != BE; ++BI){
|
for (BasicBlock::iterator BI = I->begin(), BE = I->end(); BI != BE; ++BI){
|
||||||
if (LiveSet.count(BI)) std::cerr << "X ";
|
if (LiveSet.count(BI)) std::cerr << "X ";
|
||||||
std::cerr << *BI;
|
std::cerr << *BI;
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
|
|
||||||
// Find the first postdominator of the entry node that is alive. Make it the
|
// Find the first postdominator of the entry node that is alive. Make it the
|
||||||
// new entry node...
|
// new entry node...
|
||||||
//
|
//
|
||||||
PostDominatorTree &DT = getAnalysis<PostDominatorTree>();
|
|
||||||
|
|
||||||
|
|
||||||
if (AliveBlocks.size() == Func->size()) { // No dead blocks?
|
if (AliveBlocks.size() == Func->size()) { // No dead blocks?
|
||||||
for (Function::iterator I = Func->begin(), E = Func->end(); I != E; ++I)
|
for (Function::iterator I = Func->begin(), E = Func->end(); I != E; ++I)
|
||||||
// Loop over all of the instructions in the function, telling dead
|
// Loop over all of the instructions in the function, telling dead
|
||||||
|
Loading…
x
Reference in New Issue
Block a user