Move IsUsedInReloc from MCSymbolELF to MCSymbol.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 17 Jun 2015 20:08:20 +0000 (20:08 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 17 Jun 2015 20:08:20 +0000 (20:08 +0000)
There is a free bit is MCSymbol and MachO needs the same information.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239933 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCAssembler.h
include/llvm/MC/MCSymbol.h
include/llvm/MC/MCSymbolELF.h
lib/MC/MCAssembler.cpp
lib/MC/MCSymbolELF.cpp
lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp

index a6178c214d47b617592a3622a2e3e0b02d891806..484f370515ab8346e2a97436fad7e7a43b913aee 100644 (file)
@@ -621,8 +621,6 @@ private:
 
   SymbolDataListType Symbols;
 
-  DenseSet<const MCSymbol *> LocalsUsedInReloc;
-
   std::vector<IndirectSymbolData> IndirectSymbols;
 
   std::vector<DataRegionData> DataRegions;
@@ -713,9 +711,6 @@ private:
                                         MCFragment &F, const MCFixup &Fixup);
 
 public:
-  void addLocalUsedInReloc(const MCSymbol &Sym);
-  bool isLocalUsedInReloc(const MCSymbol &Sym) const;
-
   /// Compute the effective fragment size assuming it is laid out at the given
   /// \p SectionAddress and \p FragmentOffset.
   uint64_t computeFragmentSize(const MCAsmLayout &Layout,
index 9f97fd0c001ed3213ef43771eebe747e18c395c7..0acf6e50ba48e9bd7aaa8d0935841b599cd8a032 100644 (file)
@@ -95,6 +95,9 @@ protected:
   /// unsigned to avoid sign extension and achieve better bitpacking with MSVC.
   unsigned Kind : 2;
 
+  /// True if we have created a relocation that uses this symbol.
+  mutable unsigned IsUsedInReloc : 1;
+
   /// Index field, for use by the object file implementation.
   mutable uint32_t Index = 0;
 
@@ -129,10 +132,10 @@ protected: // MCContext creates and uniques these.
   } NameEntryStorageTy;
 
   MCSymbol(SymbolKind Kind, const StringMapEntry<bool> *Name, bool isTemporary)
-      : Value(nullptr), IsTemporary(isTemporary),
-        IsRedefinable(false), IsUsed(false), IsRegistered(false),
-        IsExternal(false), IsPrivateExtern(false), HasName(!!Name),
-        Kind(Kind) {
+      : Value(nullptr), IsTemporary(isTemporary), IsRedefinable(false),
+        IsUsed(false), IsRegistered(false), IsExternal(false),
+        IsPrivateExtern(false), HasName(!!Name), Kind(Kind),
+        IsUsedInReloc(false) {
     Offset = 0;
     if (Name)
       getNameEntryPtr() = Name;
@@ -189,6 +192,9 @@ public:
   bool isRegistered() const { return IsRegistered; }
   void setIsRegistered(bool Value) const { IsRegistered = Value; }
 
+  void setUsedInReloc() const { IsUsedInReloc = true; }
+  bool isUsedInReloc() const { return IsUsedInReloc; }
+
   /// \name Accessors
   /// @{
 
index 0cc11156b5cd03b8bb873de45fa43098d9c01b0d..bbcd22e8e7dbe15fac4238ee86a28b3198d133fe 100644 (file)
@@ -38,9 +38,6 @@ public:
 
   bool isBindingSet() const;
 
-  void setUsedInReloc() const;
-  bool isUsedInReloc() const;
-
   void setIsWeakrefUsedInReloc() const;
   bool isWeakrefUsedInReloc() const;
 
index 55f50097744ddddc1b12eeb44e9001a89cff8dac..df416710182e9d9656b9f8b3373d97af8a6768bd 100644 (file)
@@ -345,16 +345,6 @@ bool MCAssembler::isThumbFunc(const MCSymbol *Symbol) const {
   return true;
 }
 
-void MCAssembler::addLocalUsedInReloc(const MCSymbol &Sym) {
-  assert(Sym.isTemporary());
-  LocalsUsedInReloc.insert(&Sym);
-}
-
-bool MCAssembler::isLocalUsedInReloc(const MCSymbol &Sym) const {
-  assert(Sym.isTemporary());
-  return LocalsUsedInReloc.count(&Sym);
-}
-
 bool MCAssembler::isSymbolLinkerVisible(const MCSymbol &Symbol) const {
   // Non-temporary labels should always be visible to the linker.
   if (!Symbol.isTemporary())
@@ -364,7 +354,7 @@ bool MCAssembler::isSymbolLinkerVisible(const MCSymbol &Symbol) const {
   if (!Symbol.isInSection())
     return false;
 
-  if (isLocalUsedInReloc(Symbol))
+  if (Symbol.isUsedInReloc())
     return true;
 
   return false;
index c3620651f8839449de335561f8e2aee1a91fec72..ec7ef447ff89f705c7d37fdfaf983fd5831d5f58 100644 (file)
@@ -36,10 +36,7 @@ enum {
   ELF_WeakrefUsedInReloc_Shift = 11,
 
   // One bit.
-  ELF_UsedInReloc_Shift = 12,
-
-  // One bit.
-  ELF_BindingSet_Shift = 13
+  ELF_BindingSet_Shift = 12
 };
 }
 
@@ -175,15 +172,6 @@ unsigned MCSymbolELF::getOther() const {
   return Other << 5;
 }
 
-void MCSymbolELF::setUsedInReloc() const {
-  uint32_t OtherFlags = getFlags() & ~(0x1 << ELF_UsedInReloc_Shift);
-  setFlags(OtherFlags | (1 << ELF_UsedInReloc_Shift));
-}
-
-bool MCSymbolELF::isUsedInReloc() const {
-  return getFlags() & (0x1 << ELF_UsedInReloc_Shift);
-}
-
 void MCSymbolELF::setIsWeakrefUsedInReloc() const {
   uint32_t OtherFlags = getFlags() & ~(0x1 << ELF_WeakrefUsedInReloc_Shift);
   setFlags(OtherFlags | (1 << ELF_WeakrefUsedInReloc_Shift));
index 67af810bbbecd5511db376cbd76ba862b87f36fe..741b273073e48ea0a3a0c4414beddf73add497da 100644 (file)
@@ -287,7 +287,7 @@ void AArch64MachObjectWriter::recordRelocation(
     if (Symbol->isTemporary() && (Value || !CanUseLocalRelocation)) {
       const MCSection &Sec = Symbol->getSection();
       if (!Asm.getContext().getAsmInfo()->isSectionAtomizableBySymbols(Sec))
-        Asm.addLocalUsedInReloc(*Symbol);
+        Symbol->setUsedInReloc();
     }
 
     const MCSymbol *Base = Asm.getAtom(*Symbol);
index 95acc07192daa4b11fe9bc10e1dce236ebd96975..9e801fc8f1916c185981d81c6b680c8e6c5668fc 100644 (file)
@@ -205,7 +205,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(
     if (Symbol->isTemporary() && Value) {
       const MCSection &Sec = Symbol->getSection();
       if (!Asm.getContext().getAsmInfo()->isSectionAtomizableBySymbols(Sec))
-        Asm.addLocalUsedInReloc(*Symbol);
+        Symbol->setUsedInReloc();
     }
     RelSymbol = Asm.getAtom(*Symbol);