[Support] Move LLD's parallel algorithm wrappers to support
authorReid Kleckner <rnk@google.com>
Tue, 5 May 2020 03:03:19 +0000 (20:03 -0700)
committerReid Kleckner <rnk@google.com>
Tue, 5 May 2020 22:21:05 +0000 (15:21 -0700)
commit932f0276ea29fd58e1a07947e302f3ca9b54e61a
treed533bbdee5e0a5d4742089abb64a1fb2cce155e9
parent855e02e799b9b05babc39cba1cb121ad7ef50f57
[Support] Move LLD's parallel algorithm wrappers to support

Essentially takes the lld/Common/Threads.h wrappers and moves them to
the llvm/Support/Paralle.h algorithm header.

The changes are:
- Remove policy parameter, since all clients use `par`.
- Rename the methods to `parallelSort` etc to match LLVM style, since
  they are no longer C++17 pstl compatible.
- Move algorithms from llvm::parallel:: to llvm::, since they have
  "parallel" in the name and are no longer overloads of the regular
  algorithms.
- Add range overloads
- Use the sequential algorithm directly when 1 thread is requested
  (skips task grouping)
- Fix the index type of parallelForEachN to size_t. Nobody in LLVM was
  using any other parameter, and it made overload resolution hard for
  for_each_n(par, 0, foo.size(), ...) because 0 is int, not size_t.

Remove Threads.h and update LLD for that.

This is a prerequisite for parallel public symbol processing in the PDB
library, which is in LLVM.

Reviewed By: MaskRay, aganea

Differential Revision: https://reviews.llvm.org/D79390
25 files changed:
lld/COFF/Driver.cpp
lld/COFF/ICF.cpp
lld/COFF/LLDMapFile.cpp
lld/COFF/MapFile.cpp
lld/COFF/PDB.cpp
lld/COFF/Writer.cpp
lld/Common/ErrorHandler.cpp
lld/Common/Filesystem.cpp
lld/ELF/Driver.cpp
lld/ELF/ICF.cpp
lld/ELF/LinkerScript.cpp
lld/ELF/MapFile.cpp
lld/ELF/OutputSections.cpp
lld/ELF/SyntheticSections.cpp
lld/ELF/Writer.cpp
lld/include/lld/Common/Threads.h [deleted file]
lld/lib/ReaderWriter/MachO/LayoutPass.cpp
lld/wasm/Driver.cpp
lld/wasm/OutputSections.cpp
lld/wasm/Writer.cpp
llvm/include/llvm/Support/Parallel.h
llvm/unittests/Support/ParallelTest.cpp
mlir/docs/Diagnostics.md
mlir/lib/Pass/Pass.cpp
mlir/lib/Transforms/Inliner.cpp