[lld] r227132 - Use parallel_sort in the LayoutPass.
Rui Ueyama
ruiu at google.com
Mon Jan 26 12:18:37 PST 2015
Author: ruiu
Date: Mon Jan 26 14:18:37 2015
New Revision: 227132
URL: http://llvm.org/viewvc/llvm-project?rev=227132&view=rev
Log:
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.
Modified:
lld/trunk/include/lld/Core/Parallel.h
lld/trunk/lib/Passes/LayoutPass.cpp
Modified: lld/trunk/include/lld/Core/Parallel.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Parallel.h?rev=227132&r1=227131&r2=227132&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Parallel.h (original)
+++ lld/trunk/include/lld/Core/Parallel.h Mon Jan 26 14:18:37 2015
@@ -221,8 +221,8 @@ void parallel_quick_sort(RandomAccessIte
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));
Modified: lld/trunk/lib/Passes/LayoutPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Passes/LayoutPass.cpp?rev=227132&r1=227131&r2=227132&view=diff
==============================================================================
--- lld/trunk/lib/Passes/LayoutPass.cpp (original)
+++ lld/trunk/lib/Passes/LayoutPass.cpp Mon Jan 26 14:18:37 2015
@@ -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
});
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);
});
More information about the llvm-commits
mailing list