The origin patch D152758 caused gcc-12 build failures, which is caused by a gcc bug, and won't be fixed in version 12.
The workaround here is to move full specialization function
definitions out of class declaration into namespace level.
Tested with linux gcc-12, linux clang, windows cl compilers.
Currently, to use PSI->isFunctionHotInCallGraph, we first need to
calculate BPI->BFI, which is expensive. Instead, we can implement
this directly with MBFI. Also as @wenlei mentioned in another patch
review, that MachineSizeOpts already has isFunctionColdInCallGraph,
isFunctionHotInCallGraphNthPercentile, etc implemented. These can be
refactored and so they can be reused across MachineFunctionSplitting
and MachineSizeOpts passes.
This CL does this - it refactors out those internal static functions
into PSI as templated functions, so they can be accessed easily.
This CL was reverted twice - 1) it hits a gcc bug; 2) it
breaks bazel's dependency rules (bazel building was not conducted
before submitting)
This seems to introduce a layering violation.
After this patch, the llvm::Analysis target now depends on the llvm::CodeGen target, but llvm::CodeGen already depends on llvm::Analysis.
One fix is to move the moving the full specialization for the MachineFunction to the CodeGen target (MachineSizeOpts.cpp)