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 @@ -34,7 +34,7 @@ std::move(Emitter)) {} bool emitSymbolAttribute(MCSymbol *, MCSymbolAttr) override { return false; } - void emitCommonSymbol(MCSymbol *, uint64_t, unsigned) override {} + void emitCommonSymbol(MCSymbol *, uint64_t, Align) override {} void emitZerofill(MCSection *, MCSymbol *Symbol = nullptr, uint64_t Size = 0, Align ByteAlignment = Align(1), SMLoc Loc = SMLoc()) 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 @@ -57,7 +57,7 @@ bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override; void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override; void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) override; + Align ByteAlignment) override; void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override; void emitELFSymverDirective(const MCSymbol *OriginalSym, StringRef Name, 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 @@ -34,7 +34,7 @@ return false; } void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) override {} + Align ByteAlignment) override {} void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, uint64_t Size = 0, Align ByteAlignment = Align(1), SMLoc Loc = SMLoc()) override {} 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 @@ -667,10 +667,9 @@ /// /// \param Symbol - The common symbol to emit. /// \param Size - The size of the common symbol. - /// \param ByteAlignment - The alignment of the symbol if - /// non-zero. This must be a power of 2. + /// \param ByteAlignment - The alignment of the symbol. virtual void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) = 0; + Align ByteAlignment) = 0; /// Emit a local common (.lcomm) 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 @@ -50,7 +50,7 @@ bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override; void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override; void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) override; + Align ByteAlignment) override; void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) 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 @@ -55,7 +55,7 @@ void emitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override; void emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) override; void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) override; + Align ByteAlignment) override; void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment) override; void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) 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 @@ -21,7 +21,7 @@ bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override; void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) override; + Align ByteAlignment) override; void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, uint64_t Size = 0, Align ByteAlignment = Align(1), SMLoc Loc = SMLoc()) override; 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 @@ -754,7 +754,7 @@ if (GVKind.isCommon()) { if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. // .comm _foo, 42, 4 - OutStreamer->emitCommonSymbol(GVSym, Size, Alignment.value()); + OutStreamer->emitCommonSymbol(GVSym, Size, Alignment); return; } @@ -795,7 +795,7 @@ // .local _foo OutStreamer->emitSymbolAttribute(GVSym, MCSA_Local); // .comm _foo, 42, 4 - OutStreamer->emitCommonSymbol(GVSym, Size, Alignment.value()); + OutStreamer->emitCommonSymbol(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 @@ -203,7 +203,7 @@ void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override; void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) override; + Align ByteAlignment) override; /// Emit a local common (.lcomm) symbol. /// @@ -970,15 +970,15 @@ } void MCAsmStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) { + Align ByteAlignment) { OS << "\t.comm\t"; Symbol->print(OS, MAI); OS << ',' << Size; if (MAI->getCOMMDirectiveAlignmentIsInBytes()) - OS << ',' << ByteAlignment; + OS << ',' << ByteAlignment.value(); else - OS << ',' << Log2_32(ByteAlignment); + OS << ',' << Log2(ByteAlignment); EmitEOL(); // Print symbol's rename (original name contains invalid character(s)) if @@ -986,7 +986,6 @@ MCSymbolXCOFF *XSym = dyn_cast(Symbol); if (XSym && XSym->hasRename()) emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName()); - } void MCAsmStreamer::emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, 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 @@ -310,7 +310,7 @@ } void MCELFStreamer::emitCommonSymbol(MCSymbol *S, uint64_t Size, - unsigned ByteAlignment) { + Align ByteAlignment) { auto *Symbol = cast(S); getAssembler().registerSymbol(*Symbol); @@ -325,13 +325,13 @@ MCSectionSubPair P = getCurrentSection(); switchSection(&Section); - emitValueToAlignment(Align(ByteAlignment), 0, 1, 0); + emitValueToAlignment(ByteAlignment, 0, 1, 0); emitLabel(Symbol); emitZeros(Size); switchSection(P.first, P.second); } else { - if(Symbol->declareCommon(Size, ByteAlignment)) + if (Symbol->declareCommon(Size, ByteAlignment.value())) report_fatal_error(Twine("Symbol: ") + Symbol->getName() + " redeclared as different type"); } @@ -357,7 +357,7 @@ // FIXME: Should this be caught and done earlier? getAssembler().registerSymbol(*Symbol); Symbol->setBinding(ELF::STB_LOCAL); - emitCommonSymbol(Symbol, Size, ByteAlignment.value()); + emitCommonSymbol(Symbol, Size, ByteAlignment); } void MCELFStreamer::emitValueImpl(const MCExpr *Value, unsigned Size, 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 @@ -104,7 +104,7 @@ bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override; void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override; void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) override; + Align ByteAlignment) override; void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment) override; @@ -431,13 +431,13 @@ } void MCMachOStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) { + Align ByteAlignment) { // FIXME: Darwin 'as' does appear to allow redef of a .comm by itself. assert(Symbol->isUndefined() && "Cannot define a symbol twice!"); getAssembler().registerSymbol(*Symbol); Symbol->setExternal(true); - Symbol->setCommon(Size, ByteAlignment); + Symbol->setCommon(Size, ByteAlignment.value()); } void MCMachOStreamer::emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, 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 @@ -37,7 +37,7 @@ } void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) override {} + Align ByteAlignment) override {} void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, uint64_t Size = 0, Align ByteAlignment = Align(1), SMLoc Loc = SMLoc()) override {} diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -5064,7 +5064,7 @@ return false; } - getStreamer().emitCommonSymbol(Sym, Size, 1 << Pow2Alignment); + getStreamer().emitCommonSymbol(Sym, Size, Align(1ULL << Pow2Alignment)); return false; } diff --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp --- a/llvm/lib/MC/MCParser/MasmParser.cpp +++ b/llvm/lib/MC/MCParser/MasmParser.cpp @@ -6125,7 +6125,7 @@ return false; } - getStreamer().emitCommonSymbol(Sym, Size, 1 << Pow2Alignment); + getStreamer().emitCommonSymbol(Sym, Size, Align(1ULL << Pow2Alignment)); 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 @@ -164,7 +164,7 @@ } void MCWasmStreamer::emitCommonSymbol(MCSymbol *S, uint64_t Size, - unsigned ByteAlignment) { + Align ByteAlignment) { llvm_unreachable("Common symbols are not yet implemented for Wasm"); } 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 @@ -260,7 +260,7 @@ } void MCWinCOFFStreamer::emitCommonSymbol(MCSymbol *S, uint64_t Size, - unsigned ByteAlignment) { + Align ByteAlignment) { auto *Symbol = cast(S); const Triple &T = getContext().getTargetTriple(); @@ -269,12 +269,12 @@ report_fatal_error("alignment is limited to 32-bytes"); // Round size up to alignment so that we will honor the alignment request. - Size = std::max(Size, static_cast(ByteAlignment)); + Size = std::max(Size, ByteAlignment.value()); } getAssembler().registerSymbol(*Symbol); Symbol->setExternal(true); - Symbol->setCommon(Size, ByteAlignment); + Symbol->setCommon(Size, ByteAlignment.value()); if (!T.isWindowsMSVCEnvironment() && ByteAlignment > 1) { SmallString<128> Directive; @@ -282,7 +282,7 @@ const MCObjectFileInfo *MFI = getContext().getObjectFileInfo(); OS << " -aligncomm:\"" << Symbol->getName() << "\"," - << Log2_32_Ceil(ByteAlignment); + << Log2_32_Ceil(ByteAlignment.value()); pushSection(); switchSection(MFI->getDrectveSection()); 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 @@ -91,19 +91,19 @@ } void MCXCOFFStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) { + Align ByteAlignment) { getAssembler().registerSymbol(*Symbol); Symbol->setExternal(cast(Symbol)->getStorageClass() != XCOFF::C_HIDEXT); - Symbol->setCommon(Size, ByteAlignment); + Symbol->setCommon(Size, ByteAlignment.value()); // Default csect align is 4, but common symbols have explicit alignment values // and we should honor it. cast(Symbol)->getRepresentedCsect()->setAlignment( - Align(ByteAlignment)); + ByteAlignment); // Emit the alignment and storage for the variable to the section. - emitValueToAlignment(Align(ByteAlignment)); + emitValueToAlignment(ByteAlignment); emitZeros(Size); } @@ -150,5 +150,5 @@ uint64_t Size, MCSymbol *CsectSym, Align Alignment) { - emitCommonSymbol(CsectSym, Size, Alignment.value()); + emitCommonSymbol(CsectSym, Size, Alignment); } 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 @@ -52,7 +52,7 @@ void emitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, Align ByteAlignment, SMLoc Loc = SMLoc()) override; void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) override; + Align ByteAlignment) override; // Ignore COFF-specific directives; we do not need any information from them, // but the default implementation of these methods crashes, so we 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 @@ -112,7 +112,7 @@ } void RecordStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) { + Align ByteAlignment) { markDefined(*Symbol); } diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -2434,7 +2434,7 @@ OutContext.getOrCreateSymbol(GVSym->getSymbolTableName()), Size, GVSym, Alignment); else - OutStreamer->emitCommonSymbol(GVSym, Size, Alignment.value()); + OutStreamer->emitCommonSymbol(GVSym, Size, Alignment); return; } 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 @@ -89,7 +89,7 @@ private: // We only care about instructions, we don't implement this part of the API. void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) override {} + Align ByteAlignment) override {} bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override { return false; } 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 @@ -48,7 +48,7 @@ } void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) override {} + Align ByteAlignment) override {} void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, uint64_t Size = 0, Align ByteAlignment = Align(1), SMLoc Loc = SMLoc()) 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 @@ -31,7 +31,7 @@ MOCK_METHOD2(emitSymbolAttribute, bool(MCSymbol *Symbol, MCSymbolAttr Attribute)); MOCK_METHOD3(emitCommonSymbol, - void(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment)); + void(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment)); MOCK_METHOD5(emitZerofill, void(MCSection *Section, MCSymbol *Symbol, uint64_t Size, Align ByteAlignment, SMLoc Loc));