Where can I find the material about LLVM PGO?

Hi, sir, Where can I find the material about LLVM PGO?

Here is a good document: How To Build Clang and LLVM with Profile-Guided Optimizations — LLVM 16.0.0git documentation

1 Like

There have some talks at the LLVM Developers’ Meeting about PGO. Here are a couple:

1 Like

Thank you a lot! I want to collect the PGO techniques in LLVM such as Control Height Reduction / Hot cold splitting. Where can I get them?

@teresajohnson Do you have any suggestions or who would be the best person to help?

1 Like

For machine function splitting, the RFC has description: https://groups.google.com/g/llvm-dev/c/RUegaMg-iqc/m/wFAVxa6fCgAJ

The control height reduction, the code review thread has lots of context info: âš™ D50591 [PGO] Control Height Reduction

@teresajohnson Do you have any suggestions or who would be the best person to help?

I was going to suggest @davidxl but it looks like he already sent a few pointers.

@liusy58 Are you looking for a list of all profile guided transformations in LLVM, or more detailed info on specific ones? For the former, I think PGO information use has spread throughout LLVM into a fair number of places, not sure if anyone has a full list compiled. There are some passes that are more fundamentally PGO based (e.g. MFS, memory intrinsic size optimizations, Indirect Call Promotion), but many more that use the info when available (e.g. inlining, unrolling, etc).

Thank you, sir. I mean the former. What about branch optimizations based on PGO in llvm?

Thank you, sir. I mean the former. What about branch optimizations based on PGO in llvm?

Yes, LLVM for example uses PGO to do code layout, see LLVM: lib/CodeGen/MachineBlockPlacement.cpp Source File

(and you are welcome, but quick correction, I’m not a sir =) )

Sorry :rofl: Are there any other transforms besides bb placement relating to branch optimizations based on PFO?

Are there any other transforms besides bb placement relating to branch optimizations based on PFO?

That and MFS and CHR described earlier are the main ones that focus more directly on branches that come to mind, but a bunch of the other PGO driven/utilizing optimizations I noted earlier (e.g. ICP, inlining, unrolling) of course also affect branches as a side effect. One that is in the works: [RFC] cmov-vs-branch optimization

There may be others that I’m not thinking of or aware of.

1 Like

right – any passes that uses BFI/BPI are users of PGO. Without PGO, they use BFI from static branch prediction. Other examples (not all of them are in LLVM though) including register allocation, code hoisting and sinking optimization, speculative PRE, strengh reduction etc.

1 Like