[PATCH] D36089: [ELF] - Replace parallelForEach with ranged form.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 4 01:31:16 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL310040: [ELF] - Replace parallelForEach with ranged form. (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D36089?vs=109066&id=109688#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36089

Files:
  lld/trunk/ELF/SyntheticSections.cpp
  lld/trunk/ELF/Threads.h
  lld/trunk/ELF/Writer.cpp


Index: lld/trunk/ELF/Threads.h
===================================================================
--- lld/trunk/ELF/Threads.h
+++ lld/trunk/ELF/Threads.h
@@ -67,12 +67,11 @@
 namespace lld {
 namespace elf {
 
-template <class IterTy, class FuncTy>
-void parallelForEach(IterTy Begin, IterTy End, FuncTy Fn) {
+template <typename R, class FuncTy> void parallelForEach(R &&Range, FuncTy Fn) {
   if (Config->Threads)
-    for_each(llvm::parallel::par, Begin, End, Fn);
+    for_each(llvm::parallel::par, std::begin(Range), std::end(Range), Fn);
   else
-    for_each(llvm::parallel::seq, Begin, End, Fn);
+    for_each(llvm::parallel::seq, std::begin(Range), std::end(Range), Fn);
 }
 
 inline void parallelForEachN(size_t Begin, size_t End,
Index: lld/trunk/ELF/SyntheticSections.cpp
===================================================================
--- lld/trunk/ELF/SyntheticSections.cpp
+++ lld/trunk/ELF/SyntheticSections.cpp
@@ -2218,15 +2218,14 @@
 void elf::decompressAndMergeSections() {
   // splitIntoPieces needs to be called on each MergeInputSection before calling
   // finalizeContents(). Do that first.
-  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();
-                  });
+  parallelForEach(InputSections, [](InputSectionBase *S) {
+    if (!S->Live)
+      return;
+    if (Decompressor::isCompressedELFSection(S->Flags, S->Name))
+      S->uncompress();
+    if (auto *MS = dyn_cast<MergeInputSection>(S))
+      MS->splitIntoPieces();
+  });
 
   std::vector<MergeSyntheticSection *> MergeSections;
   for (InputSectionBase *&S : InputSections) {
Index: lld/trunk/ELF/Writer.cpp
===================================================================
--- lld/trunk/ELF/Writer.cpp
+++ lld/trunk/ELF/Writer.cpp
@@ -199,7 +199,7 @@
   // If -compressed-debug-sections is specified, we need to compress
   // .debug_* sections. Do it right now because it changes the size of
   // output sections.
-  parallelForEach(OutputSections.begin(), OutputSections.end(),
+  parallelForEach(OutputSections,
                   [](OutputSection *Sec) { Sec->maybeCompress<ELFT>(); });
 
   Script->assignAddresses();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36089.109688.patch
Type: text/x-patch
Size: 2484 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170804/97fadfb9/attachment-0001.bin>


More information about the llvm-commits mailing list