[PATCH] InstrProf: Calculate a better function hash

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Mar 24 12:34:31 PDT 2014


The function hash in an instrumented profile should change if and only
if control flow changes.  This patch hashes the type of each AST node
that affects counters, rather than just counting how many there are.

This scheme is not perfect.  Ideally, if the condition in an if
statement has a semantic change, the hash should change too.  However,
if a user changes variable names, the hash should not change.  Hashing
just the type of control flow is a reasonable compromise.

Since we need a stable hash (even if Stmt::StmtClass gets reshuffled),
create a local enumerator that we can keep stable.

Using hash values with the most significant bit set exposed a bug where
the current text reader in clang used strtol and strtoll to read
unsigned values.  Changed to strtoul and strtoull.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgo-hash.patch
Type: application/octet-stream
Size: 28477 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140324/b921e516/attachment.obj>


More information about the cfe-commits mailing list