[PATCH] D31629: [codeview] Cope with unsorted streams in type merging

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 3 16:28:52 PDT 2017


rnk added a comment.

In https://reviews.llvm.org/D31629#717372, @ruiu wrote:

> Do you need multiple scans? I wonder if you can keep type records that were not resolved in the first pass in a map or something and backfill them once we visit all type records.


You can avoid the traversal if you copy the unresolved records to temporary storage and topologically sort them. You can't backpatch the type records because inserting them into the destination stream requires hashing them, and the hash includes the type index references we'd need to backpatch.

In general, if the type stream is badly unsorted, this algorithm is `O(n^2)`. Topo sort is `O(n)`, but it requires extra storage. It seemed better to optimize for the common case of a large, sorted type stream, and hope that unsorted streams are rare and/or small.


https://reviews.llvm.org/D31629





More information about the llvm-commits mailing list