[PATCH] D30633: [BPI] Reduce the probability of unreachable edge to minimal value greater than 0

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 16 10:42:59 PDT 2017


dexonsmith added a comment.

The testcase updates look good to me, and demonstrate the patch is doing what's intended.  It might be worth adding a couple of tests for multiple branch targets (switch statements), since I'm not convinced everything adds up to 1 right now.

As an aside, it seems the logic around unreachable (with and without the patch) might pessimize code paths that lead to `noreturn` functions, such as `posix_spawn()`.  Is that really what we want?  Why?



================
Comment at: lib/Analysis/BranchProbabilityInfo.cpp:202-206
+  auto UnreachableProb = UR_TAKEN_PROB;
+  auto ReachableProb =
+      (BranchProbability::getOne() - UR_TAKEN_PROB * UnreachableEdges.size()) /
+      ReachableEdges.size();
 
----------------
This doesn't look to me like it will add up to `BranchProbability::getOne()` in the end.  Is that a problem?


https://reviews.llvm.org/D30633





More information about the llvm-commits mailing list