[lld] r248052 - COFF: Parallelize Writer::writeSections().

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 18 15:07:11 PDT 2015


Author: ruiu
Date: Fri Sep 18 17:07:10 2015
New Revision: 248052

URL: http://llvm.org/viewvc/llvm-project?rev=248052&view=rev
Log:
COFF: Parallelize Writer::writeSections().

Self-hosting took 801 ms on my machine. Of which this function took
69 ms. Now it takes 37 ms. That is about 4% overall performance
improvement.

Modified:
    lld/trunk/COFF/Writer.cpp

Modified: lld/trunk/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=248052&r1=248051&r2=248052&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Fri Sep 18 17:07:10 2015
@@ -14,6 +14,7 @@
 #include "SymbolTable.h"
 #include "Symbols.h"
 #include "Writer.h"
+#include "lld/Core/Parallel.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/STLExtras.h"
@@ -708,8 +709,8 @@ void Writer::writeSections() {
     // ADD instructions).
     if (Sec->getPermissions() & IMAGE_SCN_CNT_CODE)
       memset(SecBuf, 0xCC, Sec->getRawSize());
-    for (Chunk *C : Sec->getChunks())
-      C->writeTo(SecBuf);
+    parallel_for_each(Sec->getChunks().begin(), Sec->getChunks().end(),
+                      [&](Chunk *C) { C->writeTo(SecBuf); });
   }
 }
 




More information about the llvm-commits mailing list