[PATCH] D57666: [LLD] [COFF] Avoid O(n^2) insertion into PartialSections

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 4 07:12:19 PST 2019


aganea added inline comments.


================
Comment at: COFF/Writer.cpp:237
   std::unique_ptr<FileOutputBuffer> &Buffer;
-  std::set<PartialSection *, PartialLess> PartialSections;
+  std::map<PartialSectionKey, PartialSection *> PartialSections;
   std::vector<OutputSection *> OutputSections;
----------------
aganea wrote:
> On a second thought, and if we wanted to be optimal, I was wondering if we shouldn't be using a `llvm::DenseSet` here instead. `std::map` isn't known to scale particularly well with many elements, and you're at the implementation's mercy. At least the behavior will be more consistent with an internal structure.
> 
> I did use a `DenseMap` initially, but that requires more plumbing, because you need to retain the insertion order ( for later, when emitting data into the PDB). I did not see the advantage at the time, given that MSVC does not generate that many sections, but in your case, it matters. What do you think?
Correction: it is NOT the insertion order that matters; it is the map that needs to be enumerated in a **sorted** order on PDB emission.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57666/new/

https://reviews.llvm.org/D57666





More information about the llvm-commits mailing list