[llvm-dev] Questions about Profile Guided Optimization (PGO)

Reixiong Hu via llvm-dev llvm-dev at lists.llvm.org
Sun Jun 27 23:52:03 PDT 2021

Hello, Stefanos,


Got it. Thanks for the comprehensive answer.



Yikun Hu




发件人: Stefanos Baziotis <stefanos.baziotis at gmail.com>
日期: 2021年6月28日 星期一 上午10:30
收件人: Reixiong Hu <reixiongh at gmail.com>
抄送: llvm-dev <llvm-dev at lists.llvm.org>
主题: Re: [llvm-dev] Questions about Profile Guided Optimization (PGO)




It kind of depends on how you define what PGO consists of. But, let's not get stuck on terminology. Basically, if you provide profiling information, then LLVM will take

them into account by default. If not, yes, it will use static heuristics. However, that doesn't necessarily mean that it will _estimate frequencies_ because a lot of times the code looks like this:

if (there is profiling information) {

  use a heuristic which is based on frequencies

} else {

  use a heuristic based on other things (e.g., the structure of the code)



i.e., the else part is not necessarily "else estimate frequencies and use the same heuristic as if there were"





Στις Δευ, 28 Ιουν 2021 στις 4:30 π.μ., ο/η Reixiong Hu via llvm-dev <llvm-dev at lists.llvm.org> έγραψε:

Hello, All,


I am studying the optimizations adopted by LLVM, and finding PGO, which is said to be a good helper for optimization.

Since that requires to instrument and execute the object program, which may be costly for compilation and sometimes inconvenient for developers to come up with test cases, I wonder whether it is a default option for the compilation (i.e., when -O2 or -O3 is enabled)?

If that is the case, how LLVM generates test cases for the profiling if no tests are provided?

If PGO is default and there are no test cases, does LLVM estimate the profiling information, such as frequencies of bbs or calls, statically?


Thanks for your time.



Reixiong Hu


LLVM Developers mailing list
llvm-dev at lists.llvm.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210628/6d784d2e/attachment.html>

More information about the llvm-dev mailing list