[lld][MachO] Sort symbols in parallel in -map

source: https://bugs.llvm.org/show_bug.cgi?id=50689

When writing a map file, sort symbols in parallel using parallelSort.
Use address name to break ties if two symbols have the same address.

Reviewed By: thakis, int3

Differential Revision: https://reviews.llvm.org/D104346
This commit is contained in:
Xuanda Yang 2021-06-17 10:13:15 +08:00
parent 5a55205bb3
commit 01cb9c5fc5

View file

@ -52,9 +52,11 @@ static SymbolMapTy getSectionSyms(ArrayRef<Defined *> syms) {
// appear in the output file rather than the order they appeared in the input
// files.
for (auto &it : ret)
llvm::stable_sort(it.second, [](Defined *a, Defined *b) {
return a->getVA() < b->getVA();
});
parallelSort(
it.second.begin(), it.second.end(), [](Defined *a, Defined *b) {
return a->getVA() != b->getVA() ? a->getVA() < b->getVA()
: a->getName() < b->getName();
});
return ret;
}