[PATCH] D44716: [lld] fix data race in ICF.cpp
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 20 16:13:30 PDT 2018
ruiu added a comment.
Generally looking good.
================
Comment at: lld/COFF/ICF.cpp:205-208
for_each_n(parallel::par, size_t(0), NumShards, [&](size_t I) {
- size_t End = (I == NumShards - 1) ? Chunks.size() : (I + 1) * Step;
- forEachClassRange(I * Step, End, Fn);
+ size_t Begin = I == 0 ? 0 : findBoundary(I * Step - 1, Chunks.size());
+ Boundaries[I] = findBoundary(Begin, Chunks.size());
+ });
----------------
This doubles the total number of computation because you call findBoundary calls twice for each iteration. I wonder if we need to parallelize this in the first place. Maybe it is better to do this with a regular for loop?
================
Comment at: lld/COFF/ICF.cpp:210-213
+ if (I == 0)
+ forEachClassRange(0, Boundaries[I], Fn);
+ else if (Boundaries[I] > Boundaries[I - 1])
+ forEachClassRange(Boundaries[I - 1], Boundaries[I], Fn);
----------------
I would allocate NumShards+1 elements for Boundaries and set Boundaries[0] to 0, so that we don't need to special-case I==0.
https://reviews.llvm.org/D44716
More information about the llvm-commits
mailing list