[all-commits] [llvm/llvm-project] bb0842: [BPI] Incorrect probability reported in case of mu...
ebrevnov via All-commits
all-commits at lists.llvm.org
Wed Apr 29 21:41:29 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: bb0842a3f11e5d5a13d3212b627d9f1521bff553
https://github.com/llvm/llvm-project/commit/bb0842a3f11e5d5a13d3212b627d9f1521bff553
Author: Evgeniy Brevnov <evgueni.brevnov at gmail.com>
Date: 2020-04-30 (Thu, 30 Apr 2020)
Changed paths:
M llvm/lib/Analysis/BranchProbabilityInfo.cpp
A llvm/test/Analysis/BranchProbabilityInfo/switch.ll
Log Message:
-----------
[BPI] Incorrect probability reported in case of mulptiple edges.
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.
Reviewers: skatkov, yrouban, taewookoh
Reviewed By: skatkov
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D79071
More information about the All-commits
mailing list