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/Transforms/Utils/BasicBlockUtils.cpp | |
| parent | 6144c1de6a7674dad94290650e4e14f24d42e421 (diff) | |
Notes
Diffstat (limited to 'lib/Transforms/Utils/BasicBlockUtils.cpp')
| -rw-r--r-- | lib/Transforms/Utils/BasicBlockUtils.cpp | 25 | 
1 files changed, 8 insertions, 17 deletions
| diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp index ec625b4cbb28f..093083a630cf3 100644 --- a/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -97,23 +97,13 @@ bool llvm::DeleteDeadPHIs(BasicBlock *BB) {  /// MergeBlockIntoPredecessor - Attempts to merge a block into its predecessor,  /// if possible.  The return value indicates success or failure.  bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, Pass *P) { -  pred_iterator PI(pred_begin(BB)), PE(pred_end(BB)); -  // Can't merge the entry block.  Don't merge away blocks who have their -  // address taken: this is a bug if the predecessor block is the entry node -  // (because we'd end up taking the address of the entry) and undesirable in -  // any case. -  if (pred_begin(BB) == pred_end(BB) || -      BB->hasAddressTaken()) return false; +  // Don't merge away blocks who have their address taken. +  if (BB->hasAddressTaken()) return false; -  BasicBlock *PredBB = *PI++; -  for (; PI != PE; ++PI)  // Search all predecessors, see if they are all same -    if (*PI != PredBB) { -      PredBB = 0;       // There are multiple different predecessors... -      break; -    } -   -  // Can't merge if there are multiple predecessors. +  // Can't merge if there are multiple predecessors, or no predecessors. +  BasicBlock *PredBB = BB->getUniquePredecessor();    if (!PredBB) return false; +    // Don't break self-loops.    if (PredBB == BB) return false;    // Don't break invokes. @@ -267,7 +257,7 @@ void llvm::RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum) {    case Instruction::Switch:    // Should remove entry    default:    case Instruction::Ret:       // Cannot happen, has no successors! -    llvm_unreachable("Unhandled terminator instruction type in RemoveSuccessor!"); +    llvm_unreachable("Unhandled terminator inst type in RemoveSuccessor!");    }    if (NewTI)   // If it's a different instruction, replace. @@ -421,7 +411,8 @@ BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB,    DominatorTree *DT = P ? P->getAnalysisIfAvailable<DominatorTree>() : 0;    if (DT)      DT->splitBlock(NewBB); -  if (DominanceFrontier *DF = P ? P->getAnalysisIfAvailable<DominanceFrontier>():0) +  if (DominanceFrontier *DF = +        P ? P->getAnalysisIfAvailable<DominanceFrontier>() : 0)      DF->splitBlock(NewBB);    // Insert a new PHI node into NewBB for every PHI node in BB and that new PHI | 
