[lld] r298557 - Rename forEach -> parallelForEach and forLoop -> parallelFor.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 22 16:03:36 PDT 2017


Author: ruiu
Date: Wed Mar 22 18:03:35 2017
New Revision: 298557

URL: http://llvm.org/viewvc/llvm-project?rev=298557&view=rev
Log:
Rename forEach -> parallelForEach and forLoop -> parallelFor.

"Parallel" is the most important aspect of the functions,
so we shouldn't omit that.

Modified:
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/ICF.cpp
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/SyntheticSections.cpp
    lld/trunk/ELF/Threads.h

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=298557&r1=298556&r2=298557&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Wed Mar 22 18:03:35 2017
@@ -942,14 +942,15 @@ template <class ELFT> void LinkerDriver:
 
   // MergeInputSection::splitIntoPieces needs to be called before
   // any call of MergeInputSection::getOffset. Do that.
-  forEach(InputSections.begin(), InputSections.end(), [](InputSectionBase *S) {
-    if (!S->Live)
-      return;
-    if (Decompressor::isCompressedELFSection(S->Flags, S->Name))
-      S->uncompress();
-    if (auto *MS = dyn_cast<MergeInputSection>(S))
-      MS->splitIntoPieces();
-  });
+  parallelForEach(InputSections.begin(), InputSections.end(),
+                  [](InputSectionBase *S) {
+                    if (!S->Live)
+                      return;
+                    if (Decompressor::isCompressedELFSection(S->Flags, S->Name))
+                      S->uncompress();
+                    if (auto *MS = dyn_cast<MergeInputSection>(S))
+                      MS->splitIntoPieces();
+                  });
 
   // Write the result to the file.
   writeResult<ELFT>();

Modified: lld/trunk/ELF/ICF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ICF.cpp?rev=298557&r1=298556&r2=298557&view=diff
==============================================================================
--- lld/trunk/ELF/ICF.cpp (original)
+++ lld/trunk/ELF/ICF.cpp Wed Mar 22 18:03:35 2017
@@ -325,8 +325,9 @@ void ICF<ELFT>::forEachClass(std::functi
   // Split sections into 256 shards and call Fn in parallel.
   size_t NumShards = 256;
   size_t Step = Sections.size() / NumShards;
-  forLoop(0, NumShards,
-          [&](size_t I) { forEachClassRange(I * Step, (I + 1) * Step, Fn); });
+  parallelFor(0, NumShards, [&](size_t I) {
+    forEachClassRange(I * Step, (I + 1) * Step, Fn);
+  });
   forEachClassRange(Step * NumShards, Sections.size(), Fn);
   ++Cnt;
 }

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=298557&r1=298556&r2=298557&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Wed Mar 22 18:03:35 2017
@@ -238,8 +238,8 @@ template <class ELFT> void OutputSection
   if (uint32_t Filler = Script->getFiller(this->Name))
     fill(Buf, this->Size, Filler);
 
-  auto Fn = [=](InputSection *IS) { IS->writeTo<ELFT>(Buf); };
-  forEach(Sections.begin(), Sections.end(), Fn);
+  parallelForEach(Sections.begin(), Sections.end(),
+                  [=](InputSection *IS) { IS->writeTo<ELFT>(Buf); });
 
   // Linker scripts may have BYTE()-family commands with which you
   // can write arbitrary bytes to the output. Process them if any.

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=298557&r1=298556&r2=298557&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Wed Mar 22 18:03:35 2017
@@ -356,8 +356,9 @@ void BuildIdSection::computeHash(
   std::vector<uint8_t> Hashes(Chunks.size() * HashSize);
 
   // Compute hash values.
-  forLoop(0, Chunks.size(),
-          [&](size_t I) { HashFn(Hashes.data() + I * HashSize, Chunks[I]); });
+  parallelFor(0, Chunks.size(), [&](size_t I) {
+    HashFn(Hashes.data() + I * HashSize, Chunks[I]);
+  });
 
   // Write to the final output buffer.
   HashFn(HashBuf, Hashes);

Modified: lld/trunk/ELF/Threads.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Threads.h?rev=298557&r1=298556&r2=298557&view=diff
==============================================================================
--- lld/trunk/ELF/Threads.h (original)
+++ lld/trunk/ELF/Threads.h Wed Mar 22 18:03:35 2017
@@ -69,14 +69,15 @@ namespace lld {
 namespace elf {
 
 template <class IterTy, class FuncTy>
-void forEach(IterTy Begin, IterTy End, FuncTy Fn) {
+void parallelForEach(IterTy Begin, IterTy End, FuncTy Fn) {
   if (Config->Threads)
     parallel_for_each(Begin, End, Fn);
   else
     std::for_each(Begin, End, Fn);
 }
 
-inline void forLoop(size_t Begin, size_t End, std::function<void(size_t)> Fn) {
+inline void parallelFor(size_t Begin, size_t End,
+                        std::function<void(size_t)> Fn) {
   if (Config->Threads) {
     parallel_for(Begin, End, Fn);
   } else {




More information about the llvm-commits mailing list