summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-03-16 06:00:15 +0000
committerChris Lattner <sabre@nondot.org>2004-03-16 06:00:15 +0000
commitdb5b8f4d6b6817cb7b8237cb2d83011d9a339979 (patch)
treec05f3db996f91396b91674d2cf09a6a42b6cc8a9 /llvm/lib
parent767858af4319c9e9794ebca4839e980d154fa081 (diff)
downloadbcm5719-llvm-db5b8f4d6b6817cb7b8237cb2d83011d9a339979.tar.gz
bcm5719-llvm-db5b8f4d6b6817cb7b8237cb2d83011d9a339979.zip
Fix a regression from this patch:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20040308/013095.html Basically, this patch only updated the immediate dominatees of the header node to tell them that the preheader also dominated them. In practice, ALL dominatees of the header node are also dominated by the preheader. This fixes: LoopSimplify/2004-03-15-IncorrectDomUpdate. and PR293 llvm-svn: 12434
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopSimplify.cpp29
1 files changed, 13 insertions, 16 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopSimplify.cpp b/llvm/lib/Transforms/Scalar/LoopSimplify.cpp
index 6fbf261835a..120f0297643 100644
--- a/llvm/lib/Transforms/Scalar/LoopSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopSimplify.cpp
@@ -312,31 +312,28 @@ void LoopSimplify::InsertPreheaderForLoop(Loop *L) {
DominatorSet &DS = getAnalysis<DominatorSet>(); // Update dominator info
DominatorTree &DT = getAnalysis<DominatorTree>();
- DominatorTree::Node *HeaderDTNode = DT.getNode(Header);
+
+
+ // Update the dominator tree information.
+ // The immediate dominator of the preheader is the immediate dominator of
+ // the old header.
+ DominatorTree::Node *PHDomTreeNode =
+ DT.createNewNode(NewBB, DT.getNode(Header)->getIDom());
+
+ // Change the header node so that PNHode is the new immediate dominator
+ DT.changeImmediateDominator(DT.getNode(Header), PHDomTreeNode);
{
// 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 (DominatorTree::Node::iterator I = HeaderDTNode->begin(),
- E = HeaderDTNode->end(); I != E; ++I)
- DS.addDominator((*I)->getBlock(), NewBB);
- }
-
- { // Update the dominator tree information.
- // The immediate dominator of the preheader is the immediate dominator of
- // the old header.
- //
- DominatorTree::Node *PHNode =
- DT.createNewNode(NewBB, HeaderDTNode->getIDom());
-
- // Change the header node so that PNHode is the new immediate dominator
- DT.changeImmediateDominator(HeaderDTNode, PHNode);
+ for (df_iterator<DominatorTree::Node*> DFI = df_begin(PHDomTreeNode),
+ E = df_end(PHDomTreeNode); DFI != E; ++DFI)
+ DS.addDominator((*DFI)->getBlock(), NewBB);
}
// Update immediate dominator information if we have it...
OpenPOWER on IntegriCloud