aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-09-29 21:41:38 +0000
committerChris Lattner <sabre@nondot.org>2002-09-29 21:41:38 +0000
commit4d01892e36cc8ea4537b32dd71f11d767edeeef2 (patch)
tree667cc4e393d08ab1c7bbb0e9786ac57258a248bf
parent934487a9cc05c8c1696b09073a9ff6ecee8ef905 (diff)
downloadexternal_llvm-4d01892e36cc8ea4537b32dd71f11d767edeeef2.zip
external_llvm-4d01892e36cc8ea4537b32dd71f11d767edeeef2.tar.gz
external_llvm-4d01892e36cc8ea4537b32dd71f11d767edeeef2.tar.bz2
Fix major bugs in dominator set & tree information updating
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3975 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Utils/LoopSimplify.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp
index 76cc32e..1432b1c 100644
--- a/lib/Transforms/Utils/LoopSimplify.cpp
+++ b/lib/Transforms/Utils/LoopSimplify.cpp
@@ -153,14 +153,18 @@ void Preheaders::InsertPreheaderForLoop(Loop *L) {
// Update dominator information if it is around...
if (DominatorSet *DS = getAnalysisToUpdate<DominatorSet>()) {
- // We need to add information about the fact that NewBB dominates Header.
- DS->addDominator(Header, NewBB);
-
// The blocks that dominate NewBB are the blocks that dominate Header,
// minus Header, plus NewBB.
DominatorSet::DomSetType DomSet = DS->getDominators(Header);
+ DomSet.insert(NewBB); // We dominate ourself
DomSet.erase(Header); // Header does not dominate us...
DS->addBasicBlock(NewBB, DomSet);
+
+ // The newly created basic block dominates all nodes dominated by Header.
+ for (Function::iterator I = Header->getParent()->begin(),
+ E = Header->getParent()->end(); I != E; ++I)
+ if (DS->dominates(Header, I))
+ DS->addDominator(I, NewBB);
}
// Update immediate dominator information if we have it...
@@ -178,11 +182,10 @@ void Preheaders::InsertPreheaderForLoop(Loop *L) {
// the old header.
//
DominatorTree::Node *HeaderNode = DT->getNode(Header);
- DominatorTree::Node *PHNode = DT->createNewNode(NewBB, HeaderNode);
+ DominatorTree::Node *PHNode = DT->createNewNode(NewBB,
+ HeaderNode->getIDom());
// Change the header node so that PNHode is the new immediate dominator
DT->changeImmediateDominator(HeaderNode, PHNode);
}
}
-
-