summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-08-18 04:30:35 +0000
committerChris Lattner <sabre@nondot.org>2009-08-18 04:30:35 +0000
commit523d2f6e2c6e14a57da815f7d8eefcb2f3cffd30 (patch)
treeba6a235ce22aee55be7fcd57da018393ad22ced3 /llvm/lib/CodeGen/MachineBasicBlock.cpp
parentdd1db9cc812e7b6a867e02c2d45753594d7dc89b (diff)
downloadbcm5719-llvm-523d2f6e2c6e14a57da815f7d8eefcb2f3cffd30.tar.gz
bcm5719-llvm-523d2f6e2c6e14a57da815f7d8eefcb2f3cffd30.zip
turn this conditional into something humans might actually
be able to understand ;-) llvm-svn: 79311
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp33
1 files changed, 25 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index b30a3fcf300..eacc8973d13 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -128,14 +128,31 @@ MachineBasicBlock::iterator MachineBasicBlock::getFirstTerminator() {
return I;
}
-bool
-MachineBasicBlock::isOnlyReachableByFallthrough() const {
- return !isLandingPad() &&
- !pred_empty() &&
- next(pred_begin()) == pred_end() &&
- (*pred_begin())->isLayoutSuccessor(this) &&
- ((*pred_begin())->empty() ||
- !(*pred_begin())->back().getDesc().isBarrier());
+bool MachineBasicBlock::isOnlyReachableByFallthrough() const {
+ // If this is a landing pad, it isn't a fall through. If it has no preds,
+ // then nothing falls through to it.
+ if (isLandingPad() || pred_empty())
+ return false;
+
+ // If there isn't exactly one predecessor, it can't be a fall through.
+ const_pred_iterator PI = pred_begin(), PI2 = PI;
+ ++PI;
+ if (PI != pred_end())
+ return false;
+
+ // The predecessor has to be immediately before this block.
+ const MachineBasicBlock *Pred = *PI;
+
+ if (!Pred->isLayoutSuccessor(this))
+ return false;
+
+ // If the block is completely empty, then it definitely does fall through.
+ if (Pred->empty())
+ return true;
+
+ // Otherwise, check the last instruction.
+ const MachineInstr &LastInst = Pred->back();
+ return LastInst.getDesc().isBarrier();
}
void MachineBasicBlock::dump() const {
OpenPOWER on IntegriCloud