diff --git a/llvm/include/llvm/MC/MCFragment.h b/llvm/include/llvm/MC/MCFragment.h index 6f38795f5d3d3a..b6329b1316240f 100644 --- a/llvm/include/llvm/MC/MCFragment.h +++ b/llvm/include/llvm/MC/MCFragment.h @@ -293,7 +293,7 @@ class MCRelaxableFragment : public MCEncodedFragmentWithFixups<8, 1> { class MCAlignFragment : public MCFragment { /// The alignment to ensure, in bytes. - unsigned Alignment; + Align Alignment; /// Flag to indicate that (optimal) NOPs should be emitted instead /// of using the provided value. The exact interpretation of this flag is @@ -314,12 +314,12 @@ class MCAlignFragment : public MCFragment { const MCSubtargetInfo *STI; public: - MCAlignFragment(unsigned Alignment, int64_t Value, unsigned ValueSize, + MCAlignFragment(Align Alignment, int64_t Value, unsigned ValueSize, unsigned MaxBytesToEmit, MCSection *Sec = nullptr) : MCFragment(FT_Align, false, Sec), Alignment(Alignment), EmitNops(false), Value(Value), ValueSize(ValueSize), MaxBytesToEmit(MaxBytesToEmit) {} - unsigned getAlignment() const { return Alignment; } + Align getAlignment() const { return Alignment; } int64_t getValue() const { return Value; } diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index a90ad89d596c53..a33d7ea9ebfe8e 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -331,7 +331,7 @@ uint64_t MCAssembler::computeFragmentSize(const MCAsmLayout &Layout, case MCFragment::FT_Align: { const MCAlignFragment &AF = cast(F); unsigned Offset = Layout.getFragmentOffset(&AF); - unsigned Size = offsetToAlignment(Offset, Align(AF.getAlignment())); + unsigned Size = offsetToAlignment(Offset, AF.getAlignment()); // Insert extra Nops for code alignment if the target define // shouldInsertExtraNopBytesForCodeAlign target hook. @@ -343,7 +343,7 @@ uint64_t MCAssembler::computeFragmentSize(const MCAsmLayout &Layout, // minimum nop size. if (Size > 0 && AF.hasEmitNops()) { while (Size % getBackend().getMinimumNopSize()) - Size += AF.getAlignment(); + Size += AF.getAlignment().value(); } if (Size > AF.getMaxBytesToEmit()) return 0; diff --git a/llvm/lib/MC/MCFragment.cpp b/llvm/lib/MC/MCFragment.cpp index 4634de863b2fce..4e6459c5d6e459 100644 --- a/llvm/lib/MC/MCFragment.cpp +++ b/llvm/lib/MC/MCFragment.cpp @@ -376,7 +376,7 @@ LLVM_DUMP_METHOD void MCFragment::dump() const { if (AF->hasEmitNops()) OS << " (emit nops)"; OS << "\n "; - OS << " Alignment:" << AF->getAlignment() + OS << " Alignment:" << AF->getAlignment().value() << " Value:" << AF->getValue() << " ValueSize:" << AF->getValueSize() << " MaxBytesToEmit:" << AF->getMaxBytesToEmit() << ">"; break; diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index c582a50038498f..4ca060759ce259 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -647,7 +647,8 @@ void MCObjectStreamer::emitValueToAlignment(unsigned ByteAlignment, unsigned MaxBytesToEmit) { if (MaxBytesToEmit == 0) MaxBytesToEmit = ByteAlignment; - insert(new MCAlignFragment(ByteAlignment, Value, ValueSize, MaxBytesToEmit)); + insert(new MCAlignFragment(Align(ByteAlignment), Value, ValueSize, + MaxBytesToEmit)); // Update the maximum alignment on the current section if necessary. MCSection *CurSec = getCurrentSectionOnly(); diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index f891f948891b7f..ab5d9f8431cfa6 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -1876,7 +1876,8 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm, const MCFragment &AlignFrag = *IT; if (AlignFrag.getKind() != MCFragment::FT_Align) report_fatal_error(".init_array section should be aligned"); - if (cast(AlignFrag).getAlignment() != (is64Bit() ? 8 : 4)) + if (cast(AlignFrag).getAlignment() != + Align(is64Bit() ? 8 : 4)) report_fatal_error(".init_array section should be aligned for pointers"); const MCFragment &Frag = *std::next(IT); diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp index 4b940093482f58..a494adf8e2106e 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp @@ -593,7 +593,7 @@ bool RISCVAsmBackend::shouldInsertExtraNopBytesForCodeAlign( if (AF.getAlignment() <= MinNopLen) { return false; } else { - Size = AF.getAlignment() - MinNopLen; + Size = AF.getAlignment().value() - MinNopLen; return true; } }