diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2010-09-17 15:48:55 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2010-09-17 15:48:55 +0000 | 
| commit | d39c594d39df7f283c2fb8a704a3f31c501180d9 (patch) | |
| tree | 36453626c792cccd91f783a38a169d610a6b9db9 /lib/CodeGen/MachineBasicBlock.cpp | |
| parent | 6144c1de6a7674dad94290650e4e14f24d42e421 (diff) | |
Notes
Diffstat (limited to 'lib/CodeGen/MachineBasicBlock.cpp')
| -rw-r--r-- | lib/CodeGen/MachineBasicBlock.cpp | 32 | 
1 files changed, 27 insertions, 5 deletions
diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index a27ee479433b..50f3f672dced 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/lib/CodeGen/MachineBasicBlock.cpp @@ -441,7 +441,7 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) {    MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock();    MF->insert(llvm::next(MachineFunction::iterator(this)), NMBB); -  DEBUG(dbgs() << "PHIElimination splitting critical edge:" +  DEBUG(dbgs() << "Splitting critical edge:"          " BB#" << getNumber()          << " -- BB#" << NMBB->getNumber()          << " -- BB#" << Succ->getNumber() << '\n'); @@ -468,11 +468,33 @@ 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 (MachineLoopInfo *MLI = P->getAnalysisIfAvailable<MachineLoopInfo>())      if (MachineLoop *TIL = MLI->getLoopFor(this)) {        // If one or the other blocks were not in a loop, the new block is not        // either, and thus LI doesn't need to be updated.  | 
