This is an archive of the discontinued LLVM Phabricator instance.

[Profile] Fix bad interaction of profile counter reset and value profile eviction
ClosedPublic

Authored by davidxl on Nov 29 2016, 1:30 PM.

Details

Summary

The problem is that value profile evict-or assumes value profile counts are non zero. The assumption is wrong once the counters are cleared (for value profile data, the counts are reset, but the target entries are still kept). When counter resetting and eviction is combined, the zero count entries will end up with large profile count due to wrapping. When all entries are wrapped, adding new target will also lead to seg fault.

Diff Detail

Repository
rL LLVM

Event Timeline

davidxl updated this revision to Diff 79628.Nov 29 2016, 1:30 PM
davidxl retitled this revision from to [Profile] Fix bad interaction of profile counter reset and value profile eviction.
davidxl updated this object.
davidxl added reviewers: vsk, xur.
davidxl added a subscriber: llvm-commits.
vsk edited edge metadata.Nov 29 2016, 1:40 PM

This makes sense. Would you be opposed to combining the C file and the test file? I think it'd improve readability to have the run lines and the check lines in the same place.

test/profile/Inputs/instrprof-value-prof-reset.c
26 ↗(On Diff #79628)

Since max-vals-per-site = 2, I think we'd also want CHECK-NOT: callee_0?

26 ↗(On Diff #79628)

nit, could you fix the capitalization here?

davidxl updated this revision to Diff 79634.Nov 29 2016, 1:45 PM
davidxl edited edge metadata.

Updated the test case according to Vedant's feedback.

vsk accepted this revision.Nov 29 2016, 1:51 PM
vsk edited edge metadata.

LGTM.

I don't see any issue with having the whole test live in test/profile/*.c, and would prefer that, but it's no big deal.

This revision is now accepted and ready to land.Nov 29 2016, 1:51 PM
xur accepted this revision.Nov 29 2016, 2:08 PM
xur edited edge metadata.

lgtm.

This revision was automatically updated to reflect the committed changes.