[PATCH] D33293: Provide a common interface for all collections of types.

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 17 13:20:52 PDT 2017


zturner added a comment.

In https://reviews.llvm.org/D33293#757740, @rnk wrote:

> Do you think all these TypeCollections should eventually just be the same thing? So, I could read a TypeCollection from a PDB, and then add more type records to it like I would with TypeTableBuilder. Then we would have a full read/write/edit API for types, which is something we seem to want for incremental PDB writing.


Maybe, it's something that I've been thinking about, but it's not entirely obvious how it would work.  The reading side is optimized around memory usage, meaning that since we already have the entire PDB file mapped into memory, we don't really want to allocate hundreds of megabytes more memory just to copy the data from some type records.  On the other hand, When you're writing you have no choice but to allocate records individually on the fly as you determine what kind of records you're going to need.

It's not entirely obvious how to merge these into one class that doesn't sacrifice memory efficiency on the reading side, but still allows each record to be allocated from private storage



================
Comment at: llvm/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h:48
+/// of O(N/M) and an amortized time of O(1).
+class LazyRandomTypeCollection : public TypeCollection {
+  typedef FixedStreamArray<TypeIndexOffset> PartialOffsetArray;
----------------
rnk wrote:
> I feel like LazyRandom is really implementation-detail oriented. Basically, this is a TypeCollection that's efficient for PDBs. "Random" also suggests that it generates random results, which would be weird.
> 
> Maybe call it PDBTypeCollection? Or TypeStreamCollection? It seems awkward to have a class starting with PDB in DebugInfo/CodeView.
I don't think it's only efficient for PDBs.  It's just **most** efficient for PDBs.  It's still very useful when all you have is a `.degug$T` section from an object file.  Even though you don't have any partial offsets, random access is still a very useful feature.

Heck, we could even put a TypeIndexOffset array into the object file in a magic section, and get all the benefits of lazy deserialization even without a PDB at all.


https://reviews.llvm.org/D33293





More information about the llvm-commits mailing list