[PATCH] D32631: Speed up the -Map option.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 27 21:14:31 PDT 2017


pcc added a comment.

Another idea I had for eliminating the O(m * n) behaviour was to collect a list of symbols (externals from the global symbol table and internals from the input files), sort it by VA, and print it in order, emitting input and output section lines whenever either of them changes. That would still be O(n * log n) like your solution, but I think it would have a few other benefits (e.g. it would make it easier to print absolute and synthetic symbols). We can think about doing that separately, though.



================
Comment at: lld/ELF/MapFile.cpp:50
+  // Maps sections to their symbols.
+  DenseMap<const SectionBase *, std::vector<SymbolBody *>> Symbols;
+
----------------
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 *`.


================
Comment at: lld/ELF/MapFile.cpp:92
+  std::vector<DefinedRegular *> Ret;
+  for (elf::ObjectFile<ELFT> *File : Files)
+    for (SymbolBody *B : File->getSymbols())
----------------
I think you can enumerate `Symtab<ELFT>::X->getObjectFiles()` instead here.


================
Comment at: lld/ELF/MapFile.cpp:116
+formatSymbols(ArrayRef<OutputSection *> V) {
+  std::vector<DefinedRegular *> Syms = getSymbols<ELFT>(V);
+
----------------
Can you avoid calling this function twice?


https://reviews.llvm.org/D32631





More information about the llvm-commits mailing list