[PATCH] D126785: Cache file IDs of symbols in emitStabs for faster sorting
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 1 11:51:54 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf5709066e3b0: [lld/mac] Cache file IDs of symbols in emitStabs for faster sorting (authored by michaeleisel, committed by thakis).
Changed prior to commit:
https://reviews.llvm.org/D126785?vs=433446&id=433482#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126785/new/
https://reviews.llvm.org/D126785
Files:
lld/MachO/SyntheticSections.cpp
Index: lld/MachO/SyntheticSections.cpp
===================================================================
--- lld/MachO/SyntheticSections.cpp
+++ lld/MachO/SyntheticSections.cpp
@@ -890,7 +890,9 @@
stabs.emplace_back(std::move(astStab));
}
- std::vector<Defined *> symbolsNeedingStabs;
+ // Cache the file ID for each symbol in an std::pair for faster sorting.
+ using SortingPair = std::pair<Defined *, int>;
+ std::vector<SortingPair> symbolsNeedingStabs;
for (const SymtabEntry &entry :
concat<SymtabEntry>(localSymbols, externalSymbols)) {
Symbol *sym = entry.sym;
@@ -913,19 +915,20 @@
if (!file || !file->compileUnit)
continue;
- symbolsNeedingStabs.push_back(defined);
+ symbolsNeedingStabs.emplace_back(defined, defined->isec->getFile()->id);
}
}
- llvm::stable_sort(symbolsNeedingStabs, [&](Defined *a, Defined *b) {
- return a->isec->getFile()->id < b->isec->getFile()->id;
+ llvm::stable_sort(symbolsNeedingStabs, [&](const SortingPair &a, const SortingPair &b) {
+ return a.second < b.second;
});
// Emit STABS symbols so that dsymutil and/or the debugger can map address
// regions in the final binary to the source and object files from which they
// originated.
InputFile *lastFile = nullptr;
- for (Defined *defined : symbolsNeedingStabs) {
+ for (SortingPair &pair : symbolsNeedingStabs) {
+ Defined *defined = pair.first;
InputSection *isec = defined->isec;
ObjFile *file = cast<ObjFile>(isec->getFile());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126785.433482.patch
Type: text/x-patch
Size: 1535 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220601/16e969d3/attachment.bin>
More information about the llvm-commits
mailing list