Lines Matching defs:MBB
76 void placeBlockMarker(MachineBasicBlock &MBB);
77 void placeLoopMarker(MachineBasicBlock &MBB);
78 void placeTryMarker(MachineBasicBlock &MBB);
79 void placeTryTableMarker(MachineBasicBlock &MBB);
99 const MachineBasicBlock *MBB);
101 const MachineBasicBlock *MBB);
189 /// Test whether Pred has any terminators explicitly branching to MBB, as
195 MachineBasicBlock *MBB) {
198 if (MO.isMBB() && MO.getMBB() == MBB)
203 // Returns an iterator to the earliest position possible within the MBB,
210 getEarliestInsertPos(MachineBasicBlock *MBB, const Container &BeforeSet,
212 auto InsertPos = MBB->end();
213 while (InsertPos != MBB->begin()) {
217 for (auto Pos = InsertPos, E = MBB->begin(); Pos != E; --Pos)
227 // Returns an iterator to the latest position possible within the MBB,
234 getLatestInsertPos(MachineBasicBlock *MBB, const Container &BeforeSet,
236 auto InsertPos = MBB->begin();
237 while (InsertPos != MBB->end()) {
241 for (auto Pos = InsertPos, E = MBB->end(); Pos != E; ++Pos)
280 /// Insert a BLOCK marker for branches to MBB (if needed).
283 void WebAssemblyCFGStackify::placeBlockMarker(MachineBasicBlock &MBB) {
284 assert(!MBB.isEHPad());
285 MachineFunction &MF = *MBB.getParent();
294 int MBBNumber = MBB.getNumber();
295 for (MachineBasicBlock *Pred : MBB.predecessors()) {
298 if (explicitlyBranchesTo(Pred, &MBB))
307 assert(&MBB != &MF.front() && "Header blocks shouldn't have predecessors");
308 MachineBasicBlock *LayoutPred = MBB.getPrevNode();
325 // Decide where in MBB to put the BLOCK.
333 // loop is above MBB, it should be after the BLOCK, because the loop is
337 if (MBB.getNumber() > LoopBottom->getNumber())
352 if (BeginToEnd[&MI]->getParent()->getNumber() <= MBB.getNumber())
393 // Decide where in MBB to put the END_BLOCK.
396 for (auto &MI : MBB) {
410 // processed, so they are placed below MBB (EH pad) in placeTryMarker. But
424 InsertPos = getEarliestInsertPos(&MBB, BeforeSet, AfterSet);
425 MachineInstr *End = BuildMI(MBB, InsertPos, MBB.findPrevDebugLoc(InsertPos),
430 updateScopeTops(Header, &MBB);
433 /// Insert a LOOP marker for a loop starting at MBB (if it's a loop header).
434 void WebAssemblyCFGStackify::placeLoopMarker(MachineBasicBlock &MBB) {
435 MachineFunction &MF = *MBB.getParent();
441 MachineLoop *Loop = MLI.getLoopFor(&MBB);
442 if (!Loop || Loop->getHeader() != &MBB)
458 for (const auto &MI : MBB) {
470 auto InsertPos = getEarliestInsertPos(&MBB, BeforeSet, AfterSet);
471 MachineInstr *Begin = BuildMI(MBB, InsertPos, MBB.findDebugLoc(InsertPos),
475 // Decide where in MBB to put the END_LOOP.
479 for (const auto &MI : MBB)
496 ScopeTops[AfterLoop->getNumber()]->getNumber() < MBB.getNumber()) &&
498 updateScopeTops(&MBB, AfterLoop);
501 void WebAssemblyCFGStackify::placeTryMarker(MachineBasicBlock &MBB) {
502 assert(MBB.isEHPad());
503 MachineFunction &MF = *MBB.getParent();
513 int MBBNumber = MBB.getNumber();
514 for (auto *Pred : MBB.predecessors()) {
517 assert(!explicitlyBranchesTo(Pred, &MBB) &&
526 WebAssemblyException *WE = WEI.getExceptionFor(&MBB);
559 // loop is above MBB, it should be after the TRY, because the loop is nested
563 if (MBB.getNumber() > LoopBottom->getNumber())
590 // If Header unwinds to MBB (= Header contains 'invoke'), the try block should
596 if (MBB.isPredecessor(Header)) {
678 registerTryScope(Begin, End, &MBB);
691 for (auto *End : {&MBB, Cont})
695 void WebAssemblyCFGStackify::placeTryTableMarker(MachineBasicBlock &MBB) {
696 assert(MBB.isEHPad());
697 MachineFunction &MF = *MBB.getParent();
707 int MBBNumber = MBB.getNumber();
708 for (auto *Pred : MBB.predecessors()) {
711 assert(!explicitlyBranchesTo(Pred, &MBB) &&
721 WebAssemblyException *WE = WEI.getExceptionFor(&MBB);
752 // loop is above MBB, it should be after the TRY_TABLE, because the loop is
756 if (MBB.getNumber() > LoopBottom->getNumber())
783 // If Header unwinds to MBB (= Header contains 'invoke'), the try_table block
789 if (MBB.isPredecessor(Header)) {
833 // try_table (catch ... $MBB)
836 // MBB:
861 auto *Catch = WebAssembly::findCatch(&MBB);
874 TryTableMIB.addMBB(&MBB);
888 TryTableMIB.addMBB(&MBB);
894 TryTableMIB.addMBB(&MBB);
900 TryTableMIB.addMBB(&MBB);
904 // Decide where in MBB to put the END_TRY_TABLE, and the END_BLOCK for the
908 for (const auto &MI : MBB) {
938 InsertPos = getEarliestInsertPos(&MBB, BeforeSet, AfterSet);
940 BuildMI(MBB, InsertPos, MBB.findPrevDebugLoc(InsertPos),
942 registerTryScope(TryTable, EndTryTable, &MBB);
944 BuildMI(MBB, InsertPos, MBB.findPrevDebugLoc(InsertPos),
988 for (auto *End : {&MBB, Cont})
1028 for (auto &MBB : MF) {
1029 if (!MBB.isEHPad())
1034 MachineBasicBlock *EHPadLayoutPred = MBB.getPrevNode();
1036 MachineBasicBlock *Cont = &MBB;
1082 for (auto &MBB : MF) {
1083 for (auto &MI : MBB) {
1111 // When MBB is split into MBB and Split, we should unstackify defs in MBB that
1113 static void unstackifyVRegsUsedInSplitBB(MachineBasicBlock &MBB,
1115 MachineFunction &MF = *MBB.getParent();
1125 if (Def->getParent() == &MBB)
1153 for (MachineInstr &MI : llvm::make_early_inc_range(MBB)) {
1164 BuildMI(MBB, &MI, MI.getDebugLoc(), TII.get(CopyOpc), TeeReg)
1166 BuildMI(MBB, &MI, MI.getDebugLoc(), TII.get(CopyOpc), Reg).addReg(DefReg);
1834 for (auto &MBB : reverse(MF)) {
1836 for (auto &MI : reverse(MBB)) {
1844 // seen one, we can skip the rest of BB. Also if MBB has no EH pad
1846 if (SeenThrowableInstInBB || !MBB.hasEHPadSuccessor() ||
1854 for (auto *Succ : MBB.successors()) {
1870 if (RangeBegin->getIterator() != MBB.begin() &&
1873 if (std::next(RangeEnd->getIterator()) != MBB.end() &&
1880 LLVM_DEBUG(dbgs() << "- Call unwind mismatch: MBB = " << MBB.getName()
1901 LLVM_DEBUG(dbgs() << "- Call unwind mismatch: MBB = "
1910 for (auto &MBB : reverse(MF)) {
1912 for (auto &MI : reverse(MBB)) {
1915 // If MBB has an EH pad successor and this is the last instruction that
1918 if (MBB.hasEHPadSuccessor() && MayThrow && !SeenThrowableInstInBB)
1981 auto *MBB = RangeBegin->getParent();
1991 for (auto *Succ : MBB->successors()) {
1998 MBB->removeSuccessor(EHPad);
2137 for (auto &MBB : reverse(MF)) {
2138 for (auto &MI : reverse(MBB)) {
2148 EHPadStack.push_back(&MBB);
2150 auto *EHPad = &MBB;
2276 for (auto &MBB : MF) {
2277 for (auto &MI : MBB) {
2312 for (auto &MBB : reverse(MF)) {
2313 for (auto &MI : reverse(MBB)) {
2314 if (ScopeTops[MBB.getNumber()])
2322 updateScopeTops(EndToBegin[&MI]->getParent(), &MBB);
2326 updateScopeTops(EHPadToTry[&MBB]->getParent(), &MBB);
2358 auto *MBB = It->getParent();
2359 while (It != MBB->rend()) {
2389 Worklist.push_back(MBB->getPrevNode()->rbegin());
2429 for (auto &MBB : MF)
2430 for (auto &MI : MBB)
2435 auto *MBB = EndTryTable->getParent();
2437 MF.insert(MBB->getIterator(), NewEndTryTableBB);
2439 NewEndTryTableBB->splice(NewEndTryTableBB->end(), MBB, MBB->begin(),
2441 NewEndTryTableBB->addSuccessor(MBB);
2452 // Place the LOOP for MBB if MBB is the header of a loop.
2453 for (auto &MBB : MF)
2454 placeLoopMarker(MBB);
2457 for (auto &MBB : MF) {
2458 if (MBB.isEHPad()) {
2459 // Place the TRY/TRY_TABLE for MBB if MBB is the EH pad of an exception.
2463 placeTryMarker(MBB);
2465 placeTryTableMarker(MBB);
2468 // Place the BLOCK for MBB if MBB is branched to from above.
2469 placeBlockMarker(MBB);
2488 const SmallVectorImpl<EndMarkerInfo> &Stack, const MachineBasicBlock *MBB) {
2491 if (X.first == MBB)
2500 const SmallVectorImpl<EndMarkerInfo> &Stack, const MachineBasicBlock *MBB) {
2501 if (MBB == FakeCallerBB)
2507 if (!MBB->isEHPad()) // Target is a delegate BB
2508 return getBranchDepth(Stack, MBB);
2524 const MachineInstr *EndTry = BeginToEnd[EHPadToTry[MBB]];
2556 // Rewrite MBB operands to be depth immediates.
2573 for (auto &MBB : reverse(MF)) {
2574 for (MachineInstr &MI : llvm::reverse(MBB)) {
2579 MBB.getNumber() &&
2586 MBB.getNumber() &&
2593 assert(Stack.back().first == &MBB && "Loop top should be balanced");
2600 Stack.push_back(std::make_pair(&MBB, &MI));
2609 Stack.push_back(std::make_pair(&MBB, &MI));
2658 // Convert MBB operands in terminators to relative depth immediates.