llvm.org GIT mirror llvm / 2acf638
Take all of the invoke basic blocks and make the dispatch basic block their new successor. Remove the old landing pad from their successor list, because it's now the successor of the dispatch block. Now that the landing pad blocks are no longer the destination of invokes, we can mark them as normal basic blocks instead of landing pads. This more closely resembles what the CFG is actually doing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141436 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 8 years ago
1 changed file(s) with 28 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
56985698
56995699 // Get an ordered list of the machine basic blocks for the jump table.
57005700 std::vector LPadList;
5701 SmallPtrSet InvokeBBs;
57015702 LPadList.reserve(CallSiteNumToLPad.size());
57025703 for (unsigned I = 1; I <= MaxCSNum; ++I) {
57035704 SmallVectorImpl &MBBList = CallSiteNumToLPad[I];
57045705 for (SmallVectorImpl::iterator
5705 II = MBBList.begin(), IE = MBBList.end(); II != IE; ++II)
5706 II = MBBList.begin(), IE = MBBList.end(); II != IE; ++II) {
57065707 LPadList.push_back(*II);
5708 InvokeBBs.insert((*II)->pred_begin(), (*II)->pred_end());
5709 }
57075710 }
57085711
57095712 assert(!LPadList.empty() &&
57205723 // Shove the dispatch's address into the return slot in the function context.
57215724 MachineBasicBlock *DispatchBB = MF->CreateMachineBasicBlock();
57225725 DispatchBB->setIsLandingPad();
5723 MBB->addSuccessor(DispatchBB);
57245726
57255727 MachineBasicBlock *TrapBB = MF->CreateMachineBasicBlock();
57265728 BuildMI(TrapBB, dl, TII->get(Subtarget->isThumb() ? ARM::tTRAP : ARM::TRAP));
58725874 }
58735875
58745876 // Add the jump table entries as successors to the MBB.
5877 MachineBasicBlock *PrevMBB = 0;
58755878 for (std::vector::iterator
5876 I = LPadList.begin(), E = LPadList.end(); I != E; ++I)
5877 DispContBB->addSuccessor(*I);
5879 I = LPadList.begin(), E = LPadList.end(); I != E; ++I) {
5880 MachineBasicBlock *CurMBB = *I;
5881 if (PrevMBB != CurMBB)
5882 DispContBB->addSuccessor(CurMBB);
5883 PrevMBB = CurMBB;
5884 }
5885
5886 // Remove the landing pad successor from the invoke block and replace it with
5887 // the new dispatch block.
5888 for (SmallPtrSet::iterator
5889 I = InvokeBBs.begin(), E = InvokeBBs.end(); I != E; ++I) {
5890 MachineBasicBlock *BB = *I;
5891 for (MachineBasicBlock::succ_iterator
5892 SI = BB->succ_begin(), SE = BB->succ_end(); SI != SE; ++SI) {
5893 MachineBasicBlock *SMBB = *SI;
5894 if (SMBB->isLandingPad()) {
5895 BB->removeSuccessor(SMBB);
5896 SMBB->setIsLandingPad(false);
5897 }
5898 }
5899
5900 BB->addSuccessor(DispatchBB);
5901 }
58785902
58795903 // The instruction is gone now.
58805904 MI->eraseFromParent();