[lld] r314616 - Run writeTo() concurrently.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 30 19:25:34 PDT 2017


Author: ruiu
Date: Sat Sep 30 19:25:34 2017
New Revision: 314616

URL: http://llvm.org/viewvc/llvm-project?rev=314616&view=rev
Log:
Run writeTo() concurrently.

I don't know why we didn't use parallelForEach to call writeTo,
but there should be no reason to not do that, as most writeTo
functions are safe to run concurrently.

Modified:
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=314616&r1=314615&r2=314616&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sat Sep 30 19:25:34 2017
@@ -1910,14 +1910,16 @@ template <class ELFT> void Writer<ELFT>:
   // In -r or -emit-relocs mode, write the relocation sections first as in
   // ELf_Rel targets we might find out that we need to modify the relocated
   // section while doing it.
-  for (OutputSection *Sec : OutputSections)
+  parallelForEach(OutputSections, [&](OutputSection *Sec) {
     if (Sec->Type == SHT_REL || Sec->Type == SHT_RELA)
       Sec->writeTo<ELFT>(Buf + Sec->Offset);
+  });
 
-  for (OutputSection *Sec : OutputSections)
+  parallelForEach(OutputSections, [&](OutputSection *Sec) {
     if (Sec != Out::Opd && Sec != EhFrameHdr && Sec->Type != SHT_REL &&
         Sec->Type != SHT_RELA)
       Sec->writeTo<ELFT>(Buf + Sec->Offset);
+  });
 
   // The .eh_frame_hdr depends on .eh_frame section contents, therefore
   // it should be written after .eh_frame is written.




More information about the llvm-commits mailing list