[PATCH] D71437: [PDB] Print the most redundant type record indices with /summary

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 2 17:19:21 PST 2020


MaskRay added inline comments.


================
Comment at: lld/COFF/PDB.cpp:431
+    // collecting statistics.
+    tpiCounts.resize(tMerger.getTypeTable().size());
+    ipiCounts.resize(tMerger.getIDTable().size());
----------------
rnk wrote:
> MaskRay wrote:
> > rnk wrote:
> > > MaskRay wrote:
> > > > Can `tpiCounts` be a non-empty vector before `resize()`?
> > > > 
> > > > If yes, `assign(tMerger.getTypeTable().size(), 0);`
> > > Yes, it can be non-empty, but why is assign better? `resize()` does zero initialization, it is not reserve.
> > If it was non-empty, existing non-zero values would not be zeroed.
> > 
> > ```
> > If the current size is less than count,
> > 
> > 1) additional default-inserted elements are appended
> > ```
> > If it was non-empty, existing non-zero values would not be zeroed.
> 
> That is the intended behavior. I can't think of another good way to express this: grow the array, fill it with zeros, do it in a way that will trigger quadratic growth. Maybe a longer .insert call? `.insert(tpiCounts.end(), size, 0)`?
> 
> Well, I will commit it this way for now.
Sorry I thought you wanted to zero the whole array. resize is the best to insert zeros while keeping existing values unchanged.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71437





More information about the llvm-commits mailing list