[lld] r290076 - Remove inappropriate use of CachedHashStringRef.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 18 19:14:16 PST 2016


Author: ruiu
Date: Sun Dec 18 21:14:16 2016
New Revision: 290076

URL: http://llvm.org/viewvc/llvm-project?rev=290076&view=rev
Log:
Remove inappropriate use of CachedHashStringRef.

Use of CachedHashStringRef makes sense only when we reuse hash values.
Sprinkling it to all DenseMap has no benefits and just complicates data types.
Basically we shouldn't use CachedHashStringRef unless there is a strong
reason to to do so.

Modified:
    lld/trunk/ELF/Config.h
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/InputSection.h
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=290076&r1=290075&r2=290076&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Sun Dec 18 21:14:16 2016
@@ -10,7 +10,6 @@
 #ifndef LLD_ELF_CONFIG_H
 #define LLD_ELF_CONFIG_H
 
-#include "llvm/ADT/CachedHashString.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ELF.h"
@@ -72,7 +71,7 @@ struct VersionDefinition {
 struct Configuration {
   InputFile *FirstElf = nullptr;
   uint8_t OSABI = 0;
-  llvm::DenseMap<llvm::CachedHashStringRef, unsigned> SymbolOrderingFile;
+  llvm::DenseMap<llvm::StringRef, unsigned> SymbolOrderingFile;
   llvm::StringMap<uint64_t> SectionStartMap;
   llvm::StringRef DynamicLinker;
   llvm::StringRef Entry;

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=290076&r1=290075&r2=290076&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Sun Dec 18 21:14:16 2016
@@ -487,7 +487,7 @@ static void parseSymbolOrderingList(Memo
   SmallVector<StringRef, 0> Arr;
   MB.getBuffer().split(Arr, '\n');
   for (StringRef S : Arr)
-    Config->SymbolOrderingFile.insert({CachedHashStringRef(S.trim()), I++});
+    Config->SymbolOrderingFile.insert({S.trim(), I++});
 }
 
 // Initializes Config members by the command line options.

Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=290076&r1=290075&r2=290076&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Sun Dec 18 21:14:16 2016
@@ -14,6 +14,7 @@
 #include "Relocations.h"
 #include "Thunks.h"
 #include "lld/Core/LLVM.h"
+#include "llvm/ADT/CachedHashString.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/TinyPtrVector.h"
 #include "llvm/Object/ELF.h"

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=290076&r1=290075&r2=290076&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sun Dec 18 21:14:16 2016
@@ -770,8 +770,7 @@ static void sortBySymbolsOrder(ArrayRef<
       auto *D = dyn_cast<DefinedRegular<ELFT>>(Body);
       if (!D || !D->Section)
         continue;
-      auto It =
-          Config->SymbolOrderingFile.find(CachedHashString(Body->getName()));
+      auto It = Config->SymbolOrderingFile.find(Body->getName());
       if (It == Config->SymbolOrderingFile.end())
         continue;
 
@@ -782,7 +781,7 @@ static void sortBySymbolsOrder(ArrayRef<
   }
 
   for (OutputSectionBase *Base : V)
-    if (OutputSection<ELFT> *Sec = dyn_cast<OutputSection<ELFT>>(Base))
+    if (auto *Sec = dyn_cast<OutputSection<ELFT>>(Base))
       Sec->sort([&](InputSection<ELFT> *S) {
         auto It = SectionsOrder.find(S);
         return It == SectionsOrder.end() ? UINT32_MAX : It->second;




More information about the llvm-commits mailing list