From 96fdaa4f5038608718448aa45de14a842c9aef94 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 3 Jun 2015 21:18:03 +0000 Subject: [PATCH] Convert BindingExplicitlySet into a MCSymbolELF field. I will pack it better in a followup patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238975 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCELFStreamer.h | 3 --- include/llvm/MC/MCSymbolELF.h | 6 +++++- lib/MC/MCELFStreamer.cpp | 7 +------ lib/MC/MCSymbolELF.cpp | 1 + 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/include/llvm/MC/MCELFStreamer.h b/include/llvm/MC/MCELFStreamer.h index b7f3e5e875d..241db0dc9cd 100644 --- a/include/llvm/MC/MCELFStreamer.h +++ b/include/llvm/MC/MCELFStreamer.h @@ -37,7 +37,6 @@ public: void reset() override { SeenIdent = false; LocalCommons.clear(); - BindingExplicitlySet.clear(); BundleGroups.clear(); MCObjectStreamer::reset(); } @@ -106,8 +105,6 @@ private: std::vector LocalCommons; - SmallPtrSet BindingExplicitlySet; - /// BundleGroups - The stack of fragments holding the bundle-locked /// instructions. llvm::SmallVector BundleGroups; diff --git a/include/llvm/MC/MCSymbolELF.h b/include/llvm/MC/MCSymbolELF.h index 87fcc492955..7ef97ce1bfe 100644 --- a/include/llvm/MC/MCSymbolELF.h +++ b/include/llvm/MC/MCSymbolELF.h @@ -17,9 +17,11 @@ class MCSymbolELF : public MCSymbol { /// symbol has no size this field will be NULL. const MCExpr *SymbolSize = nullptr; + mutable unsigned BindingSet : 1; + public: MCSymbolELF(const StringMapEntry *Name, bool isTemporary) - : MCSymbol(true, Name, isTemporary) {} + : MCSymbol(true, Name, isTemporary), BindingSet(false) {} void setSize(const MCExpr *SS) { SymbolSize = SS; } const MCExpr *getSize() const { return SymbolSize; } @@ -36,6 +38,8 @@ public: void setBinding(unsigned Binding) const; unsigned getBinding() const; + bool isBindingSet() const { return BindingSet; } + static bool classof(const MCSymbol *S) { return S->isELF(); } }; } diff --git a/lib/MC/MCELFStreamer.cpp b/lib/MC/MCELFStreamer.cpp index a24388a26ca..efeabbd66ea 100644 --- a/lib/MC/MCELFStreamer.cpp +++ b/lib/MC/MCELFStreamer.cpp @@ -241,26 +241,22 @@ bool MCELFStreamer::EmitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) { Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_OBJECT)); Symbol->setBinding(ELF::STB_GNU_UNIQUE); Symbol->setExternal(true); - BindingExplicitlySet.insert(Symbol); break; case MCSA_Global: Symbol->setBinding(ELF::STB_GLOBAL); Symbol->setExternal(true); - BindingExplicitlySet.insert(Symbol); break; case MCSA_WeakReference: case MCSA_Weak: Symbol->setBinding(ELF::STB_WEAK); Symbol->setExternal(true); - BindingExplicitlySet.insert(Symbol); break; case MCSA_Local: Symbol->setBinding(ELF::STB_LOCAL); Symbol->setExternal(false); - BindingExplicitlySet.insert(Symbol); break; case MCSA_ELF_TypeFunction: @@ -309,7 +305,7 @@ void MCELFStreamer::EmitCommonSymbol(MCSymbol *S, uint64_t Size, auto *Symbol = cast(S); getAssembler().registerSymbol(*Symbol); - if (!BindingExplicitlySet.count(Symbol)) { + if (!Symbol->isBindingSet()) { Symbol->setBinding(ELF::STB_GLOBAL); Symbol->setExternal(true); } @@ -343,7 +339,6 @@ void MCELFStreamer::EmitLocalCommonSymbol(MCSymbol *S, uint64_t Size, getAssembler().registerSymbol(*Symbol); Symbol->setBinding(ELF::STB_LOCAL); Symbol->setExternal(false); - BindingExplicitlySet.insert(Symbol); EmitCommonSymbol(Symbol, Size, ByteAlignment); } diff --git a/lib/MC/MCSymbolELF.cpp b/lib/MC/MCSymbolELF.cpp index 1893bb0f8dc..cf609e5e87e 100644 --- a/lib/MC/MCSymbolELF.cpp +++ b/lib/MC/MCSymbolELF.cpp @@ -16,6 +16,7 @@ namespace llvm { void MCSymbolELF::setBinding(unsigned Binding) const { + BindingSet = true; assert(Binding == ELF::STB_LOCAL || Binding == ELF::STB_GLOBAL || Binding == ELF::STB_WEAK || Binding == ELF::STB_GNU_UNIQUE); uint32_t OtherFlags = getFlags() & ~(0xf << ELF_STB_Shift); -- 2.34.1