[NFC] Refactor MBB hotness/coldness into templated PSI functions.
commitc3e33720403c010e140c17313eeefd9a0f25887a
authorHan Shen <shenhan@google.com>
Sat, 24 Jun 2023 17:19:26 +0000 (24 10:19 -0700)
committerHan Shen <shenhan@google.com>
Tue, 27 Jun 2023 04:56:40 +0000 (26 21:56 -0700)
tree35a3b3447493639b71014901bbab5019f83273bf
parent10ec9276d40024c23a481e6671dad1521151dd85
[NFC] Refactor MBB hotness/coldness into templated PSI functions.

In D152399, we calculate BPI->BFI in MachineFunctionSplit pass just to
use PSI->isFunctionHotInCallGraph, which is expensive. Instead, we can
implement this directly with MBFI.

Reviewer mentioned in the comment, that machine_size_opts already has
isFunctionColdInCallGraph, isFunctionHotInCallGraphNthPercentile, etc
implemented. These can be refactored and reused across MFS and machine
size opts.

This CL does this - it refactors out those internal static functions
into PSI as templated functions, so they can be accessed easily.

Differential Revision: https://reviews.llvm.org/D152758
llvm/include/llvm/Analysis/ProfileSummaryInfo.h
llvm/include/llvm/Transforms/Utils/SizeOpts.h
llvm/lib/Analysis/ProfileSummaryInfo.cpp
llvm/lib/CodeGen/MachineSizeOpts.cpp
llvm/lib/Transforms/Utils/SizeOpts.cpp