[lld] r303371 - COFF: Replace DLLNames maps with vectors.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Thu May 18 11:53:39 PDT 2017


Author: pcc
Date: Thu May 18 13:53:39 2017
New Revision: 303371

URL: http://llvm.org/viewvc/llvm-project?rev=303371&view=rev
Log:
COFF: Replace DLLNames maps with vectors.

The import lists are already binned by DLL name, so there's no need to
deduplicate here.

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

Modified:
    lld/trunk/COFF/DLL.cpp
    lld/trunk/COFF/DLL.h

Modified: lld/trunk/COFF/DLL.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DLL.cpp?rev=303371&r1=303370&r2=303371&view=diff
==============================================================================
--- lld/trunk/COFF/DLL.cpp (original)
+++ lld/trunk/COFF/DLL.cpp Thu May 18 13:53:39 2017
@@ -391,8 +391,7 @@ std::vector<Chunk *> IdataContents::getC
   V.insert(V.end(), Lookups.begin(), Lookups.end());
   V.insert(V.end(), Addresses.begin(), Addresses.end());
   V.insert(V.end(), Hints.begin(), Hints.end());
-  for (auto &KV : DLLNames)
-    V.push_back(KV.second);
+  V.insert(V.end(), DLLNames.begin(), DLLNames.end());
   return V;
 }
 
@@ -401,8 +400,6 @@ void IdataContents::create() {
 
   // Create .idata contents for each DLL.
   for (std::vector<DefinedImportData *> &Syms : V) {
-    StringRef Name = Syms[0]->getDLLName();
-
     // Create lookup and address tables. If they have external names,
     // we need to create HintName chunks to store the names.
     // If they don't (if they are import-by-ordinals), we store only
@@ -428,9 +425,8 @@ void IdataContents::create() {
       Syms[I]->setLocation(Addresses[Base + I]);
 
     // Create the import table header.
-    if (!DLLNames.count(Name))
-      DLLNames[Name] = make<StringChunk>(Name);
-    auto *Dir = make<ImportDirectoryChunk>(DLLNames[Name]);
+    DLLNames.push_back(make<StringChunk>(Syms[0]->getDLLName()));
+    auto *Dir = make<ImportDirectoryChunk>(DLLNames.back());
     Dir->LookupTab = Lookups[Base];
     Dir->AddressTab = Addresses[Base];
     Dirs.push_back(Dir);
@@ -444,8 +440,7 @@ std::vector<Chunk *> DelayLoadContents::
   V.insert(V.end(), Dirs.begin(), Dirs.end());
   V.insert(V.end(), Names.begin(), Names.end());
   V.insert(V.end(), HintNames.begin(), HintNames.end());
-  for (auto &KV : DLLNames)
-    V.push_back(KV.second);
+  V.insert(V.end(), DLLNames.begin(), DLLNames.end());
   return V;
 }
 
@@ -466,12 +461,9 @@ void DelayLoadContents::create(Defined *
 
   // Create .didat contents for each DLL.
   for (std::vector<DefinedImportData *> &Syms : V) {
-    StringRef Name = Syms[0]->getDLLName();
-
     // Create the delay import table header.
-    if (!DLLNames.count(Name))
-      DLLNames[Name] = make<StringChunk>(Name);
-    auto *Dir = make<DelayDirectoryChunk>(DLLNames[Name]);
+    DLLNames.push_back(make<StringChunk>(Syms[0]->getDLLName()));
+    auto *Dir = make<DelayDirectoryChunk>(DLLNames.back());
 
     size_t Base = Addresses.size();
     for (DefinedImportData *S : Syms) {

Modified: lld/trunk/COFF/DLL.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DLL.h?rev=303371&r1=303370&r2=303371&view=diff
==============================================================================
--- lld/trunk/COFF/DLL.h (original)
+++ lld/trunk/COFF/DLL.h Thu May 18 13:53:39 2017
@@ -39,7 +39,7 @@ private:
   std::vector<Chunk *> Lookups;
   std::vector<Chunk *> Addresses;
   std::vector<Chunk *> Hints;
-  std::map<StringRef, Chunk *> DLLNames;
+  std::vector<Chunk *> DLLNames;
 };
 
 // Windows-specific.
@@ -67,7 +67,7 @@ private:
   std::vector<Chunk *> Names;
   std::vector<Chunk *> HintNames;
   std::vector<Chunk *> Thunks;
-  std::map<StringRef, Chunk *> DLLNames;
+  std::vector<Chunk *> DLLNames;
 };
 
 // Windows-specific.




More information about the llvm-commits mailing list