[lld] r317450 - ELF: Remove SymbolTable::SymIndex class.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 5 20:58:04 PST 2017
Author: pcc
Date: Sun Nov 5 20:58:04 2017
New Revision: 317450
URL: http://llvm.org/viewvc/llvm-project?rev=317450&view=rev
Log:
ELF: Remove SymbolTable::SymIndex class.
The Traced flag is unnecessary because we only need to set the index
to -1 to mark a symbol for tracing.
Differential Revision: https://reviews.llvm.org/D39672
Modified:
lld/trunk/ELF/SymbolTable.cpp
lld/trunk/ELF/SymbolTable.h
Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=317450&r1=317449&r2=317450&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Sun Nov 5 20:58:04 2017
@@ -145,7 +145,7 @@ Defined *SymbolTable::addAbsolute(String
// Set a flag for --trace-symbol so that we can print out a log message
// if a new symbol with the same name is inserted into the symbol table.
void SymbolTable::trace(StringRef Name) {
- Symtab.insert({CachedHashStringRef(Name), {-1, true}});
+ Symtab.insert({CachedHashStringRef(Name), -1});
}
// Rename SYM as __wrap_SYM. The original symbol is preserved as __real_SYM.
@@ -224,14 +224,14 @@ std::pair<Symbol *, bool> SymbolTable::i
if (Pos != StringRef::npos && Pos + 1 < Name.size() && Name[Pos + 1] == '@')
Name = Name.take_front(Pos);
- auto P = Symtab.insert(
- {CachedHashStringRef(Name), SymIndex((int)SymVector.size(), false)});
- SymIndex &V = P.first->second;
+ auto P = Symtab.insert({CachedHashStringRef(Name), (int)SymVector.size()});
+ int &SymIndex = P.first->second;
bool IsNew = P.second;
+ bool Traced = false;
- if (V.Idx == -1) {
- IsNew = true;
- V = SymIndex((int)SymVector.size(), true);
+ if (SymIndex == -1) {
+ SymIndex = SymVector.size();
+ IsNew = Traced = true;
}
Symbol *Sym;
@@ -243,11 +243,11 @@ std::pair<Symbol *, bool> SymbolTable::i
Sym->IsUsedInRegularObj = false;
Sym->ExportDynamic = false;
Sym->CanInline = true;
- Sym->Traced = V.Traced;
+ Sym->Traced = Traced;
Sym->VersionId = Config->DefaultSymbolVersion;
SymVector.push_back(Sym);
} else {
- Sym = SymVector[V.Idx];
+ Sym = SymVector[SymIndex];
}
return {Sym, IsNew};
}
@@ -530,10 +530,9 @@ Symbol *SymbolTable::find(StringRef Name
auto It = Symtab.find(CachedHashStringRef(Name));
if (It == Symtab.end())
return nullptr;
- SymIndex V = It->second;
- if (V.Idx == -1)
+ if (It->second == -1)
return nullptr;
- return SymVector[V.Idx];
+ return SymVector[It->second];
}
template <class ELFT>
Modified: lld/trunk/ELF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=317450&r1=317449&r2=317450&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.h (original)
+++ lld/trunk/ELF/SymbolTable.h Sun Nov 5 20:58:04 2017
@@ -99,12 +99,6 @@ private:
StringRef VersionName);
void assignWildcardVersion(SymbolVersion Ver, uint16_t VersionId);
- struct SymIndex {
- SymIndex(int Idx, bool Traced) : Idx(Idx), Traced(Traced) {}
- int Idx : 31;
- unsigned Traced : 1;
- };
-
// The order the global symbols are in is not defined. We can use an arbitrary
// order, but it has to be reproducible. That is true even when cross linking.
// The default hashing of StringRef produces different results on 32 and 64
@@ -112,7 +106,7 @@ private:
// but a bit inefficient.
// FIXME: Experiment with passing in a custom hashing or sorting the symbols
// once symbol resolution is finished.
- llvm::DenseMap<llvm::CachedHashStringRef, SymIndex> Symtab;
+ llvm::DenseMap<llvm::CachedHashStringRef, int> Symtab;
std::vector<Symbol *> SymVector;
// Comdat groups define "link once" sections. If two comdat groups have the
More information about the llvm-commits
mailing list