If a branch condition is defined by a function call result, the profile information for the branch may be (effectively) lost after inlinling.
For instance,
bool cond() { if (a) return true; if (b) return true; return false; } void test() { if (__builtin_expect(cond(), false) ) { bar(); // cold } .. }
After inlining and jump threading, the first branch in the inline instance does not have profile data -- this will make the block for bar() look hot.
In this patch, the problem is fixed in jump threading by 'backward' propagate the BP to the predecessor given the conditional probability discovered.
Would be good to connect this comment to the arguments and behavior of this function.
(Don't get me wrong, this comment is *excellent* for explaining why we can do this back propagation and how to compute it! I just also want comments that explain how this routine fits into the model.)