[llvm-dev] Regarding basic block layout/code placement optimizations of profile guided optimization (PGO)

Davide Italiano via llvm-dev llvm-dev at lists.llvm.org
Tue Aug 7 14:14:58 PDT 2018


On Tue, Aug 7, 2018 at 11:53 AM Xiaowan Dong via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
>
> Hi,
>
> I would like to learn the details regarding what exactly PGO does for basic block layout/code placement optimizations in llvm. Could you please point me to some descriptions? Is it close to this paper (Karl Pettis and Robert C. Hansen. 1990. Profile guided code positioning.  PLDI'90) http://perso.ensta-paristech.fr/~bmonsuez/Cours/B6-4/Articles/papers15.pdf? Whether it is purely intra-procedural or include inter-procedural optimizations?
>
> Thank you so much!
>

lld implements C^3 which is basically a variation of Pettis-Hansen.
The CGO 17 paper describes the approach with a great level of detail
https://research.fb.com/wp-content/uploads/2017/01/cgo2017-hfsort-final1.pdf?
(the algorithm per-se is fairly straightforward).
Pointers to the code at https://reviews.llvm.org/D36351
You can also find the details in Michael's original RFC
http://lists.llvm.org/pipermail/llvm-dev/2017-June/114178.html

There's also a pass in the backend (codegen) to perform profile-driven
Machine BB placement (CodeGen/MachineBlockPlacement.cpp).

--
Davide


More information about the llvm-dev mailing list