[PATCH] D34297: [CodeView] Fix random access of types names

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 16 15:00:11 PDT 2017


zturner created this revision.
Herald added subscribers: hiraditya, mgorny.

Suppose we had a type index offsets array with a boundary at type index `N`.  Then you request the name of the type with index `N+1`, and that name requires the name of index `N-1` (think a parameter list, for example).  We didn't handle this, and we would print something like `(<unknown UDT>, <unknown UDT>)`.

The fix for this is not entirely trivial, and speaks to a larger problem.  I think we need to kill `TypeDatabase`, or at the very least kill `TypeDatabaseVisitor`.  We need a thing that doesn't do any caching whatsoever, just given a type index it can compute the type name "the slow way".  The reason for the bug is that we don't have anything like that.  Everything goes through the type database, and if we've visited a record, then we're "done".  It doesn't know how to do the expensive thing of re-visiting dependent records if they've not yet been visited.

What I've done here is more or less copied the code (albeit greatly simplified) from `TypeDatabaseVisitor`, but wrapped it in an interface that just returns a `std::string`.  The logic of caching the name is now in `LazyRandomTypeCollection`.  Eventually I'd like to move the record database here as well and the visited record bitfield here as well, at which point we can actually just delete `TypeDatabase`.  I don't see any reason for it if a "sequential" collection is just a special case of a random access collection with an empty partial offsets array.


https://reviews.llvm.org/D34297

Files:
  llvm/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h
  llvm/include/llvm/DebugInfo/CodeView/TypeName.h
  llvm/lib/DebugInfo/CodeView/CMakeLists.txt
  llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
  llvm/lib/DebugInfo/CodeView/TypeName.cpp
  llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34297.102883.patch
Type: text/x-patch
Size: 14558 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170616/bda323fe/attachment-0001.bin>


More information about the llvm-commits mailing list