[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 11:53:35 PDT 2017


zturner created this revision.
Herald added a subscriber: mgorny.

Right now we have multiple notions of things that represent collections of types.  Most commonly used are `TypeDatabase`, which is supposed to keep mappings from `TypeIndex` to type name when reading a type stream, which happens when reading PDBs.  And also `TypeTableBuilder`, which is used to build up a collection of types dynamically which we will later serialize (i.e. when writing PDBs).

But often you just want to do some operation on a collection of types, and you may want to do the same operation on any kind of collection.  For example, you might want to merge two `TypeTableBuilders` or you might want to merge two type streams that you loaded from various files.

This dichotomy between reading and writing is responsible for a lot of the existing code duplication and overlapping responsibilities in the existing CodeView library classes.  For example, after building up a `TypeTableBuilder` with a bunch of type records, if we want to dump it we have to re-invent a bunch of extra glue because our dumper takes a `TypeDatabase` or a `CVTypeArray`, which are both incompatible with `TypeTableBuilder`.

This patch introduces an abstract base class called `TypeCollection` which is shared between the various type collection like things.  Wherever we previously stored a `TypeDatabase&` in some common class, we now store a `TypeCollection&`.

The advantage of this is that all the details of how the collection are implemented, such as lazy deserialization of partial type streams, is completely transparent and you can just treat any collection of types the same regardless of where it came from.

This is a large patch, but I cannot come up with a way to make it smaller.  I have https://reviews.llvm.org/D33229 in the queue for review, and https://reviews.llvm.org/D33245 already submitted which themselves were already broken off from this to make it smaller, so I think this may be the best I can do.


https://reviews.llvm.org/D33293

Files:
  lld/COFF/PDB.cpp
  llvm/include/llvm/DebugInfo/CodeView/CVRecord.h
  llvm/include/llvm/DebugInfo/CodeView/CVTypeDumper.h
  llvm/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h
  llvm/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h
  llvm/include/llvm/DebugInfo/CodeView/RandomAccessTypeVisitor.h
  llvm/include/llvm/DebugInfo/CodeView/SymbolDumper.h
  llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h
  llvm/include/llvm/DebugInfo/CodeView/TypeDatabase.h
  llvm/include/llvm/DebugInfo/CodeView/TypeDumpVisitor.h
  llvm/include/llvm/DebugInfo/CodeView/TypeIndex.h
  llvm/include/llvm/DebugInfo/CodeView/TypeTableCollection.h
  llvm/include/llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h
  llvm/include/llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/DebugInfo/CodeView/CMakeLists.txt
  llvm/lib/DebugInfo/CodeView/CVTypeDumper.cpp
  llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
  llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
  llvm/lib/DebugInfo/CodeView/RandomAccessTypeVisitor.cpp
  llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp
  llvm/lib/DebugInfo/CodeView/TypeDatabase.cpp
  llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp
  llvm/lib/DebugInfo/CodeView/TypeIndex.cpp
  llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
  llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
  llvm/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp
  llvm/lib/DebugInfo/PDB/Native/TpiStream.cpp
  llvm/tools/llvm-pdbdump/Analyze.cpp
  llvm/tools/llvm-pdbdump/CompactTypeDumpVisitor.cpp
  llvm/tools/llvm-pdbdump/CompactTypeDumpVisitor.h
  llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
  llvm/tools/llvm-pdbdump/LLVMOutputStyle.h
  llvm/tools/llvm-pdbdump/PdbYaml.cpp
  llvm/tools/llvm-pdbdump/YAMLOutputStyle.h
  llvm/tools/llvm-pdbdump/YamlTypeDumper.cpp
  llvm/tools/llvm-readobj/COFFDumper.cpp
  llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33293.99332.patch
Type: text/x-patch
Size: 94050 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170517/3078f306/attachment-0001.bin>


More information about the llvm-commits mailing list