[llvm] e299b16 - [MC] Move isPrivateExtern to MCSymbolMachO
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 21 10:58:24 PDT 2024
Author: Fangrui Song
Date: 2024-07-21T10:58:20-07:00
New Revision: e299b163c78d34cf6fb90f9d928291419b5dcaaf
URL: https://github.com/llvm/llvm-project/commit/e299b163c78d34cf6fb90f9d928291419b5dcaaf
DIFF: https://github.com/llvm/llvm-project/commit/e299b163c78d34cf6fb90f9d928291419b5dcaaf.diff
LOG: [MC] Move isPrivateExtern to MCSymbolMachO
Added:
Modified:
llvm/include/llvm/MC/MCSymbol.h
llvm/include/llvm/MC/MCSymbolMachO.h
llvm/lib/MC/MCMachOStreamer.cpp
llvm/lib/MC/MachObjectWriter.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCSymbol.h b/llvm/include/llvm/MC/MCSymbol.h
index e0ba687feb080..6fd5c02d04531 100644
--- a/llvm/include/llvm/MC/MCSymbol.h
+++ b/llvm/include/llvm/MC/MCSymbol.h
@@ -99,7 +99,7 @@ class MCSymbol {
/// uses binding instead of this bit.
mutable unsigned IsExternal : 1;
- /// This symbol is private extern.
+ /// Mach-O specific: This symbol is private extern.
mutable unsigned IsPrivateExtern : 1;
/// This symbol is weak external.
@@ -407,9 +407,7 @@ class MCSymbol {
bool isExternal() const { return IsExternal; }
void setExternal(bool Value) const { IsExternal = Value; }
- bool isPrivateExtern() const { return IsPrivateExtern; }
- void setPrivateExtern(bool Value) { IsPrivateExtern = Value; }
-
+ // COFF-specific
bool isWeakExternal() const { return IsWeakExternal; }
/// print - Print the value to the stream \p OS.
diff --git a/llvm/include/llvm/MC/MCSymbolMachO.h b/llvm/include/llvm/MC/MCSymbolMachO.h
index 730fbea0059a6..97c9abfcf5f2c 100644
--- a/llvm/include/llvm/MC/MCSymbolMachO.h
+++ b/llvm/include/llvm/MC/MCSymbolMachO.h
@@ -46,6 +46,9 @@ class MCSymbolMachO : public MCSymbol {
MCSymbolMachO(const MCSymbolTableEntry *Name, bool isTemporary)
: MCSymbol(SymbolKindMachO, Name, isTemporary) {}
+ bool isPrivateExtern() const { return IsPrivateExtern; }
+ void setPrivateExtern(bool Value) { IsPrivateExtern = Value; }
+
// Reference type methods.
void clearReferenceType() const {
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp
index 5231d10626f85..cb2e4e70ff395 100644
--- a/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/llvm/lib/MC/MCMachOStreamer.cpp
@@ -151,12 +151,13 @@ void MCMachOStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
void MCMachOStreamer::emitEHSymAttributes(const MCSymbol *Symbol,
MCSymbol *EHSymbol) {
+ auto *Sym = cast<MCSymbolMachO>(Symbol);
getAssembler().registerSymbol(*Symbol);
if (Symbol->isExternal())
emitSymbolAttribute(EHSymbol, MCSA_Global);
- if (cast<MCSymbolMachO>(Symbol)->isWeakDefinition())
+ if (Sym->isWeakDefinition())
emitSymbolAttribute(EHSymbol, MCSA_WeakDefinition);
- if (Symbol->isPrivateExtern())
+ if (Sym->isPrivateExtern())
emitSymbolAttribute(EHSymbol, MCSA_PrivateExtern);
}
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index e58e095252d05..f5435c6f3dd16 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -376,7 +376,7 @@ const MCSymbol &MachObjectWriter::findAliasedSymbol(const MCSymbol &Sym) const {
void MachObjectWriter::writeNlist(MachSymbolData &MSD, const MCAssembler &Asm) {
const MCSymbol *Symbol = MSD.Symbol;
- const MCSymbol &Data = *Symbol;
+ const auto &Data = cast<MCSymbolMachO>(*Symbol);
const MCSymbol *AliasedSymbol = &findAliasedSymbol(*Symbol);
uint8_t SectionIndex = MSD.SectionIndex;
uint8_t Type = 0;
More information about the llvm-commits
mailing list