This is an archive of the discontinued LLVM Phabricator instance.

[SampleFDO] Extend profile-sample-accurate option to cover isFunctionColdInCallGraph
ClosedPublic

Authored by wmi on Dec 11 2018, 11:58 AM.

Details

Summary

For SampleFDO, when a callsite doesn't appear in the profile, it will not be marked as cold callsite unless the option -profile-sample-accurate is specified.

But profile-sample-accurate doesn't cover function isFunctionColdInCallGraph which is used to decide whether a function should be put into text.unlikely section, so even if the user knows the profile is accurate and specifies profile-sample-accurate, those functions not appearing in the sample profile are still not be put into text.unlikely section right now.

The patch fixes that.

Diff Detail

Repository
rL LLVM

Event Timeline

wmi created this revision.Dec 11 2018, 11:58 AM
tejohnson added inline comments.Dec 12 2018, 6:44 AM
lib/Analysis/ProfileSummaryInfo.cpp
268 ↗(On Diff #177751)

Don't need to do extra checking unless !Count, so you could simplify like:

if (Count)

return isColdCount(*Count);

if (!hasSampleProfile())

return false;

const Function *F = BB->getParent();
return ProfileSampleAccurate ||

(F && F->hasFnAttribute("profile-sample-accurate"));
wmi marked an inline comment as done.Dec 12 2018, 8:50 AM
wmi added inline comments.
lib/Analysis/ProfileSummaryInfo.cpp
268 ↗(On Diff #177751)

Thanks, that is better, Fixed.

wmi updated this revision to Diff 177860.Dec 12 2018, 8:50 AM

Address Teresa's comment.

This revision is now accepted and ready to land.Dec 12 2018, 8:54 AM
This revision was automatically updated to reflect the committed changes.
wmi added a comment.Dec 13 2018, 9:22 AM

Thanks to Easwaran who gave me a good suggestion offline to improve the patch. We can initialize function entry count to 0 when ProfileSampleAccurate is specified. That could save the effort to handle ProfileSampleAccurate in multiple places. I will post the updated patch in a separate review thread.