diff options
author | Evan Cheng <evan.cheng@apple.com> | 2010-08-19 23:32:47 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2010-08-19 23:32:47 +0000 |
commit | 63a868457b3e48d3539631bf67e66556f04773c4 (patch) | |
tree | 8fef9023ec7de7c26cfa0cfec1c0de6df2e6766a | |
parent | a03c296e7997b86f6ff8b18cd7294e23e7e5e40b (diff) | |
download | bcm5719-llvm-63a868457b3e48d3539631bf67e66556f04773c4.tar.gz bcm5719-llvm-63a868457b3e48d3539631bf67e66556f04773c4.zip |
Properly update MachineDominators when splitting critical edge.
llvm-svn: 111574
-rw-r--r-- | llvm/lib/CodeGen/MachineBasicBlock.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index d351db59e69..50f3f672dce 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -468,8 +468,31 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) { LV->addNewBlock(NMBB, this, Succ); if (MachineDominatorTree *MDT = - P->getAnalysisIfAvailable<MachineDominatorTree>()) - MDT->addNewBlock(NMBB, this); + P->getAnalysisIfAvailable<MachineDominatorTree>()) { + // Update dominator information. + MachineDomTreeNode *SucccDTNode = MDT->getNode(Succ); + + bool IsNewIDom = true; + for (const_pred_iterator PI = Succ->pred_begin(), E = Succ->pred_end(); + PI != E; ++PI) { + MachineBasicBlock *PredBB = *PI; + if (PredBB == NMBB) + continue; + if (!MDT->dominates(SucccDTNode, MDT->getNode(PredBB))) { + IsNewIDom = false; + break; + } + } + + // We know "this" dominates the newly created basic block. + MachineDomTreeNode *NewDTNode = MDT->addNewBlock(NMBB, this); + + // If all the other predecessors of "Succ" are dominated by "Succ" itself + // then the new block is the new immediate dominator of "Succ". Otherwise, + // the new block doesn't dominate anything. + if (IsNewIDom) + MDT->changeImmediateDominator(SucccDTNode, NewDTNode); + } if (MachineLoopInfo *MLI = P->getAnalysisIfAvailable<MachineLoopInfo>()) if (MachineLoop *TIL = MLI->getLoopFor(this)) { |