[llvm] 710a834 - [Alignment][NFC] Use Align in MCSymbol::setCommon
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 12 05:09:35 PST 2022
Author: Guillaume Chatelet
Date: 2022-12-12T13:09:24Z
New Revision: 710a834c4c822c5c444fc9715785d23959f5c645
URL: https://github.com/llvm/llvm-project/commit/710a834c4c822c5c444fc9715785d23959f5c645
DIFF: https://github.com/llvm/llvm-project/commit/710a834c4c822c5c444fc9715785d23959f5c645.diff
LOG: [Alignment][NFC] Use Align in MCSymbol::setCommon
This patch supersedes D138705.
Differential Revision: https://reviews.llvm.org/D139819
Added:
Modified:
llvm/include/llvm/MC/MCSymbol.h
llvm/lib/MC/MCMachOStreamer.cpp
llvm/lib/MC/MCWinCOFFStreamer.cpp
llvm/lib/MC/MCXCOFFStreamer.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCSymbol.h b/llvm/include/llvm/MC/MCSymbol.h
index 91ef6ee31d8dd..df418c3bab9d4 100644
--- a/llvm/include/llvm/MC/MCSymbol.h
+++ b/llvm/include/llvm/MC/MCSymbol.h
@@ -340,16 +340,14 @@ class MCSymbol {
/// Mark this symbol as being 'common'.
///
/// \param Size - The size of the symbol.
- /// \param Align - The alignment of the symbol.
+ /// \param Alignment - 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 Alignment, 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(Alignment);
assert(Log2Align < (1U << NumCommonAlignmentBits) &&
"Out of range alignment");
CommonAlignLog2 = Log2Align;
@@ -364,17 +362,17 @@ class MCSymbol {
/// Declare this symbol as being 'common'.
///
/// \param Size - The size of the symbol.
- /// \param Align - The alignment of the symbol.
+ /// \param Alignment - The alignment of the symbol.
/// \param Target - Is the symbol a target-specific common-like symbol.
/// \return True if symbol was already declared as a
diff erent type
- bool declareCommon(uint64_t Size, unsigned Align, bool Target = false) {
+ bool declareCommon(uint64_t Size, unsigned Alignment, bool Target = false) {
assert(isCommon() || getOffset() == 0);
if(isCommon()) {
- if (CommonSize != Size || getCommonAlignment() != Align ||
+ if (CommonSize != Size || getCommonAlignment() != Alignment ||
isTargetCommon() != Target)
return true;
} else
- setCommon(Size, Align, Target);
+ setCommon(Size, Align(Alignment), Target);
return false;
}
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp
index 9d6e6d71a1136..699742f96db82 100644
--- a/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/llvm/lib/MC/MCMachOStreamer.cpp
@@ -437,7 +437,7 @@ void MCMachOStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
getAssembler().registerSymbol(*Symbol);
Symbol->setExternal(true);
- Symbol->setCommon(Size, ByteAlignment.value());
+ Symbol->setCommon(Size, ByteAlignment);
}
void MCMachOStreamer::emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
diff --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp b/llvm/lib/MC/MCWinCOFFStreamer.cpp
index 2bb5bb53fc351..198c71571d9d3 100644
--- a/llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -274,7 +274,7 @@ void MCWinCOFFStreamer::emitCommonSymbol(MCSymbol *S, uint64_t Size,
getAssembler().registerSymbol(*Symbol);
Symbol->setExternal(true);
- Symbol->setCommon(Size, ByteAlignment.value());
+ Symbol->setCommon(Size, ByteAlignment);
if (!T.isWindowsMSVCEnvironment() && ByteAlignment > 1) {
SmallString<128> Directive;
diff --git a/llvm/lib/MC/MCXCOFFStreamer.cpp b/llvm/lib/MC/MCXCOFFStreamer.cpp
index b521b164a0468..25a678c68416e 100644
--- a/llvm/lib/MC/MCXCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCXCOFFStreamer.cpp
@@ -95,7 +95,7 @@ void MCXCOFFStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
getAssembler().registerSymbol(*Symbol);
Symbol->setExternal(cast<MCSymbolXCOFF>(Symbol)->getStorageClass() !=
XCOFF::C_HIDEXT);
- Symbol->setCommon(Size, ByteAlignment.value());
+ Symbol->setCommon(Size, ByteAlignment);
// Default csect align is 4, but common symbols have explicit alignment values
// and we should honor it.
More information about the llvm-commits
mailing list