Move IsUsedInReloc from MCSymbolELF to MCSymbol.

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
This commit is contained in:
Rafael Espindola
2015-06-17 20:08:20 +00:00
parent 1c63fe6c61
commit a1e31b45cc
7 changed files with 14 additions and 38 deletions

View File

@ -621,8 +621,6 @@ private:
SymbolDataListType Symbols; SymbolDataListType Symbols;
DenseSet<const MCSymbol *> LocalsUsedInReloc;
std::vector<IndirectSymbolData> IndirectSymbols; std::vector<IndirectSymbolData> IndirectSymbols;
std::vector<DataRegionData> DataRegions; std::vector<DataRegionData> DataRegions;
@ -713,9 +711,6 @@ private:
MCFragment &F, const MCFixup &Fixup); MCFragment &F, const MCFixup &Fixup);
public: 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 /// Compute the effective fragment size assuming it is laid out at the given
/// \p SectionAddress and \p FragmentOffset. /// \p SectionAddress and \p FragmentOffset.
uint64_t computeFragmentSize(const MCAsmLayout &Layout, uint64_t computeFragmentSize(const MCAsmLayout &Layout,

View File

@ -95,6 +95,9 @@ protected:
/// unsigned to avoid sign extension and achieve better bitpacking with MSVC. /// unsigned to avoid sign extension and achieve better bitpacking with MSVC.
unsigned Kind : 2; 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. /// Index field, for use by the object file implementation.
mutable uint32_t Index = 0; mutable uint32_t Index = 0;
@ -129,10 +132,10 @@ protected: // MCContext creates and uniques these.
} NameEntryStorageTy; } NameEntryStorageTy;
MCSymbol(SymbolKind Kind, const StringMapEntry<bool> *Name, bool isTemporary) MCSymbol(SymbolKind Kind, const StringMapEntry<bool> *Name, bool isTemporary)
: Value(nullptr), IsTemporary(isTemporary), : Value(nullptr), IsTemporary(isTemporary), IsRedefinable(false),
IsRedefinable(false), IsUsed(false), IsRegistered(false), IsUsed(false), IsRegistered(false), IsExternal(false),
IsExternal(false), IsPrivateExtern(false), HasName(!!Name), IsPrivateExtern(false), HasName(!!Name), Kind(Kind),
Kind(Kind) { IsUsedInReloc(false) {
Offset = 0; Offset = 0;
if (Name) if (Name)
getNameEntryPtr() = Name; getNameEntryPtr() = Name;
@ -189,6 +192,9 @@ public:
bool isRegistered() const { return IsRegistered; } bool isRegistered() const { return IsRegistered; }
void setIsRegistered(bool Value) const { IsRegistered = Value; } void setIsRegistered(bool Value) const { IsRegistered = Value; }
void setUsedInReloc() const { IsUsedInReloc = true; }
bool isUsedInReloc() const { return IsUsedInReloc; }
/// \name Accessors /// \name Accessors
/// @{ /// @{

View File

@ -38,9 +38,6 @@ public:
bool isBindingSet() const; bool isBindingSet() const;
void setUsedInReloc() const;
bool isUsedInReloc() const;
void setIsWeakrefUsedInReloc() const; void setIsWeakrefUsedInReloc() const;
bool isWeakrefUsedInReloc() const; bool isWeakrefUsedInReloc() const;

View File

@ -345,16 +345,6 @@ bool MCAssembler::isThumbFunc(const MCSymbol *Symbol) const {
return true; 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 { bool MCAssembler::isSymbolLinkerVisible(const MCSymbol &Symbol) const {
// Non-temporary labels should always be visible to the linker. // Non-temporary labels should always be visible to the linker.
if (!Symbol.isTemporary()) if (!Symbol.isTemporary())
@ -364,7 +354,7 @@ bool MCAssembler::isSymbolLinkerVisible(const MCSymbol &Symbol) const {
if (!Symbol.isInSection()) if (!Symbol.isInSection())
return false; return false;
if (isLocalUsedInReloc(Symbol)) if (Symbol.isUsedInReloc())
return true; return true;
return false; return false;

View File

@ -36,10 +36,7 @@ enum {
ELF_WeakrefUsedInReloc_Shift = 11, ELF_WeakrefUsedInReloc_Shift = 11,
// One bit. // One bit.
ELF_UsedInReloc_Shift = 12, ELF_BindingSet_Shift = 12
// One bit.
ELF_BindingSet_Shift = 13
}; };
} }
@ -175,15 +172,6 @@ unsigned MCSymbolELF::getOther() const {
return Other << 5; 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 { void MCSymbolELF::setIsWeakrefUsedInReloc() const {
uint32_t OtherFlags = getFlags() & ~(0x1 << ELF_WeakrefUsedInReloc_Shift); uint32_t OtherFlags = getFlags() & ~(0x1 << ELF_WeakrefUsedInReloc_Shift);
setFlags(OtherFlags | (1 << ELF_WeakrefUsedInReloc_Shift)); setFlags(OtherFlags | (1 << ELF_WeakrefUsedInReloc_Shift));

View File

@ -287,7 +287,7 @@ void AArch64MachObjectWriter::recordRelocation(
if (Symbol->isTemporary() && (Value || !CanUseLocalRelocation)) { if (Symbol->isTemporary() && (Value || !CanUseLocalRelocation)) {
const MCSection &Sec = Symbol->getSection(); const MCSection &Sec = Symbol->getSection();
if (!Asm.getContext().getAsmInfo()->isSectionAtomizableBySymbols(Sec)) if (!Asm.getContext().getAsmInfo()->isSectionAtomizableBySymbols(Sec))
Asm.addLocalUsedInReloc(*Symbol); Symbol->setUsedInReloc();
} }
const MCSymbol *Base = Asm.getAtom(*Symbol); const MCSymbol *Base = Asm.getAtom(*Symbol);

View File

@ -205,7 +205,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(
if (Symbol->isTemporary() && Value) { if (Symbol->isTemporary() && Value) {
const MCSection &Sec = Symbol->getSection(); const MCSection &Sec = Symbol->getSection();
if (!Asm.getContext().getAsmInfo()->isSectionAtomizableBySymbols(Sec)) if (!Asm.getContext().getAsmInfo()->isSectionAtomizableBySymbols(Sec))
Asm.addLocalUsedInReloc(*Symbol); Symbol->setUsedInReloc();
} }
RelSymbol = Asm.getAtom(*Symbol); RelSymbol = Asm.getAtom(*Symbol);