Conversation

Is there a document somewhere that describes what optimizations PGO opens up? Like I imagine it can say "don't inline this, it doesn't get called" and "inline this, it gets called a bunch", but what else?
1
2
Replying to
It provides branch metadata so it knows how to order branches or add hints for better branch prediction. Can also decide when to use cmov, etc. that way. Since it has metadata on function call sites, callees and branches it can also split out functions into hit/cold regions, etc.
2
Replying to
Is there a doc with all of this? I actually don't even know how code tells a branch predictor "this is the likely branch", although I know that gcc had a 'likely' builtin iirc. I see you mentioned a builtin, I'll check that out too.
1
Replying to
Ordering the block taken in the likely case before the branch is an incredibly strong hint that it's a hot path because that's how a loop looks. Similarly, if both are after the code, the one that's closer is a slight hint. It will stick all the cold paths out of line at bottom.
1
1
Replying to and
It will optimize the cold blocks / functions for size and try to group them in cold sections together, and similarly will try to group hot code together. PGO can provide more information it could use beyond just hot/cold to group code that's used together in sections together.
1
1