diff options
Diffstat (limited to 'llvm/lib/CodeGen/BranchRelaxation.cpp')
-rw-r--r-- | llvm/lib/CodeGen/BranchRelaxation.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/BranchRelaxation.cpp b/llvm/lib/CodeGen/BranchRelaxation.cpp index f05517d178ae..5a3ec1a36f96 100644 --- a/llvm/lib/CodeGen/BranchRelaxation.cpp +++ b/llvm/lib/CodeGen/BranchRelaxation.cpp @@ -67,16 +67,13 @@ class BranchRelaxation : public MachineFunctionPass { unsigned postOffset(const MachineBasicBlock &MBB) const { const unsigned PO = Offset + Size; const Align Alignment = MBB.getAlignment(); - if (Alignment == 1) - return PO; - const Align ParentAlign = MBB.getParent()->getAlignment(); if (Alignment <= ParentAlign) - return PO + offsetToAlignment(PO, Alignment); + return alignTo(PO, Alignment); // The alignment of this MBB is larger than the function's alignment, so we // can't tell whether or not it will insert nops. Assume that it will. - return PO + Alignment.value() + offsetToAlignment(PO, Alignment); + return alignTo(PO, Alignment) + Alignment.value() - ParentAlign.value(); } }; @@ -129,7 +126,6 @@ void BranchRelaxation::verify() { unsigned PrevNum = MF->begin()->getNumber(); for (MachineBasicBlock &MBB : *MF) { const unsigned Num = MBB.getNumber(); - assert(isAligned(MBB.getAlignment(), BlockInfo[Num].Offset)); assert(!Num || BlockInfo[PrevNum].postOffset(MBB) <= BlockInfo[Num].Offset); assert(BlockInfo[Num].Size == computeBlockSize(MBB)); PrevNum = Num; @@ -195,10 +191,9 @@ unsigned BranchRelaxation::getInstrOffset(const MachineInstr &MI) const { void BranchRelaxation::adjustBlockOffsets(MachineBasicBlock &Start) { unsigned PrevNum = Start.getNumber(); - for (auto &MBB : make_range(MachineFunction::iterator(Start), MF->end())) { + for (auto &MBB : + make_range(std::next(MachineFunction::iterator(Start)), MF->end())) { unsigned Num = MBB.getNumber(); - if (!Num) // block zero is never changed from offset zero. - continue; // Get the offset and known bits at the end of the layout predecessor. // Include the alignment of the current block. BlockInfo[Num].Offset = BlockInfo[PrevNum].postOffset(MBB); @@ -250,8 +245,7 @@ MachineBasicBlock *BranchRelaxation::splitBlockBeforeInstr(MachineInstr &MI, // Cleanup potential unconditional branch to successor block. // Note that updateTerminator may change the size of the blocks. - NewBB->updateTerminator(); - OrigBB->updateTerminator(); + OrigBB->updateTerminator(NewBB); // Figure out how large the OrigBB is. As the first half of the original // block, it cannot contain a tablejump. The size includes |