[PATCH] D57790: [CodeView] Fix cycles in debug info when merging Types with global hashes

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 5 14:33:06 PST 2019


aganea created this revision.
aganea added reviewers: rnk, zturner, thakis.
Herald added subscribers: kristina, rupprecht, aprantl.
Herald added a project: LLVM.

When type streams with forward references were merged using GHashes, cycles were introduced in the debug info. This was caused by `GlobalTypeTableBuilder::insertRecordAs()` not inserting the record on the second pass, thus yielding an empty `ArrayRef` at that record slot. Later on, upon PDB emission, `TpiStreamBuilder::commit()` would skip that empty record, thus offseting all indices that came after in the stream.

The solution comes in two steps:

1. Fix the hash calculation, by doing a two step resolution, iff there are forward references in the input stream.
2. Fix merge by resolving records with forward references on the second pass, therefore moving them at the end of the stream.

I had to make some esthetic changes to support GHashes in `llvm-readoj`, I could commit that separately. I'm not too happy about the `LazyRandomTypeCollection::records()` change, because it adds an extra array. But that's required to support `dumpCodeViewMergedTypes()` called from `llvm-readobj`. If you have better ideas, feel free.

Fixes PR40221


Repository:
  rL LLVM

https://reviews.llvm.org/D57790

Files:
  include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
  include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
  include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h
  include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h
  include/llvm/DebugInfo/CodeView/TypeCollection.h
  include/llvm/DebugInfo/CodeView/TypeHashing.h
  include/llvm/DebugInfo/CodeView/TypeTableCollection.h
  include/llvm/Support/BinaryStreamArray.h
  lib/DebugInfo/CodeView/GlobalTypeTableBuilder.cpp
  lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
  lib/DebugInfo/CodeView/TypeHashing.cpp
  lib/DebugInfo/CodeView/TypeStreamMerger.cpp
  lib/DebugInfo/CodeView/TypeTableCollection.cpp
  lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
  test/tools/llvm-readobj/codeview-merging-ghash.test
  tools/llvm-readobj/COFFDumper.cpp
  tools/llvm-readobj/ObjDumper.h
  tools/llvm-readobj/llvm-readobj.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57790.185405.patch
Type: text/x-patch
Size: 22277 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190205/b88b33a6/attachment.bin>


More information about the llvm-commits mailing list