Revert "Make COFF linker work when it's built by clang again."

This reverts commit r242006. The original issue in Clang was fixed in r242009,
so we can now safely use std::atomic_flag.

llvm-svn: 242112
This commit is contained in:
Rui Ueyama 2015-07-14 03:09:59 +00:00
parent 326c2c4cff
commit 159fb4cd84
2 changed files with 8 additions and 3 deletions

View File

@ -71,6 +71,12 @@ std::error_code ArchiveFile::parse() {
if (B->getName() != "__NULL_IMPORT_DESCRIPTOR")
LazySymbols.push_back(B);
}
// 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.
for (const Archive::Child &Child : File->children())
Seen[Child.getBuffer().data()].clear();
return std::error_code();
}
@ -84,8 +90,7 @@ ErrorOr<MemoryBufferRef> ArchiveFile::getMember(const Archive::Symbol *Sym) {
// Return an empty buffer if we have already returned the same buffer.
const char *StartAddr = It->getBuffer().data();
auto Pair = Seen.insert(StartAddr);
if (!Pair.second)
if (Seen[StartAddr].test_and_set())
return MemoryBufferRef();
return It->getMemoryBufferRef();
}

View File

@ -107,7 +107,7 @@ private:
std::unique_ptr<Archive> File;
std::string Filename;
std::vector<Lazy *> LazySymbols;
std::set<const char *> Seen;
std::map<const char *, std::atomic_flag> Seen;
llvm::MallocAllocator Alloc;
};