Skip to content

Commit 91a7085

Browse files
[lld] Use llvm::stable_sort (NFC) (#140488)
1 parent 3252816 commit 91a7085

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

lld/COFF/LLDMapFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static SymbolMapTy getSectionSyms(ArrayRef<DefinedRegular *> syms) {
6565
// Sort symbols by address.
6666
for (auto &it : ret) {
6767
SmallVectorImpl<DefinedRegular *> &v = it.second;
68-
std::stable_sort(v.begin(), v.end(), [](DefinedRegular *a, DefinedRegular *b) {
68+
llvm::stable_sort(v, [](DefinedRegular *a, DefinedRegular *b) {
6969
return a->getRVA() < b->getRVA();
7070
});
7171
}

lld/ELF/SyntheticSections.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4677,10 +4677,9 @@ createMemtagGlobalDescriptors(Ctx &ctx,
46774677

46784678
bool MemtagGlobalDescriptors::updateAllocSize(Ctx &ctx) {
46794679
size_t oldSize = getSize();
4680-
std::stable_sort(symbols.begin(), symbols.end(),
4681-
[&ctx = ctx](const Symbol *s1, const Symbol *s2) {
4682-
return s1->getVA(ctx) < s2->getVA(ctx);
4683-
});
4680+
llvm::stable_sort(symbols, [&ctx = ctx](const Symbol *s1, const Symbol *s2) {
4681+
return s1->getVA(ctx) < s2->getVA(ctx);
4682+
});
46844683
return oldSize != getSize();
46854684
}
46864685

lld/wasm/Writer.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,18 +1050,18 @@ void Writer::createOutputSegments() {
10501050
}
10511051

10521052
// Sort segments by type, placing .bss last
1053-
std::stable_sort(segments.begin(), segments.end(),
1054-
[](const OutputSegment *a, const OutputSegment *b) {
1055-
auto order = [](StringRef name) {
1056-
return StringSwitch<int>(name)
1057-
.StartsWith(".tdata", 0)
1058-
.StartsWith(".rodata", 1)
1059-
.StartsWith(".data", 2)
1060-
.StartsWith(".bss", 4)
1061-
.Default(3);
1062-
};
1063-
return order(a->name) < order(b->name);
1064-
});
1053+
llvm::stable_sort(segments,
1054+
[](const OutputSegment *a, const OutputSegment *b) {
1055+
auto order = [](StringRef name) {
1056+
return StringSwitch<int>(name)
1057+
.StartsWith(".tdata", 0)
1058+
.StartsWith(".rodata", 1)
1059+
.StartsWith(".data", 2)
1060+
.StartsWith(".bss", 4)
1061+
.Default(3);
1062+
};
1063+
return order(a->name) < order(b->name);
1064+
});
10651065

10661066
for (size_t i = 0; i < segments.size(); ++i)
10671067
segments[i]->index = i;

0 commit comments

Comments
 (0)