[PATCH] D45519: [ELF] - Change the way of sorting local symbols.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 26 01:55:24 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLD335583: [ELF] - Change the way of sorting local symbols. (authored by grimar, committed by ).
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D45519
Files:
ELF/SyntheticSections.cpp
Index: ELF/SyntheticSections.cpp
===================================================================
--- ELF/SyntheticSections.cpp
+++ ELF/SyntheticSections.cpp
@@ -1762,19 +1762,19 @@
size_t NumLocals = E - Symbols.begin();
getParent()->Info = NumLocals + 1;
- // Assign the growing unique ID for each local symbol's file.
- DenseMap<InputFile *, unsigned> FileIDs;
- for (auto I = Symbols.begin(); I != E; ++I)
- FileIDs.insert({I->Sym->File, FileIDs.size()});
-
- // Sort the local symbols to group them by file. We do not need to care about
- // the STT_FILE symbols, they are already naturally placed first in each group.
- // That happens because STT_FILE is always the first symbol in the object and
- // hence precede all other local symbols we add for a file.
- std::stable_sort(Symbols.begin(), E,
- [&](const SymbolTableEntry &L, const SymbolTableEntry &R) {
- return FileIDs[L.Sym->File] < FileIDs[R.Sym->File];
- });
+ // We want to group the local symbols by file. For that we rebuild the local
+ // part of the symbols vector. We do not need to care about the STT_FILE
+ // symbols, they are already naturally placed first in each group. That
+ // happens because STT_FILE is always the first symbol in the object and hence
+ // precede all other local symbols we add for a file.
+ MapVector<InputFile *, std::vector<SymbolTableEntry>> Arr;
+ for (const SymbolTableEntry &S : llvm::make_range(Symbols.begin(), E))
+ Arr[S.Sym->File].push_back(S);
+
+ auto I = Symbols.begin();
+ for (std::pair<InputFile *, std::vector<SymbolTableEntry>> &P : Arr)
+ for (SymbolTableEntry &Entry : P.second)
+ *I++ = Entry;
}
void SymbolTableBaseSection::addSymbol(Symbol *B) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45519.152853.patch
Type: text/x-patch
Size: 1775 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180626/7f9c9afc/attachment.bin>
More information about the llvm-commits
mailing list