[PATCH] D138705: [Alignment] Use Align in MCSymbol::setCommon
Guillaume Chatelet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 25 05:29:09 PST 2022
gchatelet created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
gchatelet requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D138705
Files:
llvm/include/llvm/MC/MCSymbol.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/MC/MCMachOStreamer.cpp
llvm/lib/MC/MCWinCOFFStreamer.cpp
llvm/lib/MC/MCXCOFFStreamer.cpp
Index: llvm/lib/MC/MCXCOFFStreamer.cpp
===================================================================
--- llvm/lib/MC/MCXCOFFStreamer.cpp
+++ llvm/lib/MC/MCXCOFFStreamer.cpp
@@ -95,7 +95,7 @@
getAssembler().registerSymbol(*Symbol);
Symbol->setExternal(cast<MCSymbolXCOFF>(Symbol)->getStorageClass() !=
XCOFF::C_HIDEXT);
- Symbol->setCommon(Size, ByteAlignment);
+ Symbol->setCommon(Size, Align(ByteAlignment));
// Default csect align is 4, but common symbols have explicit alignment values
// and we should honor it.
Index: llvm/lib/MC/MCWinCOFFStreamer.cpp
===================================================================
--- llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -276,7 +276,7 @@
getAssembler().registerSymbol(*Symbol);
Symbol->setExternal(true);
- Symbol->setCommon(Size, ByteAlignment);
+ Symbol->setCommon(Size, Align(ByteAlignment));
if (!T.isWindowsMSVCEnvironment() && ByteAlignment > 1) {
SmallString<128> Directive;
Index: llvm/lib/MC/MCMachOStreamer.cpp
===================================================================
--- llvm/lib/MC/MCMachOStreamer.cpp
+++ llvm/lib/MC/MCMachOStreamer.cpp
@@ -436,7 +436,7 @@
getAssembler().registerSymbol(*Symbol);
Symbol->setExternal(true);
- Symbol->setCommon(Size, ByteAlignment);
+ Symbol->setCommon(Size, Align(ByteAlignment));
}
void MCMachOStreamer::emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -746,7 +746,7 @@
const bool SupportsAlignment =
getObjFileLowering().getCommDirectiveSupportsAlignment();
OutStreamer->emitCommonSymbol(GVSym, Size,
- SupportsAlignment ? Alignment.value() : 0);
+ SupportsAlignment ? Alignment.value() : 1);
return;
}
Index: llvm/include/llvm/MC/MCSymbol.h
===================================================================
--- llvm/include/llvm/MC/MCSymbol.h
+++ llvm/include/llvm/MC/MCSymbol.h
@@ -342,14 +342,12 @@
/// \param Size - The size of the symbol.
/// \param Align - The alignment of the symbol.
/// \param Target - Is the symbol a target-specific common-like symbol.
- void setCommon(uint64_t Size, unsigned Align, bool Target = false) {
+ void setCommon(uint64_t Size, Align Align, bool Target = false) {
assert(getOffset() == 0);
CommonSize = Size;
SymbolContents = Target ? SymContentsTargetCommon : SymContentsCommon;
- assert((!Align || isPowerOf2_32(Align)) &&
- "Alignment must be a power of 2");
- unsigned Log2Align = Log2_32(Align) + 1;
+ unsigned Log2Align = encode(Align);
assert(Log2Align < (1U << NumCommonAlignmentBits) &&
"Out of range alignment");
CommonAlignLog2 = Log2Align;
@@ -374,7 +372,7 @@
isTargetCommon() != Target)
return true;
} else
- setCommon(Size, Align, Target);
+ setCommon(Size, llvm::Align(Align), Target);
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138705.477928.patch
Type: text/x-patch
Size: 3210 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221125/07a991f2/attachment.bin>
More information about the llvm-commits
mailing list