This is split from patch https://reviews.llvm.org/D95698
Break SampleProfileLoader into to a base and a derived class.
Base class (SampleProfileLoaderBaseImpl) includes the common
code for IR and MachineIR samples loader.
It will be templatelized in the following patch.
Inline and Probe related code will remain in the derived class of
SampleProfileLoader and stays in SampleProfile.cpp.
We need to refactor some functions:
(1) getInstWeight() to enable the code sharing -- put the core into getInstWeightImpl().
(2) emitAnnotation() and propagateWeights() to carve out the code specific to SampleProfileLoader.
(3) make getInstWeight() and findFunctionSamples() virtual and override
in SampleProfileLoader as they need to access the fields in the derived class.
In a following patch, I will move the base class to a new header file in
llvm/include/llvm/ProfileData
After that, I will make the base class a template. Some function will be specialized in
IR and MachineIR, respectively.
The usages of ProfileIsCS are all in SampleProfileLoader member functions, so it doesn't need to be defined in SampleProfileLoaderImpl?