Index: llvm/include/llvm/Transforms/IPO/HotColdSplitting.h =================================================================== --- llvm/include/llvm/Transforms/IPO/HotColdSplitting.h +++ llvm/include/llvm/Transforms/IPO/HotColdSplitting.h @@ -17,6 +17,42 @@ namespace llvm { class Module; +class ProfileSummaryInfo; +class BlockFrequencyInfo; +class TargetTransformInfo; +class OptimizationRemarkEmitter; +class AssumptionCache; +class DominatorTree; + +/// A sequence of basic blocks. +/// +/// A 0-sized SmallVector is slightly cheaper to move than a std::vector. +using BlockSequence = SmallVector; + +class HotColdSplitting { +public: + HotColdSplitting(ProfileSummaryInfo *ProfSI, + function_ref GBFI, + function_ref GTTI, + std::function *GORE, + function_ref LAC) + : PSI(ProfSI), GetBFI(GBFI), GetTTI(GTTI), GetORE(GORE), LookupAC(LAC) {} + bool run(Module &M); + +private: + bool isFunctionCold(const Function &F) const; + bool shouldOutlineFrom(const Function &F) const; + bool outlineColdRegions(Function &F, bool HasProfileSummary); + Function *extractColdRegion(const BlockSequence &Region, DominatorTree &DT, + BlockFrequencyInfo *BFI, TargetTransformInfo &TTI, + OptimizationRemarkEmitter &ORE, + AssumptionCache *AC, unsigned Count); + ProfileSummaryInfo *PSI; + function_ref GetBFI; + function_ref GetTTI; + std::function *GetORE; + function_ref LookupAC; +}; /// Pass to outline cold regions. class HotColdSplittingPass : public PassInfoMixin { Index: llvm/lib/Transforms/IPO/HotColdSplitting.cpp =================================================================== --- llvm/lib/Transforms/IPO/HotColdSplitting.cpp +++ llvm/lib/Transforms/IPO/HotColdSplitting.cpp @@ -85,12 +85,6 @@ "multiple of TCC_Basic)")); namespace { - -/// A sequence of basic blocks. -/// -/// A 0-sized SmallVector is slightly cheaper to move than a std::vector. -using BlockSequence = SmallVector; - // Same as blockEndsInUnreachable in CodeGen/BranchFolding.cpp. Do not modify // this function unless you modify the MBB version as well. // @@ -169,31 +163,6 @@ return Changed; } -class HotColdSplitting { -public: - HotColdSplitting(ProfileSummaryInfo *ProfSI, - function_ref GBFI, - function_ref GTTI, - std::function *GORE, - function_ref LAC) - : PSI(ProfSI), GetBFI(GBFI), GetTTI(GTTI), GetORE(GORE), LookupAC(LAC) {} - bool run(Module &M); - -private: - bool isFunctionCold(const Function &F) const; - bool shouldOutlineFrom(const Function &F) const; - bool outlineColdRegions(Function &F, bool HasProfileSummary); - Function *extractColdRegion(const BlockSequence &Region, DominatorTree &DT, - BlockFrequencyInfo *BFI, TargetTransformInfo &TTI, - OptimizationRemarkEmitter &ORE, - AssumptionCache *AC, unsigned Count); - ProfileSummaryInfo *PSI; - function_ref GetBFI; - function_ref GetTTI; - std::function *GetORE; - function_ref LookupAC; -}; - class HotColdSplittingLegacyPass : public ModulePass { public: static char ID;