[PATCH] D39446: [PGO] Detect more structural changes with the stable hash

Vedant Kumar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 30 19:48:33 PDT 2017


vsk created this revision.

Lifting from Bob Wilson's notes: The hash value that we compute and store in
PGO profile data to detect out-of-date profiles does not include enough
information. This means that many significant changes to the source will not
cause compiler warnings about the profile being out of date, and worse, we may
continue to use the outdated profile data to make bad optimization decisions.
There is some tension here because some source changes won't affect PGO and we
don't want to invalidate the profile unnecessary.

This patch adds a new version of the PGO hash which is sensitive to 'goto',
'break', 'continue', and 'return'. It also draws a distinction between 'if'
statements with/without an 'else' block.

I chose these types of statements because their presence or absence
significantly alter control flow (to the point where any existing
profile data for the function becomes suspect). I picked these types of
statements after scanning through the subclasses of Expr and Stmt --
these seemed like the most important ones to handle. If there's
something missing, it will be easy to update the hash version again.

Profiles which use the old version of the PGO hash remain valid and can
be used without issue (there are already tests in tree for this).

rdar://17068282


https://reviews.llvm.org/D39446

Files:
  lib/CodeGen/CodeGenPGO.cpp
  test/Profile/Inputs/c-counter-overflows.proftext
  test/Profile/Inputs/c-general.proftext
  test/Profile/Inputs/cxx-throws.proftext

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39446.120927.patch
Type: text/x-patch
Size: 6266 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171031/5f1031e2/attachment-0001.bin>


More information about the cfe-commits mailing list