@@ -67,16 +67,13 @@ class BranchRelaxation : public MachineFunctionPass {
67
67
unsigned postOffset (const MachineBasicBlock &MBB) const {
68
68
const unsigned PO = Offset + Size;
69
69
const Align Alignment = MBB.getAlignment ();
70
- if (Alignment == 1 )
71
- return PO;
72
-
73
70
const Align ParentAlign = MBB.getParent ()->getAlignment ();
74
71
if (Alignment <= ParentAlign)
75
- return PO + offsetToAlignment (PO, Alignment);
72
+ return alignTo (PO, Alignment);
76
73
77
74
// The alignment of this MBB is larger than the function's alignment, so we
78
75
// can't tell whether or not it will insert nops. Assume that it will.
79
- return PO + Alignment.value () + offsetToAlignment (PO, Alignment );
76
+ return alignTo (PO, Alignment) + Alignment.value () - ParentAlign. value ( );
80
77
}
81
78
};
82
79
@@ -129,7 +126,6 @@ void BranchRelaxation::verify() {
129
126
unsigned PrevNum = MF->begin ()->getNumber ();
130
127
for (MachineBasicBlock &MBB : *MF) {
131
128
const unsigned Num = MBB.getNumber ();
132
- assert (isAligned (MBB.getAlignment (), BlockInfo[Num].Offset ));
133
129
assert (!Num || BlockInfo[PrevNum].postOffset (MBB) <= BlockInfo[Num].Offset );
134
130
assert (BlockInfo[Num].Size == computeBlockSize (MBB));
135
131
PrevNum = Num;
@@ -195,10 +191,9 @@ unsigned BranchRelaxation::getInstrOffset(const MachineInstr &MI) const {
195
191
196
192
void BranchRelaxation::adjustBlockOffsets (MachineBasicBlock &Start) {
197
193
unsigned PrevNum = Start.getNumber ();
198
- for (auto &MBB : make_range (MachineFunction::iterator (Start), MF->end ())) {
194
+ for (auto &MBB :
195
+ make_range (std::next (MachineFunction::iterator (Start)), MF->end ())) {
199
196
unsigned Num = MBB.getNumber ();
200
- if (!Num) // block zero is never changed from offset zero.
201
- continue ;
202
197
// Get the offset and known bits at the end of the layout predecessor.
203
198
// Include the alignment of the current block.
204
199
BlockInfo[Num].Offset = BlockInfo[PrevNum].postOffset (MBB);
0 commit comments