[LLVMdev] How to use BlockFrequency in inter-procedural context?

Xinliang David Li xinliangli at gmail.com
Fri Dec 26 20:34:03 PST 2014


On Fri, Dec 26, 2014 at 7:12 PM, <ibaev at codeaurora.org> wrote:
>
> The BlockFrequency analysis has been useful for machine block placement,
> register allocation and other function-level optimizations. How could we
> extend it for use in an inter-procedural (whole-program) context? For
> example, if we would like to compare the hotness of two call sites in
> different functions, or calculate the hotness of two global variables
> referenced in multiple functions.
>

BlockFrequency can not be used for inter-procedural analysis.


>
> If the ratio of a block BB frequency to the entry block frequency is the
> expected number of times the block BB will execute per entry to the
> function (according to LLVM Block Frequency Terminology page), would the
> multiplication of that ratio to the profile count of the function be a
> reasonable approximation of BB total execution count?
>

The answer depends on how BB frequency is computed. If BB frequency is
directly scaled from BB profile count (Execution count), then the answer is
'yes'. In the current implementation, the answer is 'no'.  LLVM only keeps
branch probability information from the profile data, and BB frequency is
computed from branch probabilities:  There are known limitations of the
frequency propagation algorithm to make the resulting frequency
'distorted'. To name a few: loop scale is capped at 4096; branch weight is
incremented by 1 (leading to issues such as computed loop trip count as low
as half of the actual count); limitation of handling irreducible loops etc.
In fact, frequency can not be reliably be used for comparison across
different loop nests.

We have plans to address those issues to improve PGO.

thanks,

David





>
> Thanks,
> Ivan
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141226/ac085c10/attachment.html>


More information about the llvm-dev mailing list