Use CachedHashStringRef instead of CachedHash<StringRef>.
authorJustin Lebar <jlebar@google.com>
Tue, 18 Oct 2016 17:50:36 +0000 (17:50 +0000)
committerJustin Lebar <jlebar@google.com>
Tue, 18 Oct 2016 17:50:36 +0000 (17:50 +0000)
Summary:
This uses one less word on 64-bit platforms, so should be a strict
improvement.  This change also lets us get rid of llvm::CachedHash.

Reviewers: rafael, timshen

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D25646

llvm-svn: 284502

lld/ELF/SymbolTable.cpp
lld/ELF/SymbolTable.h

index 976f8d8..69626e0 100644 (file)
@@ -140,7 +140,7 @@ DefinedRegular<ELFT> *SymbolTable<ELFT>::addIgnored(StringRef Name,
 // 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.
 template <class ELFT> void SymbolTable<ELFT>::trace(StringRef Name) {
-  Symtab.insert({Name, {-1, true}});
+  Symtab.insert({CachedHashStringRef(Name), {-1, true}});
 }
 
 // Rename SYM as __wrap_SYM. The original symbol is preserved as __real_SYM.
@@ -201,7 +201,8 @@ static std::pair<StringRef, uint16_t> getSymbolVersion(StringRef S) {
 // Find an existing symbol or create and insert a new one.
 template <class ELFT>
 std::pair<Symbol *, bool> SymbolTable<ELFT>::insert(StringRef &Name) {
-  auto P = Symtab.insert({Name, SymIndex((int)SymVector.size(), false)});
+  auto P = Symtab.insert(
+      {CachedHashStringRef(Name), SymIndex((int)SymVector.size(), false)});
   SymIndex &V = P.first->second;
   bool IsNew = P.second;
 
@@ -461,7 +462,7 @@ Symbol *SymbolTable<ELFT>::addBitcode(StringRef Name, uint8_t Binding,
 }
 
 template <class ELFT> SymbolBody *SymbolTable<ELFT>::find(StringRef Name) {
-  auto It = Symtab.find(Name);
+  auto It = Symtab.find(CachedHashStringRef(Name));
   if (It == Symtab.end())
     return nullptr;
   SymIndex V = It->second;
index 9048062..7b6145f 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "InputFiles.h"
 #include "LTO.h"
+#include "llvm/ADT/CachedHashString.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/Support/Regex.h"
 
@@ -21,7 +22,7 @@ class Lazy;
 template <class ELFT> class OutputSectionBase;
 struct Symbol;
 
-typedef llvm::CachedHash<StringRef> SymName;
+typedef llvm::CachedHashStringRef SymName;
 
 // SymbolTable is a bucket of all known symbols, including defined,
 // undefined, or lazy symbols (the last one is symbols in archive