diff options
author | Chris Lattner <sabre@nondot.org> | 2004-03-16 06:00:15 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-03-16 06:00:15 +0000 |
commit | 85ebd541faf03a00d20ce3bdaf133aa6948c64f8 (patch) | |
tree | 9de269b7e1b29c6c950c1f0fc88556a7543b90df /lib/Transforms/Utils | |
parent | 339c50873de75ad7db9ab57d64cb4db70035709b (diff) | |
download | external_llvm-85ebd541faf03a00d20ce3bdaf133aa6948c64f8.zip external_llvm-85ebd541faf03a00d20ce3bdaf133aa6948c64f8.tar.gz external_llvm-85ebd541faf03a00d20ce3bdaf133aa6948c64f8.tar.bz2 |
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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12434 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r-- | lib/Transforms/Utils/LoopSimplify.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp index 6fbf261..120f029 100644 --- a/lib/Transforms/Utils/LoopSimplify.cpp +++ b/lib/Transforms/Utils/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... |