summaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2009-12-11 03:14:18 +0000
committerBill Wendling <isanbard@gmail.com>2009-12-11 03:14:18 +0000
commit64bdde2093f461f10c095d08d53dc57c6612ce69 (patch)
tree1addb1cedf976837572c052cd034fbc2323b67c8 /lib/CodeGen/MachineBasicBlock.cpp
parent4bde1ab82d4a520dca59db1fd212d77ac667b3a8 (diff)
downloadllvm-64bdde2093f461f10c095d08d53dc57c6612ce69.tar.gz
llvm-64bdde2093f461f10c095d08d53dc57c6612ce69.tar.bz2
llvm-64bdde2093f461f10c095d08d53dc57c6612ce69.tar.xz
Address comments on last patch:
- Loosen the restrictions when checking of it branches to a landing pad. - Make the loop more efficient by checking the '.insert' return value. - Do cheaper checks first. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91101 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r--lib/CodeGen/MachineBasicBlock.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp
index 684af34494..7ce723e019 100644
--- a/lib/CodeGen/MachineBasicBlock.cpp
+++ b/lib/CodeGen/MachineBasicBlock.cpp
@@ -449,24 +449,19 @@ void MachineBasicBlock::ReplaceUsesOfBlockWith(MachineBasicBlock *Old,
addSuccessor(New);
}
-/// BranchesToLandingPad - The basic block branches only to a landing pad or to
-/// another basic block which branches only to a landing pad. No other
-/// instructions are present other than the unconditional branch.
+/// BranchesToLandingPad - The basic block is a landing pad or branches only to
+/// a landing pad. No other instructions are present other than the
+/// unconditional branch.
bool
MachineBasicBlock::BranchesToLandingPad(const MachineBasicBlock *MBB) const {
SmallSet<const MachineBasicBlock*, 32> Visited;
const MachineBasicBlock *CurMBB = MBB;
- while (!Visited.count(CurMBB) && !CurMBB->isLandingPad()) {
- if (CurMBB->size() != 1 || CurMBB->succ_empty() || CurMBB->succ_size() != 1)
+ while (!CurMBB->isLandingPad()) {
+ if (CurMBB->succ_size() != 1)
break;
- const TargetInstrInfo *TII =
- CurMBB->getParent()->getTarget().getInstrInfo();
- if (!TII->isUnpredicatedTerminator(CurMBB->begin()))
- break;
-
- Visited.insert(CurMBB);
+ if (!Visited.insert(CurMBB)) break;
CurMBB = *CurMBB->succ_begin();
}
@@ -516,8 +511,8 @@ bool MachineBasicBlock::CorrectExtraCFGEdges(MachineBasicBlock *DestA,
} else if (MBB == DestB) {
DestB = 0;
++SI;
- } else if (BranchesToLandingPad(MBB) &&
- MBB != OrigDestA && MBB != OrigDestB) {
+ } else if (MBB != OrigDestA && MBB != OrigDestB &&
+ BranchesToLandingPad(MBB)) {
++SI;
} else {
// Otherwise, this is a superfluous edge, remove it.