Lines Matching refs:MBB
66 /// Compute the offset immediately following this block. \p MBB is the next
68 unsigned postOffset(const MachineBasicBlock &MBB) const {
70 const Align Alignment = MBB.getAlignment();
71 const Align ParentAlign = MBB.getParent()->getAlignment();
75 // The alignment of this MBB is larger than the function's alignment, so we
110 uint64_t computeBlockSize(const MachineBasicBlock &MBB) const;
137 for (MachineBasicBlock &MBB : *MF) {
138 const unsigned Num = MBB.getNumber();
139 assert(!Num || BlockInfo[PrevNum].postOffset(MBB) <= BlockInfo[Num].Offset);
140 assert(BlockInfo[Num].Size == computeBlockSize(MBB));
144 for (MachineBasicBlock &MBB : *MF) {
145 for (MachineBasicBlock::iterator J = MBB.getFirstTerminator();
146 J != MBB.end(); J = std::next(J)) {
154 RelaxedUnconditionals.contains({&MBB, DestBB}));
163 for (auto &MBB : *MF) {
164 const BasicBlockInfo &BBI = BlockInfo[MBB.getNumber()];
165 dbgs() << format("%%bb.%u\toffset=%08x\t", MBB.getNumber(), BBI.Offset)
185 for (MachineBasicBlock &MBB : *MF) {
186 BlockInfo[MBB.getNumber()].Size = computeBlockSize(MBB);
188 if (MBB.getSectionID() != MBBSectionID::ColdSectionID)
189 TrampolineInsertionPoint = &MBB;
201 /// computeBlockSize - Compute the size for MBB.
202 uint64_t BranchRelaxation::computeBlockSize(const MachineBasicBlock &MBB) const {
204 for (const MachineInstr &MI : MBB)
213 const MachineBasicBlock *MBB = MI.getParent();
215 // The offset is composed of two things: the sum of the sizes of all MBB's
218 unsigned Offset = BlockInfo[MBB->getNumber()].Offset;
220 // Sum instructions before MI in MBB.
221 for (MachineBasicBlock::const_iterator I = MBB->begin(); &*I != &MI; ++I) {
222 assert(I != MBB->end() && "Didn't find MI in its own basic block?");
231 for (auto &MBB :
233 unsigned Num = MBB.getNumber();
236 BlockInfo[Num].Offset = BlockInfo[PrevNum].postOffset(MBB);
253 // Create a new MBB for the code after the OrigBB.
276 // Create a new MBB for the code after the OrigBB.
358 MachineBasicBlock *MBB = MI.getParent();
363 auto insertUncondBranch = [&](MachineBasicBlock *MBB,
365 unsigned &BBSize = BlockInfo[MBB->getNumber()].Size;
367 TII->insertUnconditionalBranch(*MBB, DestBB, DL, &NewBrSize);
370 auto insertBranch = [&](MachineBasicBlock *MBB, MachineBasicBlock *TBB,
373 unsigned &BBSize = BlockInfo[MBB->getNumber()].Size;
375 TII->insertBranch(*MBB, TBB, FBB, Cond, DL, &NewBrSize);
378 auto removeBranch = [&](MachineBasicBlock *MBB) {
379 unsigned &BBSize = BlockInfo[MBB->getNumber()].Size;
381 TII->removeBranch(*MBB, &RemovedSize);
385 auto finalizeBlockChanges = [&](MachineBasicBlock *MBB,
388 adjustBlockOffsets(*MBB);
395 bool Fail = TII->analyzeBranch(*MBB, TBB, FBB, Cond);
409 if (MBB->getSectionID() != TBB->getSectionID() &&
414 createNewBlockAfter(*TrampolineInsertionPoint, MBB->getBasicBlock());
423 MBB->replaceSuccessor(TBB, NewBB);
426 // Replace branch in the current (MBB) block.
427 removeBranch(MBB);
428 insertBranch(MBB, NewBB, FBB, Cond);
431 finalizeBlockChanges(MBB, NewBB);
437 << printMBBReference(*MBB) << " to " << printMBBReference(*TBB)
463 << MBB->back());
465 removeBranch(MBB);
466 insertBranch(MBB, FBB, TBB, Cond);
467 finalizeBlockChanges(MBB, nullptr);
473 NewBB = createNewBlockAfter(*MBB);
478 MBB->replaceSuccessor(FBB, NewBB);
484 MachineBasicBlock &NextBB = *std::next(MachineFunction::iterator(MBB));
490 removeBranch(MBB);
492 insertBranch(MBB, &NextBB, TBB, Cond);
494 finalizeBlockChanges(MBB, NewBB);
498 // In this case we always add a block after the MBB.
500 << " Insert a new BB after " << MBB->back());
503 FBB = &(*std::next(MachineFunction::iterator(MBB)));
516 NewBB = createNewBlockAfter(*MBB);
527 MBB->replaceSuccessor(TBB, NewBB);
530 // Replace branch in the current (MBB) block.
531 removeBranch(MBB);
532 insertBranch(MBB, NewBB, FBB, Cond);
534 finalizeBlockChanges(MBB, NewBB);
539 MachineBasicBlock *MBB = MI.getParent();
548 MI.getOpcode(), MBB->getSectionID() != DestBB->getSectionID()
552 BlockInfo[MBB->getNumber()].Size -= OldBrSize;
554 MachineBasicBlock *BranchBB = MBB;
558 if (!MBB->empty()) {
559 BranchBB = createNewBlockAfter(*MBB);
562 for (const MachineBasicBlock *Succ : MBB->successors()) {
569 MBB->replaceSuccessor(DestBB, BranchBB);
570 if (TrampolineInsertionPoint == MBB)
593 adjustBlockOffsets(*MBB);
599 if (MBB->getSectionID() == MBBSectionID::ColdSectionID &&
661 for (MachineBasicBlock &MBB : *MF) {
663 MachineBasicBlock::iterator Last = MBB.getLastNonDebugInstr();
664 if (Last == MBB.end())
677 !RelaxedUnconditionals.contains({&MBB, DestBB})) {
687 for (MachineBasicBlock::iterator J = MBB.getFirstTerminator();
688 J != MBB.end(); J = Next) {
702 if (Next != MBB.end() && Next->isConditionalBranch()) {
716 Next = MBB.getFirstTerminator();