From 3165dbffa99ce176df0b3568c21636e2967ebdef Mon Sep 17 00:00:00 2001 From: Patrick Wildt Date: Tue, 24 Jan 2017 08:33:38 +0000 Subject: Import LLVM 4.0.0 rc1 including clang and lld to help the current development effort on OpenBSD/arm64. --- gnu/llvm/tools/lld/ELF/Memory.h | 4 ++-- gnu/llvm/tools/lld/ELF/Threads.h | 30 ++++++++++++++++-------------- 2 files changed, 18 insertions(+), 16 deletions(-) (limited to 'gnu/llvm/tools') 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 #include namespace lld { namespace elf { template -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 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 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 -- cgit v1.2.3