This is an archive of the discontinued LLVM Phabricator instance.

[BPI] Incorrect probability reported in case of mulptiple edges.
ClosedPublic

Authored by ebrevnov on Apr 29 2020, 12:59 AM.

Details

Summary

By design 'BranchProbabilityInfo:: getEdgeProbability(const BasicBlock *Src, const BasicBlock *Dst) const' should return sum of probabilities over all edges from Src to Dst. Current implementation is buggy and returns 1/num_of_successors if probabilities are not explicitly set.

Note current implementation of BPI printing has an issue as well and annotates each edge with sum of probabilities over all ages from one basic block to another. That's why 30% probability reported (instead of 10%) in the lit test. This is not urgent issue since only printing is affected.
Note also current implementation assumes that either all or none edges have probabilities set. This is not the only place which uses such assumption. At least we should assert that in verifier. In addition we can think on a more robust API of BPI which would prevent situations.

Diff Detail

Event Timeline

ebrevnov created this revision.Apr 29 2020, 12:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 29 2020, 12:59 AM
ebrevnov edited the summary of this revision. (Show Details)Apr 29 2020, 1:12 AM
ebrevnov added reviewers: skatkov, yrouban, taewookoh.
skatkov accepted this revision.Apr 29 2020, 2:00 AM
This revision is now accepted and ready to land.Apr 29 2020, 2:00 AM
This revision was automatically updated to reflect the committed changes.