diff options
author | Dan Gohman <gohman@apple.com> | 2008-08-22 19:21:41 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-08-22 19:21:41 +0000 |
commit | e0182ec0e473ae2cd23f6451d2539b7ec449f04e (patch) | |
tree | 794de57abbaf68c28b66840e51ea0058fcea6d0e /lib/CodeGen/SelectionDAG/FastISel.cpp | |
parent | b4ae2da7e4bacbcfee146c30b03c568274b320b8 (diff) |
Support non-fallthrough unconditional branches in FastISel.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55191 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/FastISel.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/FastISel.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp index 1462472ea4..74174519fb 100644 --- a/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -145,6 +145,8 @@ BasicBlock::iterator FastISel::SelectInstructions(BasicBlock::iterator Begin, BasicBlock::iterator End, DenseMap<const Value*, unsigned> &ValueMap, + std::map<const BasicBlock*, + MachineBasicBlock *> &MBBMap, MachineBasicBlock *mbb) { MBB = mbb; BasicBlock::iterator I = Begin; @@ -195,19 +197,25 @@ FastISel::SelectInstructions(BasicBlock::iterator Begin, case Instruction::Br: { BranchInst *BI = cast<BranchInst>(I); - // For now, check for and handle just the most trivial case: an - // unconditional fall-through branch. if (BI->isUnconditional()) { - MachineFunction::iterator NextMBB = + MachineFunction::iterator NextMBB = next(MachineFunction::iterator(MBB)); - if (NextMBB != MF.end() && - NextMBB->getBasicBlock() == BI->getSuccessor(0)) { - MBB->addSuccessor(NextMBB); - break; + BasicBlock *LLVMSucc = BI->getSuccessor(0); + MachineBasicBlock *MSucc = MBBMap[LLVMSucc]; + + if (NextMBB != MF.end() && MSucc == NextMBB) { + // The unconditional fall-through case, which needs no instructions. + } else { + // The unconditional branch case. + const SmallVector<MachineOperand, 0> NoCond(0); + TII.InsertBranch(*MBB, MSucc, NULL, NoCond); } + MBB->addSuccessor(MSucc); + break; } - // Something more complicated. Halt "fast" selection and bail. + // Conditional branches are not handed yet. + // Halt "fast" selection and bail. return I; } |