Re-apply r80926, with fixes: keep the domtree informed of new blocks

that get created during loop unswitching, and fix SplitBlockPredecessors'
LCSSA updating code to create new PHIs instead of trying to just move
existing ones.

Also, optimize Loop::verifyLoop, since it gets called a lot. Use
searches on a sorted list of blocks instead of calling the "contains"
function, as is done in other places in the Loop class, since "contains"
does a linear search. Also, don't call verifyLoop from LoopSimplify or
LCSSA, as the PassManager is already calling verifyLoop as part of
LoopInfo's verifyAnalysis.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81221 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2009-09-08 15:45:00 +00:00
parent 6ca0b9e722
commit 5c89b5240c
12 changed files with 959 additions and 197 deletions

View File

@ -300,6 +300,9 @@ bool Loop::isLoopSimplifyForm() const {
///
void
Loop::getUniqueExitBlocks(SmallVectorImpl<BasicBlock *> &ExitBlocks) const {
assert(isLoopSimplifyForm() &&
"getUniqueExitBlocks assumes the loop is in canonical form!");
// Sort the blocks vector so that we can use binary search to do quick
// lookups.
SmallVector<BasicBlock *, 128> LoopBBs(block_begin(), block_end());
@ -371,6 +374,13 @@ bool LoopInfo::runOnFunction(Function &) {
return false;
}
void LoopInfo::verifyAnalysis() const {
for (iterator I = begin(), E = end(); I != E; ++I) {
assert(!(*I)->getParentLoop() && "Top-level loop has a parent!");
(*I)->verifyLoopNest();
}
}
void LoopInfo::getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
AU.addRequired<DominatorTree>();