[PATCH] D30633: [BPI] Unreachable branch has 0 probability

Serguei Katkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 6 19:41:29 PST 2017


skatkov added a comment.

Hi Chandler,

Let's consider the following example: you have a loop with say throwing instruction (or @llvm.experimental.deoptimize) inside which is representable by unreachable basic block.
If we use any value greater than zero as probability of the branch coming to unreachable block it is possible that profiling will detect that normal exit from the loop has lower probability than unreachable block and this is incorrect.
So now we say that unreachable edge probability is (1, 2^20). If loop is executed > 2^20 iterations than edge coming to "normal" out of the loop basic block will have a probability (1, >2^20) and LLVM will consider unreachable edge be hotter than mormal exit.

This is unexpected behavior. And it is evident if we choose any constant greater than 0 we are able to find a loop iteration count breaking the expected behavior.
In reality as I understand, we expect  that unreachable is actually never executed and this corresponds to 0 probability for corresponding edge.

Hope that it helps. If you'd like I could add this example to the summary section. I tried to put more general words in summary section.


https://reviews.llvm.org/D30633





More information about the llvm-commits mailing list