diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2017-01-24 08:33:38 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2017-01-24 08:33:38 +0000 |
commit | 3165dbffa99ce176df0b3568c21636e2967ebdef (patch) | |
tree | 997adf46d09d12db5310356961f16a24be02ce8d /gnu/llvm/tools | |
parent | 9ea554e0446e0e4517c3d01c5a262a88a0514f7a (diff) |
Import LLVM 4.0.0 rc1 including clang and lld to help the current
development effort on OpenBSD/arm64.
Diffstat (limited to 'gnu/llvm/tools')
-rw-r--r-- | gnu/llvm/tools/lld/ELF/Memory.h | 4 | ||||
-rw-r--r-- | gnu/llvm/tools/lld/ELF/Threads.h | 30 |
2 files changed, 18 insertions, 16 deletions
diff --git a/gnu/llvm/tools/lld/ELF/Memory.h b/gnu/llvm/tools/lld/ELF/Memory.h index 4000f2f9f1c..e5a04ed1e5a 100644 --- a/gnu/llvm/tools/lld/ELF/Memory.h +++ b/gnu/llvm/tools/lld/ELF/Memory.h @@ -61,7 +61,7 @@ inline void freeArena() { Alloc->reset(); BAlloc.Reset(); } -} // namespace elf -} // namespace lld +} +} #endif diff --git a/gnu/llvm/tools/lld/ELF/Threads.h b/gnu/llvm/tools/lld/ELF/Threads.h index 9feb8683976..c03e15253e1 100644 --- a/gnu/llvm/tools/lld/ELF/Threads.h +++ b/gnu/llvm/tools/lld/ELF/Threads.h @@ -15,7 +15,7 @@ // // That said, we don't want to do "too clever" things using threads. // Complex multi-threaded algorithms are sometimes extremely hard to -// reason about and can easily mess up the entire design. +// justify the correctness and can easily mess up the entire design. // // Fortunately, when a linker links large programs (when the link time is // most critical), it spends most of the time to work on massive number of @@ -34,7 +34,7 @@ // instead of std::for_each (or a plain for loop). Because tasks are // completely independent from each other, we can run them in parallel // without any coordination between them. That's very easy to understand -// and reason about. +// and justify. // // For the cases such as the latter, we can use parallel algorithms to // deal with massive data. We have to write code for a tailored algorithm @@ -61,28 +61,30 @@ #include "Config.h" -#include "llvm/Support/Parallel.h" +#include "lld/Core/Parallel.h" +#include <algorithm> #include <functional> namespace lld { namespace elf { template <class IterTy, class FuncTy> -void parallelForEach(IterTy Begin, IterTy End, FuncTy Fn) { +void forEach(IterTy Begin, IterTy End, FuncTy Fn) { if (Config->Threads) - for_each(llvm::parallel::par, Begin, End, Fn); + parallel_for_each(Begin, End, Fn); else - for_each(llvm::parallel::seq, Begin, End, Fn); + std::for_each(Begin, End, Fn); } -inline void parallelForEachN(size_t Begin, size_t End, - std::function<void(size_t)> Fn) { - if (Config->Threads) - for_each_n(llvm::parallel::par, Begin, End, Fn); - else - for_each_n(llvm::parallel::seq, Begin, End, Fn); +inline void forLoop(size_t Begin, size_t End, std::function<void(size_t)> Fn) { + if (Config->Threads) { + parallel_for(Begin, End, Fn); + } else { + for (size_t I = Begin; I < End; ++I) + Fn(I); + } +} +} } -} // namespace elf -} // namespace lld #endif |