You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[SimpleLoopUnswitch] Don't use BlockFrequencyInfo to skip cold loops
In https://reviews.llvm.org/D129599, non-trivial switching was disabled for cold loops in the interest of code size. This added a dependency on BlockFrequencyInfo, but in loop passes this is only available on a lossy basis: see https://reviews.llvm.org/D86156
LICM moved away from BFI and as of today SimpleLoopUnswitch is the only remaining loop pass that uses BFI, for the sole reason to prevent code size increases in PGO builds. It doesn't use BFI if there's no profile summary available.
However just before the BFI check, we also check to see if the function is marked as OptSize: https://reviews.llvm.org/D94559
And coincidentally sometime after the initial BFI patch PGOForceFunctionAttrsPass was added which will automatically annotate cold functions with OptSize: https://reviews.llvm.org/D149800
I think using PGOForceFunctionAttrs to add the OptSize is probably a more accurate and generalized way to prevent unwanted code size increases. So this patch proposes to remove the BFI check in SimpleLoopUnswitch.
This isn't 100% the same behaviour since the previous behaviour checked for coldness at the loop level and this is now at the function level, but I believe the benefits outweigh this:
- It allows us to remove BFI from the function to loop pass adapter, which was only enabled for certain stages in the LTO pipeline
- We no longer have to worry about lossy analysis results
- Which in turn means the decision to avoid non-trivial switching will be more accurate
- It brings the behaviour inline with other passes that respect OptSize
- It respects the -pgo-cold-func-opt flag so users can control the behaviour
- It prevents the need to run OuterAnalysisManagerProxy as often which is probably good for compile time
0 commit comments