diff --git a/llvm/include/llvm/MC/MCDXContainerStreamer.h b/llvm/include/llvm/MC/MCDXContainerStreamer.h --- a/llvm/include/llvm/MC/MCDXContainerStreamer.h +++ b/llvm/include/llvm/MC/MCDXContainerStreamer.h @@ -36,7 +36,7 @@ bool emitSymbolAttribute(MCSymbol *, MCSymbolAttr) override { return false; } void emitCommonSymbol(MCSymbol *, uint64_t, unsigned) override {} void emitZerofill(MCSection *, MCSymbol *Symbol = nullptr, uint64_t Size = 0, - unsigned ByteAlignment = 0, SMLoc Loc = SMLoc()) override {} + Align Alignment = Align(), SMLoc Loc = SMLoc()) override {} private: void emitInstToData(const MCInst &, const MCSubtargetInfo &) override; diff --git a/llvm/include/llvm/MC/MCELFStreamer.h b/llvm/include/llvm/MC/MCELFStreamer.h --- a/llvm/include/llvm/MC/MCELFStreamer.h +++ b/llvm/include/llvm/MC/MCELFStreamer.h @@ -67,7 +67,7 @@ unsigned ByteAlignment) override; void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, - uint64_t Size = 0, unsigned ByteAlignment = 0, + uint64_t Size = 0, Align Alignment = Align(), SMLoc L = SMLoc()) override; void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment = 0) override; diff --git a/llvm/include/llvm/MC/MCSPIRVStreamer.h b/llvm/include/llvm/MC/MCSPIRVStreamer.h --- a/llvm/include/llvm/MC/MCSPIRVStreamer.h +++ b/llvm/include/llvm/MC/MCSPIRVStreamer.h @@ -36,7 +36,7 @@ void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override {} void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, - uint64_t Size = 0, unsigned ByteAlignment = 0, + uint64_t Size = 0, Align Alignment = Align(), SMLoc Loc = SMLoc()) override {} private: diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h --- a/llvm/include/llvm/MC/MCStreamer.h +++ b/llvm/include/llvm/MC/MCStreamer.h @@ -685,10 +685,9 @@ /// \param Section - The zerofill section to create and or to put the symbol /// \param Symbol - The zerofill symbol to emit, if non-NULL. /// \param Size - The size of the zerofill symbol. - /// \param ByteAlignment - The alignment of the zerofill symbol if - /// non-zero. This must be a power of 2 on some targets. + /// \param Alignment - The alignment of the zerofill symbol. virtual void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, - uint64_t Size = 0, unsigned ByteAlignment = 0, + uint64_t Size = 0, Align Alignment = Align(), SMLoc Loc = SMLoc()) = 0; /// Emit a thread local bss (.tbss) symbol. diff --git a/llvm/include/llvm/MC/MCWasmStreamer.h b/llvm/include/llvm/MC/MCWasmStreamer.h --- a/llvm/include/llvm/MC/MCWasmStreamer.h +++ b/llvm/include/llvm/MC/MCWasmStreamer.h @@ -58,7 +58,7 @@ unsigned ByteAlignment) override; void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, - uint64_t Size = 0, unsigned ByteAlignment = 0, + uint64_t Size = 0, Align Alignment = Align(), SMLoc Loc = SMLoc()) override; void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment = 0) override; diff --git a/llvm/include/llvm/MC/MCWinCOFFStreamer.h b/llvm/include/llvm/MC/MCWinCOFFStreamer.h --- a/llvm/include/llvm/MC/MCWinCOFFStreamer.h +++ b/llvm/include/llvm/MC/MCWinCOFFStreamer.h @@ -60,7 +60,7 @@ unsigned ByteAlignment) override; void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override; void emitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment, SMLoc Loc = SMLoc()) override; + Align Alignment, SMLoc Loc = SMLoc()) override; void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override; void emitIdent(StringRef IdentString) override; diff --git a/llvm/include/llvm/MC/MCXCOFFStreamer.h b/llvm/include/llvm/MC/MCXCOFFStreamer.h --- a/llvm/include/llvm/MC/MCXCOFFStreamer.h +++ b/llvm/include/llvm/MC/MCXCOFFStreamer.h @@ -23,7 +23,7 @@ void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override; void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, - uint64_t Size = 0, unsigned ByteAlignment = 0, + uint64_t Size = 0, Align Alignment = Align(), SMLoc Loc = SMLoc()) override; void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override; void emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym, uint64_t Size, diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -761,7 +761,7 @@ Size = 1; // zerofill of 0 bytes is undefined. emitLinkage(GV, GVSym); // .zerofill __DATA, __bss, _foo, 400, 5 - OutStreamer->emitZerofill(TheSection, GVSym, Size, Alignment.value()); + OutStreamer->emitZerofill(TheSection, GVSym, Size, Alignment); return; } diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -214,7 +214,7 @@ unsigned ByteAlignment) override; void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, - uint64_t Size = 0, unsigned ByteAlignment = 0, + uint64_t Size = 0, Align Alignment = Align(), SMLoc Loc = SMLoc()) override; void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, @@ -1011,8 +1011,7 @@ } void MCAsmStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol, - uint64_t Size, unsigned ByteAlignment, - SMLoc Loc) { + uint64_t Size, Align Alignment, SMLoc Loc) { if (Symbol) assignFragment(Symbol, &Section->getDummyFragment()); @@ -1030,8 +1029,7 @@ OS << ','; Symbol->print(OS, MAI); OS << ',' << Size; - if (ByteAlignment != 0) - OS << ',' << Log2_32(ByteAlignment); + OS << ',' << Log2(Align(Alignment)); } EmitEOL(); } diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp --- a/llvm/lib/MC/MCELFStreamer.cpp +++ b/llvm/lib/MC/MCELFStreamer.cpp @@ -724,8 +724,7 @@ } void MCELFStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol, - uint64_t Size, unsigned ByteAlignment, - SMLoc Loc) { + uint64_t Size, Align Alignment, SMLoc Loc) { llvm_unreachable("ELF doesn't support this directive"); } diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp --- a/llvm/lib/MC/MCMachOStreamer.cpp +++ b/llvm/lib/MC/MCMachOStreamer.cpp @@ -109,7 +109,7 @@ void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override; void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, - uint64_t Size = 0, unsigned ByteAlignment = 0, + uint64_t Size = 0, Align Alignment = Align(), SMLoc Loc = SMLoc()) override; void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment = 0) override; @@ -443,12 +443,11 @@ unsigned ByteAlignment) { // '.lcomm' is equivalent to '.zerofill'. return emitZerofill(getContext().getObjectFileInfo()->getDataBSSSection(), - Symbol, Size, ByteAlignment); + Symbol, Size, Align(ByteAlignment)); } void MCMachOStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol, - uint64_t Size, unsigned ByteAlignment, - SMLoc Loc) { + uint64_t Size, Align Alignment, SMLoc Loc) { // On darwin all virtual sections have zerofill type. Disallow the usage of // .zerofill in non-virtual functions. If something similar is needed, use // .space or .zero. @@ -465,7 +464,7 @@ // The symbol may not be present, which only creates the section. if (Symbol) { - emitValueToAlignment(Align(ByteAlignment), 0, 1, 0); + emitValueToAlignment(Alignment, 0, 1, 0); emitLabel(Symbol); emitZeros(Size); } @@ -476,7 +475,7 @@ // .zerofill directive this doesn't actually switch sections on us. void MCMachOStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) { - emitZerofill(Section, Symbol, Size, ByteAlignment); + emitZerofill(Section, Symbol, Size, Align(ByteAlignment)); } void MCMachOStreamer::emitInstToData(const MCInst &Inst, diff --git a/llvm/lib/MC/MCNullStreamer.cpp b/llvm/lib/MC/MCNullStreamer.cpp --- a/llvm/lib/MC/MCNullStreamer.cpp +++ b/llvm/lib/MC/MCNullStreamer.cpp @@ -39,7 +39,7 @@ void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override {} void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, - uint64_t Size = 0, unsigned ByteAlignment = 0, + uint64_t Size = 0, Align Alignment = Align(), SMLoc Loc = SMLoc()) override {} void emitGPRel32Value(const MCExpr *Value) override {} void beginCOFFSymbolDef(const MCSymbol *Symbol) override {} diff --git a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp --- a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp +++ b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp @@ -902,7 +902,7 @@ getStreamer().emitZerofill( getContext().getMachOSection(Segment, Section, MachO::S_ZEROFILL, 0, SectionKind::getBSS()), - /*Symbol=*/nullptr, /*Size=*/0, /*ByteAlignment=*/0, SectionLoc); + /*Symbol=*/nullptr, /*Size=*/0, Align(), SectionLoc); return false; } @@ -958,10 +958,10 @@ // Create the zerofill Symbol with Size and Pow2Alignment // // FIXME: Arch specific. - getStreamer().emitZerofill(getContext().getMachOSection( - Segment, Section, MachO::S_ZEROFILL, - 0, SectionKind::getBSS()), - Sym, Size, 1 << Pow2Alignment, SectionLoc); + getStreamer().emitZerofill( + getContext().getMachOSection(Segment, Section, MachO::S_ZEROFILL, 0, + SectionKind::getBSS()), + Sym, Size, Align(1ULL << Pow2Alignment), SectionLoc); return false; } diff --git a/llvm/lib/MC/MCWasmStreamer.cpp b/llvm/lib/MC/MCWasmStreamer.cpp --- a/llvm/lib/MC/MCWasmStreamer.cpp +++ b/llvm/lib/MC/MCWasmStreamer.cpp @@ -263,8 +263,7 @@ } void MCWasmStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol, - uint64_t Size, unsigned ByteAlignment, - SMLoc Loc) { + uint64_t Size, Align Alignment, SMLoc Loc) { llvm_unreachable("Wasm doesn't support this directive"); } diff --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp b/llvm/lib/MC/MCWinCOFFStreamer.cpp --- a/llvm/lib/MC/MCWinCOFFStreamer.cpp +++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp @@ -318,7 +318,7 @@ } void MCWinCOFFStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol, - uint64_t Size, unsigned ByteAlignment, + uint64_t Size, Align Alignment, SMLoc Loc) { llvm_unreachable("not implemented"); } diff --git a/llvm/lib/MC/MCXCOFFStreamer.cpp b/llvm/lib/MC/MCXCOFFStreamer.cpp --- a/llvm/lib/MC/MCXCOFFStreamer.cpp +++ b/llvm/lib/MC/MCXCOFFStreamer.cpp @@ -108,8 +108,7 @@ } void MCXCOFFStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol, - uint64_t Size, unsigned ByteAlignment, - SMLoc Loc) { + uint64_t Size, Align Alignment, SMLoc Loc) { report_fatal_error("Zero fill not implemented for XCOFF."); } diff --git a/llvm/lib/Object/RecordStreamer.h b/llvm/lib/Object/RecordStreamer.h --- a/llvm/lib/Object/RecordStreamer.h +++ b/llvm/lib/Object/RecordStreamer.h @@ -50,7 +50,7 @@ void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override; bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override; void emitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment, SMLoc Loc = SMLoc()) override; + Align Alignment, SMLoc Loc = SMLoc()) override; void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override; diff --git a/llvm/lib/Object/RecordStreamer.cpp b/llvm/lib/Object/RecordStreamer.cpp --- a/llvm/lib/Object/RecordStreamer.cpp +++ b/llvm/lib/Object/RecordStreamer.cpp @@ -106,8 +106,7 @@ } void RecordStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol, - uint64_t Size, unsigned ByteAlignment, - SMLoc Loc) { + uint64_t Size, Align Alignment, SMLoc Loc) { markDefined(*Symbol); } diff --git a/llvm/tools/llvm-exegesis/lib/SnippetFile.cpp b/llvm/tools/llvm-exegesis/lib/SnippetFile.cpp --- a/llvm/tools/llvm-exegesis/lib/SnippetFile.cpp +++ b/llvm/tools/llvm-exegesis/lib/SnippetFile.cpp @@ -96,7 +96,7 @@ void emitValueToAlignment(Align Alignment, int64_t Value, unsigned ValueSize, unsigned MaxBytesToEmit) override {} void emitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment, SMLoc Loc) override {} + Align Alignment, SMLoc Loc) override {} unsigned findRegisterByName(const StringRef RegName) const { // FIXME: Can we do better than this ? diff --git a/llvm/tools/llvm-mca/CodeRegionGenerator.cpp b/llvm/tools/llvm-mca/CodeRegionGenerator.cpp --- a/llvm/tools/llvm-mca/CodeRegionGenerator.cpp +++ b/llvm/tools/llvm-mca/CodeRegionGenerator.cpp @@ -50,7 +50,7 @@ void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override {} void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, - uint64_t Size = 0, unsigned ByteAlignment = 0, + uint64_t Size = 0, Align Alignment = Align(), SMLoc Loc = SMLoc()) override {} void emitGPRel32Value(const MCExpr *Value) override {} void beginCOFFSymbolDef(const MCSymbol *Symbol) override {} diff --git a/llvm/unittests/CodeGen/TestAsmPrinter.h b/llvm/unittests/CodeGen/TestAsmPrinter.h --- a/llvm/unittests/CodeGen/TestAsmPrinter.h +++ b/llvm/unittests/CodeGen/TestAsmPrinter.h @@ -32,9 +32,8 @@ bool(MCSymbol *Symbol, MCSymbolAttr Attribute)); MOCK_METHOD3(emitCommonSymbol, void(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment)); - MOCK_METHOD5(emitZerofill, - void(MCSection *Section, MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment, SMLoc Loc)); + MOCK_METHOD5(emitZerofill, void(MCSection *Section, MCSymbol *Symbol, + uint64_t Size, Align Alignment, SMLoc Loc)); // The following are mock methods to be used in tests.