[PATCH] D33330: COFF: Replace DLLNames maps with vectors.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 18 11:44:07 PDT 2017
pcc created this revision.
The import lists are already binned by DLL name, so there's no need to
deduplicate here.
https://reviews.llvm.org/D33330
Files:
lld/COFF/DLL.cpp
lld/COFF/DLL.h
Index: lld/COFF/DLL.h
===================================================================
--- lld/COFF/DLL.h
+++ lld/COFF/DLL.h
@@ -39,7 +39,7 @@
std::vector<std::unique_ptr<Chunk>> Lookups;
std::vector<std::unique_ptr<Chunk>> Addresses;
std::vector<std::unique_ptr<Chunk>> Hints;
- std::map<StringRef, std::unique_ptr<Chunk>> DLLNames;
+ std::vector<std::unique_ptr<Chunk>> DLLNames;
};
// Windows-specific.
@@ -67,7 +67,7 @@
std::vector<std::unique_ptr<Chunk>> Names;
std::vector<std::unique_ptr<Chunk>> HintNames;
std::vector<std::unique_ptr<Chunk>> Thunks;
- std::map<StringRef, std::unique_ptr<Chunk>> DLLNames;
+ std::vector<std::unique_ptr<Chunk>> DLLNames;
};
// Windows-specific.
Index: lld/COFF/DLL.cpp
===================================================================
--- lld/COFF/DLL.cpp
+++ lld/COFF/DLL.cpp
@@ -394,20 +394,16 @@
V.push_back(C.get());
for (std::unique_ptr<Chunk> &C : Hints)
V.push_back(C.get());
- for (auto &P : DLLNames) {
- std::unique_ptr<Chunk> &C = P.second;
+ for (std::unique_ptr<Chunk> &C : DLLNames)
V.push_back(C.get());
- }
return V;
}
void IdataContents::create() {
std::vector<std::vector<DefinedImportData *>> V = binImports(Imports);
// 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
@@ -433,9 +429,8 @@
Syms[I]->setLocation(Addresses[Base + I].get());
// Create the import table header.
- if (!DLLNames.count(Name))
- DLLNames[Name] = make_unique<StringChunk>(Name);
- auto Dir = make_unique<ImportDirectoryChunk>(DLLNames[Name].get());
+ DLLNames.push_back(make_unique<StringChunk>(Syms[0]->getDLLName()));
+ auto Dir = make_unique<ImportDirectoryChunk>(DLLNames.back().get());
Dir->LookupTab = Lookups[Base].get();
Dir->AddressTab = Addresses[Base].get();
Dirs.push_back(std::move(Dir));
@@ -452,10 +447,8 @@
V.push_back(C.get());
for (std::unique_ptr<Chunk> &C : HintNames)
V.push_back(C.get());
- for (auto &P : DLLNames) {
- std::unique_ptr<Chunk> &C = P.second;
+ for (std::unique_ptr<Chunk> &C : DLLNames)
V.push_back(C.get());
- }
return V;
}
@@ -478,12 +471,9 @@
// 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_unique<StringChunk>(Name);
- auto Dir = make_unique<DelayDirectoryChunk>(DLLNames[Name].get());
+ DLLNames.push_back(make_unique<StringChunk>(Syms[0]->getDLLName()));
+ auto Dir = make_unique<DelayDirectoryChunk>(DLLNames.back().get());
size_t Base = Addresses.size();
for (DefinedImportData *S : Syms) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33330.99471.patch
Type: text/x-patch
Size: 3040 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170518/2e4c4f70/attachment.bin>
More information about the llvm-commits
mailing list