MCSymbol: Avoid isExported/setExported
The next change will move these methods from the base class.
This commit is contained in:
parent
36dc6146b8
commit
06ab660911
@ -17,6 +17,7 @@
|
||||
#include "llvm/MC/MCLinkerOptimizationHint.h"
|
||||
#include "llvm/MC/MCObjectWriter.h"
|
||||
#include "llvm/MC/MCSectionMachO.h"
|
||||
#include "llvm/MC/MCSymbolMachO.h"
|
||||
#include "llvm/MC/StringTableBuilder.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/EndianStream.h"
|
||||
@ -110,7 +111,7 @@ public:
|
||||
private:
|
||||
/// Helper struct for containing some precomputed information on symbols.
|
||||
struct MachSymbolData {
|
||||
const MCSymbol *Symbol;
|
||||
const MCSymbolMachO *Symbol;
|
||||
uint64_t StringIndex;
|
||||
uint8_t SectionIndex;
|
||||
|
||||
@ -119,7 +120,7 @@ private:
|
||||
};
|
||||
|
||||
struct IndirectSymbolData {
|
||||
MCSymbol *Symbol;
|
||||
MCSymbolMachO *Symbol;
|
||||
MCSection *Section;
|
||||
};
|
||||
|
||||
|
@ -149,7 +149,7 @@ void MCMachOStreamer::emitEHSymAttributes(const MCSymbol *Symbol,
|
||||
MCSymbol *EHSymbol) {
|
||||
auto *Sym = static_cast<const MCSymbolMachO *>(Symbol);
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
if (Symbol->isExternal())
|
||||
if (Sym->isExternal())
|
||||
emitSymbolAttribute(EHSymbol, MCSA_Global);
|
||||
if (Sym->isWeakDefinition())
|
||||
emitSymbolAttribute(EHSymbol, MCSA_WeakDefinition);
|
||||
@ -372,12 +372,13 @@ void MCMachOStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
|
||||
|
||||
void MCMachOStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||
Align ByteAlignment) {
|
||||
auto &Sym = static_cast<MCSymbolMachO &>(*Symbol);
|
||||
// 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);
|
||||
getAssembler().registerSymbol(Sym);
|
||||
Sym.setExternal(true);
|
||||
Sym.setCommon(Size, ByteAlignment);
|
||||
}
|
||||
|
||||
void MCMachOStreamer::emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||
@ -460,7 +461,8 @@ void MCMachOStreamer::finishImpl() {
|
||||
}
|
||||
|
||||
void MCMachOStreamer::finalizeCGProfileEntry(const MCSymbolRefExpr *&SRE) {
|
||||
const MCSymbol *S = &SRE->getSymbol();
|
||||
auto *S =
|
||||
static_cast<MCSymbolMachO *>(const_cast<MCSymbol *>(&SRE->getSymbol()));
|
||||
if (getAssembler().registerSymbol(*S))
|
||||
S->setExternal(true);
|
||||
}
|
||||
|
@ -128,14 +128,14 @@ void MCXCOFFStreamer::emitXCOFFCInfoSym(StringRef Name, StringRef Metadata) {
|
||||
|
||||
void MCXCOFFStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||
Align ByteAlignment) {
|
||||
auto *Sym = static_cast<MCSymbolXCOFF *>(Symbol);
|
||||
auto &Sym = static_cast<MCSymbolXCOFF &>(*Symbol);
|
||||
getAssembler().registerSymbol(*Symbol);
|
||||
Symbol->setExternal(Sym->getStorageClass() != XCOFF::C_HIDEXT);
|
||||
Sym.setExternal(Sym.getStorageClass() != XCOFF::C_HIDEXT);
|
||||
Symbol->setCommon(Size, ByteAlignment);
|
||||
|
||||
// Default csect align is 4, but common symbols have explicit alignment values
|
||||
// and we should honor it.
|
||||
Sym->getRepresentedCsect()->setAlignment(ByteAlignment);
|
||||
Sym.getRepresentedCsect()->setAlignment(ByteAlignment);
|
||||
|
||||
// Emit the alignment and storage for the variable to the section.
|
||||
emitValueToAlignment(ByteAlignment);
|
||||
|
@ -383,7 +383,7 @@ const MCSymbol &MachObjectWriter::findAliasedSymbol(const MCSymbol &Sym) const {
|
||||
}
|
||||
|
||||
void MachObjectWriter::writeNlist(MachSymbolData &MSD, const MCAssembler &Asm) {
|
||||
auto *Symbol = static_cast<const MCSymbolMachO *>(MSD.Symbol);
|
||||
auto *Symbol = MSD.Symbol;
|
||||
const auto &Data = static_cast<const MCSymbolMachO &>(*Symbol);
|
||||
auto *AliasedSymbol =
|
||||
static_cast<const MCSymbolMachO *>(&findAliasedSymbol(*Symbol));
|
||||
@ -602,15 +602,16 @@ void MachObjectWriter::computeSymbolTable(
|
||||
// match 'as'. Even though it doesn't matter for correctness, this is
|
||||
// important for letting us diff .o files.
|
||||
for (const MCSymbol &Symbol : Asm.symbols()) {
|
||||
auto &Sym = static_cast<const MCSymbolMachO &>(Symbol);
|
||||
// Ignore non-linker visible symbols.
|
||||
if (!static_cast<const MCSymbolMachO &>(Symbol).isSymbolLinkerVisible())
|
||||
if (!Sym.isSymbolLinkerVisible())
|
||||
continue;
|
||||
|
||||
if (!Symbol.isExternal() && !Symbol.isUndefined())
|
||||
if (!Sym.isExternal() && !Sym.isUndefined())
|
||||
continue;
|
||||
|
||||
MachSymbolData MSD;
|
||||
MSD.Symbol = &Symbol;
|
||||
MSD.Symbol = &Sym;
|
||||
MSD.StringIndex = StringTable.getOffset(Symbol.getName());
|
||||
|
||||
if (Symbol.isUndefined()) {
|
||||
@ -628,15 +629,16 @@ void MachObjectWriter::computeSymbolTable(
|
||||
|
||||
// Now add the data for local symbols.
|
||||
for (const MCSymbol &Symbol : Asm.symbols()) {
|
||||
auto &Sym = static_cast<const MCSymbolMachO &>(Symbol);
|
||||
// Ignore non-linker visible symbols.
|
||||
if (!static_cast<const MCSymbolMachO &>(Symbol).isSymbolLinkerVisible())
|
||||
if (!Sym.isSymbolLinkerVisible())
|
||||
continue;
|
||||
|
||||
if (Symbol.isExternal() || Symbol.isUndefined())
|
||||
if (Sym.isExternal() || Sym.isUndefined())
|
||||
continue;
|
||||
|
||||
MachSymbolData MSD;
|
||||
MSD.Symbol = &Symbol;
|
||||
MSD.Symbol = &Sym;
|
||||
MSD.StringIndex = StringTable.getOffset(Symbol.getName());
|
||||
|
||||
if (Symbol.isAbsolute()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user