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!
Best regards,
Xiaowan
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 ⚙ D36351 [lld][ELF] Add profile guided section layout
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).
Thank you so much for your prompt reply, Davide!
Dear Davide,
We noticed that C^3 will only be available for the upcoming versions of LLVM. I was wondering what it is like in LLVM 6.0.1?
Thank you so much!
Best regards,
Xiaowan
Dear Davide,
We noticed that C^3 will only be available for the upcoming versions of LLVM. I was wondering what it is like in LLVM 6.0.1?
Thank you so much!
Best regards,
Xiaowan
LLVM currently does basic block layout per function based on profile data. See lib/CodeGen/MachineBlockPlacement.cpp .