summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-08-17 17:07:02 +0000
committerDan Gohman <gohman@apple.com>2010-08-17 17:07:02 +0000
commit941020ed729cdd37592caaf361939665491cd443 (patch)
tree07f49cac0c2eafffe9fd12ac508caf5f078bbede /llvm/lib/Transforms/Utils
parent896bd7e932e550d0eb8d11a56176e260027ec7f1 (diff)
downloadbcm5719-llvm-941020ed729cdd37592caaf361939665491cd443.tar.gz
bcm5719-llvm-941020ed729cdd37592caaf361939665491cd443.zip
Use the getUniquePredecessor() utility function, instead of doing
what it does manually. llvm-svn: 111248
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/BasicBlockUtils.cpp20
1 files changed, 5 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index ec625b4cbb2..c28b0275567 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/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.
OpenPOWER on IntegriCloud