This is an archive of the discontinued LLVM Phabricator instance.

[CodeView] Truncate Long Type Names With A Hash
ClosedPublic

Authored by bwyma on Mar 3 2021, 12:20 PM.

Details

Summary

When type names are too long to fit into a type record, the names need to be
truncated. The existing algorithm shrinks the name and unique name by
a proportionate amount until they fit into a type record. If the unique name
is significantly shorter then it can be reduced to a zero length string
resulting in the following crash:

  
Failure value returned from cantFail wrapped call
Stream Error: The stream is too short to perform the requested operation.
UNREACHABLE executed at llvm/include/llvm/Support/Error.h:718!
PLEASE submit a bug report to https://bugs.llvm.org/ ...

Instead, reduce the size of the type record by:

  1. Replacing the entire linkage name with an MD5 hash.
  2. Truncate the source name and append an MD5 hash.

This matches the behavior of Visual Studio 2017.

Diff Detail

Event Timeline

bwyma created this revision.Mar 3 2021, 12:20 PM
bwyma requested review of this revision.Mar 3 2021, 12:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2021, 12:20 PM
rnk accepted this revision.Mar 3 2021, 12:28 PM

lgtm

llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp
186–187

Are these locals necessary? We should be able to map NameB and UniqueB directly.

This revision is now accepted and ready to land.Mar 3 2021, 12:28 PM
bwyma added a comment.Mar 4 2021, 7:55 AM

x64 windows > LLVM.Instrumentation/InstrProfiling::profiling.ll
I couldn't find a correlation between my patch and this unit test failure. This maybe related to this commit:
https://github.com/llvm/llvm-project/commit/30ad7b5dadcd90ce8df240f1fa74ee2e98a875dc

bwyma updated this revision to Diff 328185.Mar 4 2021, 8:29 AM

Fix the constant name flagged by tidy.

bwyma added inline comments.Mar 5 2021, 5:41 AM
llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp
186–187

The mapStringZ() calls perform both reading and writing, requiring a StringRef& (string-ref-reference). Its ugly and I welcome any suggestions to improve it.

rnk added inline comments.Mar 8 2021, 1:44 PM
llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp
186–187

I see. I think it's fine as is.

This revision was automatically updated to reflect the committed changes.