[PATCH] D45969: [ELF] - Never use std::sort.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 24 02:59:00 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLD330702: [ELF] - Never use std::sort. (authored by grimar, committed by ).
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D45969
Files:
ELF/CallGraphSort.cpp
ELF/MapFile.cpp
ELF/SyntheticSections.cpp
ELF/Writer.cpp
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -1106,7 +1106,7 @@
}
OrderedSections.push_back({IS, I->second});
}
- std::sort(
+ llvm::sort(
OrderedSections.begin(), OrderedSections.end(),
[&](std::pair<InputSection *, int> A, std::pair<InputSection *, int> B) {
return A.second < B.second;
@@ -2056,10 +2056,10 @@
// Check whether sections overlap for a specific address range (file offsets,
// load and virtual adresses).
static void checkOverlap(StringRef Name, std::vector<SectionOffset> &Sections) {
- std::sort(Sections.begin(), Sections.end(),
- [=](const SectionOffset &A, const SectionOffset &B) {
- return A.Offset < B.Offset;
- });
+ llvm::sort(Sections.begin(), Sections.end(),
+ [=](const SectionOffset &A, const SectionOffset &B) {
+ return A.Offset < B.Offset;
+ });
// Finding overlap is easy given a vector is sorted by start position.
// If an element starts before the end of the previous element, they overlap.
Index: ELF/CallGraphSort.cpp
===================================================================
--- ELF/CallGraphSort.cpp
+++ ELF/CallGraphSort.cpp
@@ -219,10 +219,10 @@
});
// Sort by density.
- std::sort(Clusters.begin(), Clusters.end(),
- [](const Cluster &A, const Cluster &B) {
- return A.getDensity() > B.getDensity();
- });
+ std::stable_sort(Clusters.begin(), Clusters.end(),
+ [](const Cluster &A, const Cluster &B) {
+ return A.getDensity() > B.getDensity();
+ });
}
DenseMap<const InputSectionBase *, int> CallGraphSort::run() {
Index: ELF/SyntheticSections.cpp
===================================================================
--- ELF/SyntheticSections.cpp
+++ ELF/SyntheticSections.cpp
@@ -1393,10 +1393,10 @@
NonRelatives.push_back(R);
}
- std::sort(Relatives.begin(), Relatives.end(),
- [](const Elf_Rel &A, const Elf_Rel &B) {
- return A.r_offset < B.r_offset;
- });
+ llvm::sort(Relatives.begin(), Relatives.end(),
+ [](const Elf_Rel &A, const Elf_Rel &B) {
+ return A.r_offset < B.r_offset;
+ });
// Try to find groups of relative relocations which are spaced one word
// apart from one another. These generally correspond to vtable entries. The
@@ -1474,10 +1474,10 @@
}
// Finally the non-relative relocations.
- std::sort(NonRelatives.begin(), NonRelatives.end(),
- [](const Elf_Rela &A, const Elf_Rela &B) {
- return A.r_offset < B.r_offset;
- });
+ llvm::sort(NonRelatives.begin(), NonRelatives.end(),
+ [](const Elf_Rela &A, const Elf_Rela &B) {
+ return A.r_offset < B.r_offset;
+ });
if (!NonRelatives.empty()) {
Add(NonRelatives.size());
Add(HasAddendIfRela);
Index: ELF/MapFile.cpp
===================================================================
--- ELF/MapFile.cpp
+++ ELF/MapFile.cpp
@@ -90,8 +90,9 @@
// in the input files.
for (auto &It : Ret) {
SmallVectorImpl<Symbol *> &V = It.second;
- std::sort(V.begin(), V.end(),
- [](Symbol *A, Symbol *B) { return A->getVA() < B->getVA(); });
+ std::stable_sort(V.begin(), V.end(), [](Symbol *A, Symbol *B) {
+ return A->getVA() < B->getVA();
+ });
}
return Ret;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45969.143699.patch
Type: text/x-patch
Size: 3526 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180424/10aa1658/attachment.bin>
More information about the llvm-commits
mailing list