aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-09-24 00:09:26 +0000
committerChris Lattner <sabre@nondot.org>2002-09-24 00:09:26 +0000
commit3abb95df01ff2ea5a6a35a1b47351072d4cb4c73 (patch)
tree184dc5b842b9de828594b6e71a1b8635721f0741 /lib/Transforms/Utils/SimplifyCFG.cpp
parentd76efa018660e806cd87c0a24512e3c532fc1d36 (diff)
Minor cleanups
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3904 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index 59ea9865af..f7eaa67acf 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -28,7 +28,9 @@
//
static bool PropogatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
assert(*succ_begin(BB) == Succ && "Succ is not successor of BB!");
- assert(isa<PHINode>(Succ->front()) && "Only works on PHId BBs!");
+
+ if (!isa<PHINode>(Succ->front()))
+ return false; // We can make the transformation, no problem.
// If there is more than one predecessor, and there are PHI nodes in
// the successor, then we need to add incoming edges for the PHI nodes
@@ -39,10 +41,9 @@ static bool PropogatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
// Succ. If so, we cannot do the transformation!
//
for (pred_iterator PI = pred_begin(Succ), PE = pred_end(Succ);
- PI != PE; ++PI) {
+ PI != PE; ++PI)
if (find(BBPreds.begin(), BBPreds.end(), *PI) != BBPreds.end())
return true;
- }
// Loop over all of the PHI nodes in the successor BB
for (BasicBlock::iterator I = Succ->begin();
@@ -118,11 +119,8 @@ bool SimplifyCFG(BasicBlock *BB) {
// Be careful though, if this transformation fails (returns true) then
// we cannot do this transformation!
//
- if (!isa<PHINode>(Succ->front()) ||
- !PropogatePredecessorsForPHIs(BB, Succ)) {
-
+ if (!PropogatePredecessorsForPHIs(BB, Succ)) {
//cerr << "Killing Trivial BB: \n" << BB;
-
BB->replaceAllUsesWith(Succ);
std::string OldName = BB->getName();