[llvm] r187213 - Add preliminary support for hashing DIEs and breaking them into
Robinson, Paul
Paul_Robinson at playstation.sony.com
Fri Jul 26 14:30:02 PDT 2013
> >> +
> >> + // ... take the least significant 8 bytes and store those as the
> attribute.
> >> + uint64_t Signature;
> >> + memcpy(&Signature, &Result[8], 8);
> >
> > Any discussion on this with the DWARF committee? I assume computing a
> > big hash & then just taking some of the bytes isn't really the best
> > way to use a hashing algorithm.
>
> I got them to admit that they want the least significant 8 bytes
> rather than "the lower 8 bytes". But the field is fixed now at this
> point, it's pretty proof against collisions etc. That said, it bothers
> me a bit as well.
Blame Cary. :-) MD5 produces a 16-byte hash but he only wanted 8 bytes
for the key. I suppose we could have argued for a different hash
that produced the output size he wanted, but that's water under the
bridge now. Assuming that MD5 does a reasonable job of spreading the
entropy across all bits of output, taking the low 8 bytes is equivalent
to producing an 8-byte hash in the first place.
And, just to be completely geeky about it, if we look at
http://en.wikipedia.org/wiki/Birthday_problem under "Square approximation"
it's not too hard to figure out that with a 64-bit hash, with a million
(2^20) hashes there's about a 1-in-a-million (2^(-22)) chance of a
collision.
So from a purist perspective it's weird, but in practice we're good.
--paulr
More information about the llvm-commits
mailing list