Revert r285968: Always use parallel_for_each because it falls back to std::for_each.
authorRui Ueyama <ruiu@google.com>
Fri, 4 Nov 2016 18:22:36 +0000 (18:22 +0000)
committerRui Ueyama <ruiu@google.com>
Fri, 4 Nov 2016 18:22:36 +0000 (18:22 +0000)
It turned ou that we actually want to call std::for_each even if
threading is supported. Unless --thread is given, LLD shouldn't use
more than one threads.

llvm-svn: 286004

lld/ELF/OutputSections.cpp

index 781d972..9179d19 100644 (file)
@@ -1064,8 +1064,13 @@ template <class ELFT> void OutputSection<ELFT>::writeTo(uint8_t *Buf) {
   ArrayRef<uint8_t> Filler = Script<ELFT>::X->getFiller(this->Name);
   if (!Filler.empty())
     fill(Buf, this->getSize(), Filler);
-  parallel_for_each(Sections.begin(), Sections.end(),
-                    [=](InputSection<ELFT> *C) { C->writeTo(Buf); });
+  if (Config->Threads) {
+    parallel_for_each(Sections.begin(), Sections.end(),
+                      [=](InputSection<ELFT> *C) { C->writeTo(Buf); });
+  } else {
+    for (InputSection<ELFT> *C : Sections)
+      C->writeTo(Buf);
+  }
   // Linker scripts may have BYTE()-family commands with which you
   // can write arbitrary bytes to the output. Process them if any.
   Script<ELFT>::X->writeDataBytes(this->Name, Buf);