[lld] r242006 - Make COFF linker work when it's built by clang again.

Nico Weber nicolasweber at gmx.de
Sun Jul 12 17:55:26 PDT 2015


Author: nico
Date: Sun Jul 12 19:55:26 2015
New Revision: 242006

URL: http://llvm.org/viewvc/llvm-project?rev=242006&view=rev
Log:
Make COFF linker work when it's built by clang again.

clang-cl doesn't compile std::atomic_flag correctly (PR24101).  Since the COFF
linker doesn't use threads yet, just revert r241420 and r241481 for now to
work around this clang-cl bug.

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

Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=242006&r1=242005&r2=242006&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Sun Jul 12 19:55:26 2015
@@ -71,12 +71,6 @@ 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();
 }
 
@@ -90,7 +84,8 @@ ErrorOr<MemoryBufferRef> ArchiveFile::ge
 
   // Return an empty buffer if we have already returned the same buffer.
   const char *StartAddr = It->getBuffer().data();
-  if (Seen[StartAddr].test_and_set())
+  auto Pair = Seen.insert(StartAddr);
+  if (!Pair.second)
     return MemoryBufferRef();
   return It->getMemoryBufferRef();
 }

Modified: lld/trunk/COFF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.h?rev=242006&r1=242005&r2=242006&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.h (original)
+++ lld/trunk/COFF/InputFiles.h Sun Jul 12 19:55:26 2015
@@ -107,7 +107,7 @@ private:
   std::unique_ptr<Archive> File;
   std::string Filename;
   std::vector<Lazy *> LazySymbols;
-  std::map<const char *, std::atomic_flag> Seen;
+  std::set<const char *> Seen;
   llvm::MallocAllocator Alloc;
 };
 





More information about the llvm-commits mailing list