This is an archive of the discontinued LLVM Phabricator instance.

[PGO] Fix handling of cold entry count for instrumented PGO
ClosedPublic

Authored by tejohnson on Dec 15 2017, 1:09 PM.

Details

Summary

In r277849, getEntryCount was changed to return None when the entry
count was 0, specifically for SamplePGO where it means no samples were
recorded. However, for instrumentation PGO a 0 entry count should be
returned directly, since it does mean that the function was completely
cold. Otherwise we end up treating these functions conservatively
in isFunctionEntryCold() and isColdBB().

Instead, for SamplePGO use -1 when there are no samples, and change
getEntryCount to return None when the value is -1.

Diff Detail

Repository
rL LLVM

Event Timeline

tejohnson created this revision.Dec 15 2017, 1:09 PM
davidxl added inline comments.Dec 15 2017, 1:16 PM
lib/Transforms/IPO/SampleProfile.cpp
1586 ↗(On Diff #127184)

Add a comment here and reference the treatment of -1 in getEntryCount()

tejohnson marked an inline comment as done.Dec 15 2017, 1:46 PM
tejohnson updated this revision to Diff 127191.Dec 15 2017, 1:46 PM

Address comment

davidxl accepted this revision.Dec 15 2017, 3:19 PM

lgtm

This revision is now accepted and ready to land.Dec 15 2017, 3:19 PM
danielcdh accepted this revision.Dec 15 2017, 9:33 PM

LGTM, I'm curious what is the code size impact on PGO binaries (I'd expect it to reduce code size significantly)

This revision was automatically updated to reflect the committed changes.