From 48904e9452de81375bd55d830d08e51cc8f2ec7e Mon Sep 17 00:00:00 2001 From: Guillaume Chatelet Date: Wed, 11 Sep 2019 11:16:48 +0000 Subject: [Alignment] Use llvm::Align in MachineFunction and TargetLowering - fixes mir parsing Summary: This catches malformed mir files which specify alignment as log2 instead of pow2. See https://reviews.llvm.org/D65945 for reference, This is patch is part of a series to introduce an Alignment type. See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html See this patch for the introduction of the type: https://reviews.llvm.org/D64790 Reviewers: courbet Subscribers: MatzeB, qcolombet, dschuff, arsenm, sdardis, nemanjai, jvesely, nhaehnle, hiraditya, kbarton, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, jsji, Petar.Avramovic, asbirlea, s.egerton, pzheng, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67433 llvm-svn: 371608 --- llvm/lib/CodeGen/BranchRelaxation.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'llvm/lib/CodeGen/BranchRelaxation.cpp') diff --git a/llvm/lib/CodeGen/BranchRelaxation.cpp b/llvm/lib/CodeGen/BranchRelaxation.cpp index 4ee61cff4b4..d027d5b154e 100644 --- a/llvm/lib/CodeGen/BranchRelaxation.cpp +++ b/llvm/lib/CodeGen/BranchRelaxation.cpp @@ -64,19 +64,18 @@ class BranchRelaxation : public MachineFunctionPass { /// Compute the offset immediately following this block. \p MBB is the next /// block. unsigned postOffset(const MachineBasicBlock &MBB) const { - unsigned PO = Offset + Size; - unsigned LogAlign = MBB.getLogAlignment(); - if (LogAlign == 0) + const unsigned PO = Offset + Size; + const llvm::Align Align = MBB.getAlignment(); + if (Align == 1) return PO; - unsigned AlignAmt = 1 << LogAlign; - unsigned ParentLogAlign = MBB.getParent()->getLogAlignment(); - if (LogAlign <= ParentLogAlign) - return PO + OffsetToAlignment(PO, AlignAmt); + const llvm::Align ParentAlign = MBB.getParent()->getAlignment(); + if (Align <= ParentAlign) + return PO + OffsetToAlignment(PO, Align.value()); // 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 + AlignAmt + OffsetToAlignment(PO, AlignAmt); + return PO + Align.value() + OffsetToAlignment(PO, Align.value()); } }; -- cgit v1.2.3