[PATCH] D27667: COFF: Use a DenseSet instead of a map to atomic_flag to track which archive members have been read.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 11 17:41:25 PST 2016
pcc created this revision.
pcc added a reviewer: ruiu.
pcc added a subscriber: llvm-commits.
https://reviews.llvm.org/D27667
Files:
lld/COFF/InputFiles.cpp
lld/COFF/InputFiles.h
Index: lld/COFF/InputFiles.h
===================================================================
--- lld/COFF/InputFiles.h
+++ lld/COFF/InputFiles.h
@@ -12,6 +12,7 @@
#include "lld/Core/LLVM.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseSet.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/LTO/legacy/LTOModule.h"
#include "llvm/Object/Archive.h"
@@ -91,7 +92,7 @@
private:
std::unique_ptr<Archive> File;
std::string Filename;
- std::map<uint64_t, std::atomic_flag> Seen;
+ llvm::DenseSet<uint64_t> Seen;
};
// .obj or .o file. This may be a member of an archive file.
Index: lld/COFF/InputFiles.cpp
===================================================================
--- lld/COFF/InputFiles.cpp
+++ lld/COFF/InputFiles.cpp
@@ -55,29 +55,19 @@
// Parse a MemoryBufferRef as an archive file.
File = check(Archive::create(MB), toString(this));
- // Seen is a map from member files to boolean values. Initially
- // all members are mapped to false, which indicates all these files
- // are not read yet.
- Error Err = Error::success();
- for (auto &Child : File->children(Err))
- Seen[Child.getChildOffset()].clear();
- if (Err)
- fatal(Err, toString(this));
-
// Read the symbol table to construct Lazy objects.
for (const Archive::Symbol &Sym : File->symbols())
Symtab->addLazy(this, Sym);
}
// Returns a buffer pointing to a member file containing a given symbol.
-// This function is thread-safe.
InputFile *ArchiveFile::getMember(const Archive::Symbol *Sym) {
const Archive::Child &C =
check(Sym->getMember(),
"could not get the member for symbol " + Sym->getName());
// Return an empty buffer if we have already returned the same buffer.
- if (Seen[C.getChildOffset()].test_and_set())
+ if (!Seen.insert(C.getChildOffset()).second)
return nullptr;
MemoryBufferRef MB =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27667.81040.patch
Type: text/x-patch
Size: 1883 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161212/8a8cbcff/attachment.bin>
More information about the llvm-commits
mailing list