[lld] r347587 - [COFF] ICF: use parallelForEach{,N}
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 26 12:07:07 PST 2018
Author: maskray
Date: Mon Nov 26 12:07:07 2018
New Revision: 347587
URL: http://llvm.org/viewvc/llvm-project?rev=347587&view=rev
Log:
[COFF] ICF: use parallelForEach{,N}
Summary: They have an additional `ThreadsEnabled` check, which does not matter much.
Reviewers: pcc, ruiu, rnk
Reviewed By: ruiu
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D54812
Modified:
lld/trunk/COFF/ICF.cpp
Modified: lld/trunk/COFF/ICF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/ICF.cpp?rev=347587&r1=347586&r2=347587&view=diff
==============================================================================
--- lld/trunk/COFF/ICF.cpp (original)
+++ lld/trunk/COFF/ICF.cpp Mon Nov 26 12:07:07 2018
@@ -22,6 +22,7 @@
#include "Chunks.h"
#include "Symbols.h"
#include "lld/Common/ErrorHandler.h"
+#include "lld/Common/Threads.h"
#include "lld/Common/Timer.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/Support/Debug.h"
@@ -226,10 +227,10 @@ void ICF::forEachClass(std::function<voi
size_t Boundaries[NumShards + 1];
Boundaries[0] = 0;
Boundaries[NumShards] = Chunks.size();
- for_each_n(parallel::par, size_t(1), NumShards, [&](size_t I) {
+ parallelForEachN(1, NumShards, [&](size_t I) {
Boundaries[I] = findBoundary((I - 1) * Step, Chunks.size());
});
- for_each_n(parallel::par, size_t(1), NumShards + 1, [&](size_t I) {
+ parallelForEachN(1, NumShards + 1, [&](size_t I) {
if (Boundaries[I - 1] < Boundaries[I]) {
forEachClassRange(Boundaries[I - 1], Boundaries[I], Fn);
}
@@ -261,13 +262,13 @@ void ICF::run(ArrayRef<Chunk *> Vec) {
SC->Class[0] = NextId++;
// Initially, we use hash values to partition sections.
- for_each(parallel::par, Chunks.begin(), Chunks.end(), [&](SectionChunk *SC) {
+ parallelForEach(Chunks, [&](SectionChunk *SC) {
SC->Class[1] = xxHash64(SC->getContents());
});
// Combine the hashes of the sections referenced by each section into its
// hash.
- for_each(parallel::par, Chunks.begin(), Chunks.end(), [&](SectionChunk *SC) {
+ parallelForEach(Chunks, [&](SectionChunk *SC) {
uint32_t Hash = SC->Class[1];
for (Symbol *B : SC->symbols())
if (auto *Sym = dyn_cast_or_null<DefinedRegular>(B))
More information about the llvm-commits
mailing list