[PATCH] D33564: [CodeView Type Merging] Make a Type Index Iterator that bypasses the visitor framework

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 25 13:43:19 PDT 2017


zturner created this revision.
Herald added a subscriber: mgorny.

The visitor abstraction is useful for plugging lots of somewhat related components together, but with abstraction comes a cost in performance.  Type Merging is easily the slowest part of a link, so it makes sense to consider whether it's worth sacrifcing abstractional purity in exchange for speed here.

This patch swings completely the opposite direction.  It bypasses the `TempSerializer`, it bypasses the `FieldListRecordBuilder`, it bypasses the `TypeRecordMapping`, and it bypasses the visitation switch and instead re-implements the record deserialization switch in a hand rolled algorithm that doesn't care about deserializing at all, but only about knowing what offsets within a record's byte sequence contain type indices.

For field list records in particular, this algorithm also implements the logic of skipping a record to find the next record.  This allows us to completely skip the process of deserializing field list records in order to determine what indices to remap, and then re-serializing them.  Furthermore, computing "how many bytes is this field list member record" is somewhat faster than actually pulling out all the fields of the record.

The algorithm here simply gets as input a sequence of bytes, and returns as output a list of offsets that we need to remap.

Performance wise, this is a huge win.  This is linking lld using clang-cl generated objects and library inputs (so /Z7) before this patch, after this patch, and using MSVC.

MSVC: 25.67s
Before Patch: 18.59s
After Patch: 8.92s


https://reviews.llvm.org/D33564

Files:
  llvm/include/llvm/DebugInfo/CodeView/TypeIndexIterator.h
  llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h
  llvm/lib/DebugInfo/CodeView/CMakeLists.txt
  llvm/lib/DebugInfo/CodeView/TypeIndexIterator.cpp
  llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
  llvm/unittests/DebugInfo/CodeView/CMakeLists.txt
  llvm/unittests/DebugInfo/CodeView/ErrorChecking.h
  llvm/unittests/DebugInfo/CodeView/TypeIndexIteratorTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33564.100289.patch
Type: text/x-patch
Size: 49460 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170525/d7cfdcf1/attachment-0001.bin>


More information about the llvm-commits mailing list