[llvm] b94bd9c - [Alignment] Use Align in MCStreamer::emitTBSSSymbol
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 8 01:02:56 PST 2022
Author: Guillaume Chatelet
Date: 2022-12-08T09:02:28Z
New Revision: b94bd9c20a39758f7733cd4e7d493fe51200932c
URL: https://github.com/llvm/llvm-project/commit/b94bd9c20a39758f7733cd4e7d493fe51200932c
DIFF: https://github.com/llvm/llvm-project/commit/b94bd9c20a39758f7733cd4e7d493fe51200932c.diff
LOG: [Alignment] Use Align in MCStreamer::emitTBSSSymbol
In the same vein as D139439, the patch is not NFC as there is no way to check all downstream implementations but the patch seems pretty safe.
Differential Revision: https://reviews.llvm.org/D139548
Added:
Modified:
llvm/include/llvm/MC/MCELFStreamer.h
llvm/include/llvm/MC/MCStreamer.h
llvm/include/llvm/MC/MCWasmStreamer.h
llvm/include/llvm/MC/MCWinCOFFStreamer.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/MC/MCAsmStreamer.cpp
llvm/lib/MC/MCELFStreamer.cpp
llvm/lib/MC/MCMachOStreamer.cpp
llvm/lib/MC/MCParser/DarwinAsmParser.cpp
llvm/lib/MC/MCStreamer.cpp
llvm/lib/MC/MCWasmStreamer.cpp
llvm/lib/MC/MCWinCOFFStreamer.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCELFStreamer.h b/llvm/include/llvm/MC/MCELFStreamer.h
index f097c3d2e20a3..71c229a96ac7a 100644
--- a/llvm/include/llvm/MC/MCELFStreamer.h
+++ b/llvm/include/llvm/MC/MCELFStreamer.h
@@ -70,7 +70,7 @@ class MCELFStreamer : public MCObjectStreamer {
uint64_t Size = 0, Align ByteAlignment = Align(1),
SMLoc L = SMLoc()) override;
void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment = 0) override;
+ Align ByteAlignment = Align(1)) override;
void emitValueImpl(const MCExpr *Value, unsigned Size,
SMLoc Loc = SMLoc()) override;
diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h
index 0773c74f3c7cb..1df6dd623a746 100644
--- a/llvm/include/llvm/MC/MCStreamer.h
+++ b/llvm/include/llvm/MC/MCStreamer.h
@@ -699,7 +699,7 @@ class MCStreamer {
/// \param ByteAlignment - The alignment of the thread local common symbol
/// if non-zero. This must be a power of 2 on some targets.
virtual void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
- uint64_t Size, unsigned ByteAlignment = 0);
+ uint64_t Size, Align ByteAlignment = Align(1));
/// @}
/// \name Generating Data
diff --git a/llvm/include/llvm/MC/MCWasmStreamer.h b/llvm/include/llvm/MC/MCWasmStreamer.h
index d3365df650f52..1a4947a53bfc3 100644
--- a/llvm/include/llvm/MC/MCWasmStreamer.h
+++ b/llvm/include/llvm/MC/MCWasmStreamer.h
@@ -61,7 +61,7 @@ class MCWasmStreamer : public MCObjectStreamer {
uint64_t Size = 0, Align ByteAlignment = Align(1),
SMLoc Loc = SMLoc()) override;
void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment = 0) override;
+ Align ByteAlignment = Align(1)) override;
void emitIdent(StringRef IdentString) override;
diff --git a/llvm/include/llvm/MC/MCWinCOFFStreamer.h b/llvm/include/llvm/MC/MCWinCOFFStreamer.h
index 8cc69c7ea33fe..fc8325eb0d099 100644
--- a/llvm/include/llvm/MC/MCWinCOFFStreamer.h
+++ b/llvm/include/llvm/MC/MCWinCOFFStreamer.h
@@ -62,7 +62,7 @@ class MCWinCOFFStreamer : public MCObjectStreamer {
void emitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
Align ByteAlignment, SMLoc Loc = SMLoc()) override;
void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment) override;
+ Align ByteAlignment) override;
void emitIdent(StringRef IdentString) override;
void emitWinEHHandlerData(SMLoc Loc) override;
void emitCGProfileEntry(const MCSymbolRefExpr *From,
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 257f9613a86a8..e7f96a75ecc79 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -816,7 +816,7 @@ void AsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
if (GVKind.isThreadBSS()) {
TheSection = getObjFileLowering().getTLSBSSSection();
- OutStreamer->emitTBSSSymbol(TheSection, MangSym, Size, Alignment.value());
+ OutStreamer->emitTBSSSymbol(TheSection, MangSym, Size, Alignment);
} else if (GVKind.isThreadData()) {
OutStreamer->switchSection(TheSection);
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index 3474ab184cbb7..952da7def4c8f 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -218,7 +218,7 @@ class MCAsmStreamer final : public MCStreamer {
SMLoc Loc = SMLoc()) override;
void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment = 0) override;
+ Align ByteAlignment = Align(1)) override;
void emitBinaryData(StringRef Data) override;
@@ -1039,7 +1039,7 @@ void MCAsmStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol,
// This depends that the symbol has already been mangled from the original,
// e.g. _a.
void MCAsmStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
- uint64_t Size, unsigned ByteAlignment) {
+ uint64_t Size, Align ByteAlignment) {
assignFragment(Symbol, &Section->getDummyFragment());
assert(Symbol && "Symbol shouldn't be NULL!");
@@ -1055,7 +1055,8 @@ void MCAsmStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
// Output align if we have it. We default to 1 so don't bother printing
// that.
- if (ByteAlignment > 1) OS << ", " << Log2_32(ByteAlignment);
+ if (ByteAlignment > 1)
+ OS << ", " << Log2(ByteAlignment);
EmitEOL();
}
diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp
index 71d556abd699f..f01ba9815026e 100644
--- a/llvm/lib/MC/MCELFStreamer.cpp
+++ b/llvm/lib/MC/MCELFStreamer.cpp
@@ -733,7 +733,7 @@ void MCELFStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol,
}
void MCELFStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
- uint64_t Size, unsigned ByteAlignment) {
+ uint64_t Size, Align ByteAlignment) {
llvm_unreachable("ELF doesn't support this directive");
}
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp
index 9352ae9e17f66..3a0f913d7f9ac 100644
--- a/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/llvm/lib/MC/MCMachOStreamer.cpp
@@ -112,7 +112,7 @@ class MCMachOStreamer : public MCObjectStreamer {
uint64_t Size = 0, Align ByteAlignment = Align(1),
SMLoc Loc = SMLoc()) override;
void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlignment = 0) override;
+ Align ByteAlignment = Align(1)) override;
void emitIdent(StringRef IdentString) override {
llvm_unreachable("macho doesn't support this directive");
@@ -476,8 +476,8 @@ void MCMachOStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol,
// This should always be called with the thread local bss section. Like the
// .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, Align(ByteAlignment));
+ uint64_t Size, Align ByteAlignment) {
+ emitZerofill(Section, Symbol, Size, ByteAlignment);
}
void MCMachOStreamer::emitInstToData(const MCInst &Inst,
diff --git a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
index 4d6e83e01f809..4be081ded3cf1 100644
--- a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
@@ -872,7 +872,7 @@ bool DarwinAsmParser::parseDirectiveTBSS(StringRef, SMLoc) {
getContext().getMachOSection("__DATA", "__thread_bss",
MachO::S_THREAD_LOCAL_ZEROFILL, 0,
SectionKind::getThreadBSS()),
- Sym, Size, 1 << Pow2Alignment);
+ Sym, Size, Align(1ULL << Pow2Alignment));
return false;
}
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index c87b841b879bd..edda4f8f4c493 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -1204,7 +1204,7 @@ void MCStreamer::emitELFSymverDirective(const MCSymbol *OriginalSym,
void MCStreamer::emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
Align ByteAlignment) {}
void MCStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
- uint64_t Size, unsigned ByteAlignment) {}
+ uint64_t Size, Align ByteAlignment) {}
void MCStreamer::changeSection(MCSection *, const MCExpr *) {}
void MCStreamer::emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {}
void MCStreamer::emitBytes(StringRef Data) {}
diff --git a/llvm/lib/MC/MCWasmStreamer.cpp b/llvm/lib/MC/MCWasmStreamer.cpp
index 351951bf7d2ea..d035e373ed4eb 100644
--- a/llvm/lib/MC/MCWasmStreamer.cpp
+++ b/llvm/lib/MC/MCWasmStreamer.cpp
@@ -269,7 +269,7 @@ void MCWasmStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol,
}
void MCWasmStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
- uint64_t Size, unsigned ByteAlignment) {
+ uint64_t Size, Align ByteAlignment) {
llvm_unreachable("Wasm doesn't support this directive");
}
diff --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp b/llvm/lib/MC/MCWinCOFFStreamer.cpp
index 173e8b52e1d62..4334eb1e0ed7e 100644
--- a/llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -322,7 +322,7 @@ void MCWinCOFFStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol,
}
void MCWinCOFFStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
- uint64_t Size, unsigned ByteAlignment) {
+ uint64_t Size, Align ByteAlignment) {
llvm_unreachable("not implemented");
}
More information about the llvm-commits
mailing list