[llvm] [clang] [PGO] Add ability to mark cold functions as optsize/minsize/optnone (PR #69030)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 30 20:12:04 PST 2024


WenleiHe wrote:

> > How does this relate to the existing `shouldOptimizeForSize(Function&, ...)` and `shouldOptimizeForSize(MachineFunction&, ...)` APIs which appear to provide similar functionality at a first glance. If they are the same, then we should have a plan in place to cleanup and only have one system afterwards, if there are important differences, then I wouldn't mind some comments explaining them.
> 
> This patch allows more user control on the cold function action types.
> 
> Another difference is that the existing API can be invoked in postInline passes which can see more cold functions after inlining. To replace those APIs, the new pass will need to run again post-inlining.

They provide similar but different controls. However, the fact that the two mechanisms are completely disconnected is not ideal. If we want to apply an opt strategy for cold code, we should do it at both function level and block level consistently. 

In fact the unification was also discussed on the original RFC: https://discourse.llvm.org/t/rfc-new-feature-proposal-de-optimizing-cold-functions-using-pgo-info/56388/16?u=wenleihe  Is there a plan on that front? 

https://github.com/llvm/llvm-project/pull/69030


More information about the cfe-commits mailing list