[MC][ELF] Remove unneeded MCSymbol::setExternal calls

ELF code uses symbol bindings and does not call isExternal().
This commit is contained in:
Fangrui Song 2020-12-20 21:26:36 -08:00
parent 29eb3dcfe6
commit 7b9890e17e
4 changed files with 5 additions and 17 deletions

View File

@ -94,7 +94,8 @@ protected:
mutable unsigned IsRegistered : 1;
/// This symbol is visible outside this translation unit.
/// True if this symbol is visible outside this translation unit. Note: ELF
/// uses binding instead of this bit.
mutable unsigned IsExternal : 1;
/// This symbol is private extern.

View File

@ -221,7 +221,6 @@ bool MCELFStreamer::emitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) {
case MCSA_ELF_TypeGnuUniqueObject:
Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_OBJECT));
Symbol->setBinding(ELF::STB_GNU_UNIQUE);
Symbol->setExternal(true);
break;
case MCSA_Global:
@ -233,7 +232,6 @@ bool MCELFStreamer::emitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) {
Symbol->getName() +
" changed binding to STB_GLOBAL");
Symbol->setBinding(ELF::STB_GLOBAL);
Symbol->setExternal(true);
break;
case MCSA_WeakReference:
@ -244,7 +242,6 @@ bool MCELFStreamer::emitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) {
getContext().reportWarning(
getStartTokLoc(), Symbol->getName() + " changed binding to STB_WEAK");
Symbol->setBinding(ELF::STB_WEAK);
Symbol->setExternal(true);
break;
case MCSA_Local:
@ -253,7 +250,6 @@ bool MCELFStreamer::emitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) {
Symbol->getName() +
" changed binding to STB_LOCAL");
Symbol->setBinding(ELF::STB_LOCAL);
Symbol->setExternal(false);
break;
case MCSA_ELF_TypeFunction:
@ -308,10 +304,8 @@ void MCELFStreamer::emitCommonSymbol(MCSymbol *S, uint64_t Size,
auto *Symbol = cast<MCSymbolELF>(S);
getAssembler().registerSymbol(*Symbol);
if (!Symbol->isBindingSet()) {
if (!Symbol->isBindingSet())
Symbol->setBinding(ELF::STB_GLOBAL);
Symbol->setExternal(true);
}
Symbol->setType(ELF::STT_OBJECT);
@ -352,7 +346,6 @@ void MCELFStreamer::emitLocalCommonSymbol(MCSymbol *S, uint64_t Size,
// FIXME: Should this be caught and done earlier?
getAssembler().registerSymbol(*Symbol);
Symbol->setBinding(ELF::STB_LOCAL);
Symbol->setExternal(false);
emitCommonSymbol(Symbol, Size, ByteAlignment);
}
@ -499,10 +492,8 @@ void MCELFStreamer::finalizeCGProfileEntry(const MCSymbolRefExpr *&SRE) {
// Not a temporary, referece it as a weak undefined.
bool Created;
getAssembler().registerSymbol(*S, &Created);
if (Created) {
if (Created)
cast<MCSymbolELF>(S)->setBinding(ELF::STB_WEAK);
cast<MCSymbolELF>(S)->setExternal(true);
}
}
void MCELFStreamer::finalizeCGProfile() {

View File

@ -644,7 +644,6 @@ private:
Symbol->setType(ELF::STT_NOTYPE);
Symbol->setBinding(ELF::STB_LOCAL);
Symbol->setExternal(false);
}
void EmitMappingSymbol(StringRef Name, SMLoc Loc, MCFragment *F,
@ -654,7 +653,6 @@ private:
emitLabelAtPos(Symbol, Loc, F, Offset);
Symbol->setType(ELF::STT_NOTYPE);
Symbol->setBinding(ELF::STB_LOCAL);
Symbol->setExternal(false);
}
void emitThumbFunc(MCSymbol *Func) override {

View File

@ -205,10 +205,8 @@ void SparcMCExpr::fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {
MCSymbol *Symbol = Asm.getContext().getOrCreateSymbol("__tls_get_addr");
Asm.registerSymbol(*Symbol);
auto ELFSymbol = cast<MCSymbolELF>(Symbol);
if (!ELFSymbol->isBindingSet()) {
if (!ELFSymbol->isBindingSet())
ELFSymbol->setBinding(ELF::STB_GLOBAL);
ELFSymbol->setExternal(true);
}
LLVM_FALLTHROUGH;
}
case VK_Sparc_TLS_GD_HI22: