diff options
author | Bill Wendling <isanbard@gmail.com> | 2009-12-11 03:14:18 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2009-12-11 03:14:18 +0000 |
commit | a1bce0c42eb778677eced182d9523c4d80f26c6a (patch) | |
tree | 83a356f4ad2f81e61878ba59bf9549eff0390736 /llvm/lib/CodeGen/MachineBasicBlock.cpp | |
parent | 9cb53b86af1e9d3b076c2228183a6bd20535c003 (diff) | |
download | bcm5719-llvm-a1bce0c42eb778677eced182d9523c4d80f26c6a.tar.gz bcm5719-llvm-a1bce0c42eb778677eced182d9523c4d80f26c6a.zip |
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.
llvm-svn: 91101
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBasicBlock.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 684af344940..7ce723e019a 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/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. |