forked from OSchip/llvm-project
Use parallel_sort in the LayoutPass.
Time to link lld using lld improved from 5.7s to 5.4s on Windows. It's not a significant improvement but not bad for one-line change. This patch includes a bug fix for Parallel.h as the original code uses operator< instead of a compare function there. llvm-svn: 227132
This commit is contained in:
parent
00f792e19e
commit
87d10ef325
|
@ -221,8 +221,8 @@ void parallel_quick_sort(RandomAccessIterator start, RandomAccessIterator end,
|
|||
auto pivot = medianOf3(start, end, comp);
|
||||
// Move pivot to end.
|
||||
std::swap(*(end - 1), *pivot);
|
||||
pivot = std::partition(start, end - 1, [end](decltype(*start) v) {
|
||||
return v < *(end - 1);
|
||||
pivot = std::partition(start, end - 1, [&comp, end](decltype(*start) v) {
|
||||
return comp(v, *(end - 1));
|
||||
});
|
||||
// Move pivot to middle of partition.
|
||||
std::swap(*pivot, *(end - 1));
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "lld/Passes/LayoutPass.h"
|
||||
#include "lld/Core/Instrumentation.h"
|
||||
#include "lld/Core/Parallel.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include <algorithm>
|
||||
|
@ -534,7 +535,7 @@ void LayoutPass::perform(std::unique_ptr<MutableFile> &mergedFile) {
|
|||
});
|
||||
|
||||
std::vector<LayoutPass::SortKey> vec = decorate(atomRange);
|
||||
std::sort(vec.begin(), vec.end(),
|
||||
parallel_sort(vec.begin(), vec.end(),
|
||||
[&](const LayoutPass::SortKey &l, const LayoutPass::SortKey &r) -> bool {
|
||||
return compareAtoms(l, r, _customSorter);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue