[llvm] r238975 - Convert BindingExplicitlySet into a MCSymbolELF field.

Rafael Espindola rafael.espindola at gmail.com
Wed Jun 3 14:18:03 PDT 2015


Author: rafael
Date: Wed Jun  3 16:18:03 2015
New Revision: 238975

URL: http://llvm.org/viewvc/llvm-project?rev=238975&view=rev
Log:
Convert BindingExplicitlySet into a MCSymbolELF field.

I will pack it better in a followup patch.

Modified:
    llvm/trunk/include/llvm/MC/MCELFStreamer.h
    llvm/trunk/include/llvm/MC/MCSymbolELF.h
    llvm/trunk/lib/MC/MCELFStreamer.cpp
    llvm/trunk/lib/MC/MCSymbolELF.cpp

Modified: llvm/trunk/include/llvm/MC/MCELFStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCELFStreamer.h?rev=238975&r1=238974&r2=238975&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCELFStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCELFStreamer.h Wed Jun  3 16:18:03 2015
@@ -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<LocalCommon> LocalCommons;
 
-  SmallPtrSet<MCSymbol *, 16> BindingExplicitlySet;
-
   /// BundleGroups - The stack of fragments holding the bundle-locked
   /// instructions.
   llvm::SmallVector<MCDataFragment *, 4> BundleGroups;

Modified: llvm/trunk/include/llvm/MC/MCSymbolELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSymbolELF.h?rev=238975&r1=238974&r2=238975&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCSymbolELF.h (original)
+++ llvm/trunk/include/llvm/MC/MCSymbolELF.h Wed Jun  3 16:18:03 2015
@@ -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<bool> *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(); }
 };
 }

Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=238975&r1=238974&r2=238975&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCELFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCELFStreamer.cpp Wed Jun  3 16:18:03 2015
@@ -241,26 +241,22 @@ bool MCELFStreamer::EmitSymbolAttribute(
     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(MCS
   auto *Symbol = cast<MCSymbolELF>(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::EmitLocalCommonSymbo
   getAssembler().registerSymbol(*Symbol);
   Symbol->setBinding(ELF::STB_LOCAL);
   Symbol->setExternal(false);
-  BindingExplicitlySet.insert(Symbol);
   EmitCommonSymbol(Symbol, Size, ByteAlignment);
 }
 

Modified: llvm/trunk/lib/MC/MCSymbolELF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSymbolELF.cpp?rev=238975&r1=238974&r2=238975&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCSymbolELF.cpp (original)
+++ llvm/trunk/lib/MC/MCSymbolELF.cpp Wed Jun  3 16:18:03 2015
@@ -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);





More information about the llvm-commits mailing list