This is an archive of the discontinued LLVM Phabricator instance.

Use call target count to derive the call instruction weight
ClosedPublic

Authored by danielcdh on Sep 9 2016, 10:44 AM.

Details

Summary

The call target count profile is directly derived from LBR branch->target data. This is more reliable than instruction frequency profiles that could be moved across basic block boundaries. This patches uses call target count profile to annotate call instructions.

Diff Detail

Event Timeline

danielcdh updated this revision to Diff 70862.Sep 9 2016, 10:44 AM
danielcdh retitled this revision from to Use call target count to derive the call instruction weight.
danielcdh updated this object.
danielcdh added reviewers: dnovillo, davidxl.
danielcdh added a subscriber: llvm-commits.
dnovillo edited edge metadata.Sep 18 2016, 1:45 PM

OK, so instead of looking at the number of samples collected at the call site, it looks at the number of calls the target had. But what if the target is called disproportionately more from one call site than the other?

Like:

if (this_is_true_95_percent_of_the_time())

A();

else

A();

The example is ridiculous, I know, but wouldn't we end up inlining A() in both branches of the if()? Is that a code growth issue in general?

OK, so instead of looking at the number of samples collected at the call site, it looks at the number of calls the target had. But what if the target is called disproportionately more from one call site than the other?

Like:

if (this_is_true_95_percent_of_the_time())

A();

else

A();

The example is ridiculous, I know, but wouldn't we end up inlining A() in both branches of the if()? Is that a code growth issue in general?

No because we use lineno+discriminator to distinguish a callsite, so we can precisely locate both callsites to A and only inline the hot one.

dnovillo accepted this revision.Sep 19 2016, 9:01 AM
dnovillo edited edge metadata.
This revision is now accepted and ready to land.Sep 19 2016, 9:01 AM
danielcdh updated this revision to Diff 71840.Sep 19 2016, 9:15 AM
danielcdh edited edge metadata.

format

danielcdh closed this revision.Sep 19 2016, 9:15 AM