This is an archive of the discontinued LLVM Phabricator instance.

Add TypeDatabase
ClosedPublic

Authored by zturner on Jan 9 2017, 2:42 PM.

Details

Summary

Previously we had logic in CVTypeDumper that would try to build up a list of types that had been encountered while dumping a type stream. All of this logic was embedded in the CVTypeDumper class, so it was hard to re-use anywhere else. In practice, the idea of visiting a list of types and then using the resulting information for something will be useful for more than just dumping types. My immediate need for this is to have a separate "compact" dump output format, where all we dump is a type's name, leaf kind, and type index, all on a single line. This doesn't really belong in CVTypeDumper since it has so much additional logic to dump nested fields etc, so I wanted to make a separate compact dumper. But in order to do this, I would need to re-implement all of this name logic. So this patch:

  1. Creates the notion of a TypeDatabase, which stores type indices and type record data
  2. Creates a TypeDatabaseVisitor which builds up a TypeDatabase while iterating over a type stream.
  3. Updates CVTypeDumper to use TypeDatabaseVisitor, by simply sticking a TypeDatabaseVisitor into the callback pipeline and having CVTypeDumper read the same instance of TypeDatabase that TypeDatabaseVisitor writes to.

In the future, we can make TypeDatabase more complicated, such as storing hash values, allowing lookup by various types, and searching, and this can be the general purpose type database used for all type based operations (for example in implementing the DIA SDK in terms of native APIs)

Diff Detail

Repository
rL LLVM

Event Timeline

zturner updated this revision to Diff 83705.Jan 9 2017, 2:42 PM
zturner retitled this revision from to Add TypeDatabase.
zturner updated this object.
zturner added reviewers: inglorion, rnk, amccarth.
zturner added a subscriber: llvm-commits.
amccarth edited edge metadata.Jan 9 2017, 4:59 PM

This looks pretty good to me.

llvm/lib/DebugInfo/CodeView/TypeDatabase.cpp
25 ↗(On Diff #83705)

Should these use the same .def file trick used in so many other places with large tables like this?

70 ↗(On Diff #83705)

Maybe use TypeIndex::FirstNonSimpleIndex for these.

I know the value isn't likely to change, but it could be a good breadcrumb for the uninitiated to discover why this 0x1000 base value exists.

zturner marked an inline comment as done.Jan 10 2017, 9:30 AM
zturner added inline comments.
llvm/lib/DebugInfo/CodeView/TypeDatabase.cpp
25 ↗(On Diff #83705)

I think this is the only place we actually do it, but if we ever end up with more than one, the .def file trick might be useful.

This revision was automatically updated to reflect the committed changes.