[PATCH] D32631: Speed up the -Map option.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 28 08:03:19 PDT 2017
ruiu added a comment.
Yes, I think we do not have a multimap in LLVM. I could use std::unordered_multimap, but that's probably slower than DenseMap<T, std::vector<U>>.
================
Comment at: lld/ELF/MapFile.cpp:50
+ // Maps sections to their symbols.
+ DenseMap<const SectionBase *, std::vector<SymbolBody *>> Symbols;
+
----------------
ruiu wrote:
> dberris wrote:
> > pcc wrote:
> > > ruiu wrote:
> > > > dberris wrote:
> > > > > No `SmallVector<...>` ?
> > > > Does it make any noticeable difference? I usually use data structures in the standard library unless that is not appropriate because most people are more familiar with std::* than llvm:*.
> > > I think the key type of this map could be `const InputSection *`.
> > I suspect it should, especially if you size the SmallVector with enough values to not require an additional indirection when reaching for the values. It should be easy to measure, given that you already have a test case. :)
> OK, let me do that tomorrow.
It actually cannot.
================
Comment at: lld/ELF/MapFile.cpp:50
+ // Maps sections to their symbols.
+ DenseMap<const SectionBase *, std::vector<SymbolBody *>> Symbols;
+
----------------
ruiu wrote:
> ruiu wrote:
> > dberris wrote:
> > > pcc wrote:
> > > > ruiu wrote:
> > > > > dberris wrote:
> > > > > > No `SmallVector<...>` ?
> > > > > Does it make any noticeable difference? I usually use data structures in the standard library unless that is not appropriate because most people are more familiar with std::* than llvm:*.
> > > > I think the key type of this map could be `const InputSection *`.
> > > I suspect it should, especially if you size the SmallVector with enough values to not require an additional indirection when reaching for the values. It should be easy to measure, given that you already have a test case. :)
> > OK, let me do that tomorrow.
> It actually cannot.
Changing the type from std::vector to SmallVector sped it up by a few hundred milliseconds for the clang test case, so that actually mattered.
================
Comment at: lld/ELF/MapFile.cpp:116
+formatSymbols(ArrayRef<OutputSection *> V) {
+ std::vector<DefinedRegular *> Syms = getSymbols<ELFT>(V);
+
----------------
pcc wrote:
> Can you avoid calling this function twice?
Done.
https://reviews.llvm.org/D32631
More information about the llvm-commits
mailing list