[lld] r284502 - Use CachedHashStringRef instead of CachedHash<StringRef>.

Justin Lebar via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 18 10:50:36 PDT 2016


Author: jlebar
Date: Tue Oct 18 12:50:36 2016
New Revision: 284502

URL: http://llvm.org/viewvc/llvm-project?rev=284502&view=rev
Log:
Use CachedHashStringRef instead of CachedHash<StringRef>.

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

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=284502&r1=284501&r2=284502&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Tue Oct 18 12:50:36 2016
@@ -140,7 +140,7 @@ DefinedRegular<ELFT> *SymbolTable<ELFT>:
 // 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> ge
 // 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(St
 }
 
 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;

Modified: lld/trunk/ELF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=284502&r1=284501&r2=284502&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.h (original)
+++ lld/trunk/ELF/SymbolTable.h Tue Oct 18 12:50:36 2016
@@ -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




More information about the llvm-commits mailing list