[llvm-commits] [llvm] r40035 - /llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp
Devang Patel
dpatel at apple.com
Wed Jul 18 19:29:25 PDT 2007
Author: dpatel
Date: Wed Jul 18 21:29:24 2007
New Revision: 40035
URL: http://llvm.org/viewvc/llvm-project?rev=40035&view=rev
Log:
After a basic block is split into two parts,
second part dominates all the blocks dominated
by original basic block. And first part dominates
second part.
Modified:
llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp
Modified: llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp?rev=40035&r1=40034&r2=40035&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp Wed Jul 18 21:29:24 2007
@@ -165,8 +165,21 @@
if (Loop *L = LI.getLoopFor(Old))
L->addBasicBlockToLoop(New, LI);
- if (DominatorTree *DT = P->getAnalysisToUpdate<DominatorTree>())
- DT->addNewBlock(New, Old);
+ if (DominatorTree *DT = P->getAnalysisToUpdate<DominatorTree>())
+ {
+ // Old dominates New. New node domiantes all other nodes dominated by Old.
+ DomTreeNode *OldNode = DT->getNode(Old);
+ std::vector<DomTreeNode *> Children;
+ for (DomTreeNode::iterator I = OldNode->begin(), E = OldNode->end();
+ I != E; ++I)
+ Children.push_back(*I);
+
+ DomTreeNode *NewNode = DT->addNewBlock(New,Old);
+
+ for (std::vector<DomTreeNode *>::iterator I = Children.begin(),
+ E = Children.end(); I != E; ++I)
+ DT->changeImmediateDominator(*I, NewNode);
+ }
if (DominanceFrontier *DF = P->getAnalysisToUpdate<DominanceFrontier>())
DF->splitBlock(Old);
More information about the llvm-commits
mailing list