[PATCH] InstrProf: Calculate a better function hash

Chandler Carruth chandlerc at google.com
Mon Mar 24 14:10:31 PDT 2014


+void MapRegionCounters::combineHash(ASTHash Val) {
+  // Use Bernstein's hash.
+  Hash = Hash * 33 + Val;
+}

So, you care a lot about collisions, but you use Bernstein's hash? I don't
get it. This will collide like crazy. Note that Bernstein's hashing
algorithm is only ever a "good" distribution for hashing ascii-ish text,
and you're hashing dense things.

If you care about collisions, I would use the high 64 bits of an md5 (or
better yet, all 128 bits). Or some other well researched and understood
algorithm.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140324/7d47ae7a/attachment.html>


More information about the cfe-commits mailing list