This is an archive of the discontinued LLVM Phabricator instance.

[CodeView] Fix random access of types names
ClosedPublic

Authored by zturner on Jun 16 2017, 3:00 PM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

zturner created this revision.Jun 16 2017, 3:00 PM
rnk accepted this revision.Jun 16 2017, 3:41 PM

lgtm

I'm not really that concerned with the efficiency of calculating type names. We don't recurse through aggregate types, so the biggest most complex type we could have is probably a function type.

This revision is now accepted and ready to land.Jun 16 2017, 3:41 PM
This revision was automatically updated to reflect the committed changes.