Page MenuHomePhabricator

[SampleFDO] Fix invalid branch profile generated by indirect call promotion
ClosedPublic

Authored by wmi on Jan 15 2020, 10:25 AM.

Details

Summary

Suppose an inline instance has hot total sample count but 0 entry count, and it is an indirect call target. If the indirect call has no other call target and inline instance associated with it and it is promoted, currently the conditional branch generated by indirect call promotion will have invalid branch profile which is !{!"branch_weights", i32 0, i32 0} -- because the entry count of the promoted target is 0 and the total entry count of all targets is also 0. This caused a SEGV in Control Height Reduction and may cause problem in other passes.

Function entry count of an inline instance is computed by a heuristic -- using either the sample of the starting line or starting inner inline instance. The patch changes the heuristic a little bit so that when total sample count is larger than 0, the computed entry count will be at least 1. Then the new branch profile will be !{!"branch_weights", i32 1, i32 0}.

Diff Detail

Event Timeline

wmi created this revision.Jan 15 2020, 10:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 15 2020, 10:25 AM
This revision is now accepted and ready to land.Jan 15 2020, 10:39 AM
yamauchi accepted this revision.Jan 15 2020, 11:01 AM
This revision was automatically updated to reflect the committed changes.