[PATCH] D22512: Added hash_stream class for producing hash codes from data streams.

Raphael Isemann via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 17 16:59:34 PDT 2016


teemperor added a comment.

The immediate motivation is that in https://reviews.llvm.org/D22515 we need to generate a hash code for data that isn't in a container but implicitly stored in the properties of some AST nodes. This hash code needs to be generated for every single node in the AST so we try to avoid calling any heavy code during that. But to generate a hash code with the current API we first need to forward our data stream that we get from the visitor to a container like FoldingSetNodeID (which could even allocate memory) and then forward that container to the hashing function which handles it again like a stream of data.

hash_stream would allow us to generate hash_codes without having this unnecessary buffer between the two streams. As we allow the user of the API to fill this buffer with whatever data he is interested in, it could be that this buffer restricts the performance in some cases where the user adds a lot of data.

The other option would be to use `hash_combine(OldHashCode, NewData)` on every new data which is like the makeshift version of this patch because we repeatedly have to finalize on every new chunk of data.


https://reviews.llvm.org/D22512





More information about the llvm-commits mailing list