llvm.org GIT mirror llvm / 3c7ec21
[NFC] Move hot cold splitting class to header file Summary: This is to facilitate unittests Reviewers: compnerd, vsk, tejohnson, sebpop, brzycki, SirishP Reviewed By: tejohnson Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68079 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373151 91177308-0d34-0410-b5e6-96231b3b80d8 Aditya Kumar 1 year, 1 month ago
2 changed file(s) with 36 addition(s) and 31 deletion(s). Raw diff Collapse all Expand all
1616 namespace llvm {
1717
1818 class Module;
19 class ProfileSummaryInfo;
20 class BlockFrequencyInfo;
21 class TargetTransformInfo;
22 class OptimizationRemarkEmitter;
23 class AssumptionCache;
24 class DominatorTree;
25
26 /// A sequence of basic blocks.
27 ///
28 /// A 0-sized SmallVector is slightly cheaper to move than a std::vector.
29 using BlockSequence = SmallVector;
30
31 class HotColdSplitting {
32 public:
33 HotColdSplitting(ProfileSummaryInfo *ProfSI,
34 function_ref GBFI,
35 function_ref GTTI,
36 std::function *GORE,
37 function_ref LAC)
38 : PSI(ProfSI), GetBFI(GBFI), GetTTI(GTTI), GetORE(GORE), LookupAC(LAC) {}
39 bool run(Module &M);
40
41 private:
42 bool isFunctionCold(const Function &F) const;
43 bool shouldOutlineFrom(const Function &F) const;
44 bool outlineColdRegions(Function &F, bool HasProfileSummary);
45 Function *extractColdRegion(const BlockSequence &Region, DominatorTree &DT,
46 BlockFrequencyInfo *BFI, TargetTransformInfo &TTI,
47 OptimizationRemarkEmitter &ORE,
48 AssumptionCache *AC, unsigned Count);
49 ProfileSummaryInfo *PSI;
50 function_ref GetBFI;
51 function_ref GetTTI;
52 std::function *GetORE;
53 function_ref LookupAC;
54 };
1955
2056 /// Pass to outline cold regions.
2157 class HotColdSplittingPass : public PassInfoMixin {
8484 "multiple of TCC_Basic)"));
8585
8686 namespace {
87
88 /// A sequence of basic blocks.
89 ///
90 /// A 0-sized SmallVector is slightly cheaper to move than a std::vector.
91 using BlockSequence = SmallVector;
92
9387 // Same as blockEndsInUnreachable in CodeGen/BranchFolding.cpp. Do not modify
9488 // this function unless you modify the MBB version as well.
9589 //
167161
168162 return Changed;
169163 }
170
171 class HotColdSplitting {
172 public:
173 HotColdSplitting(ProfileSummaryInfo *ProfSI,
174 function_ref GBFI,
175 function_ref GTTI,
176 std::function *GORE,
177 function_ref LAC)
178 : PSI(ProfSI), GetBFI(GBFI), GetTTI(GTTI), GetORE(GORE), LookupAC(LAC) {}
179 bool run(Module &M);
180
181 private:
182 bool isFunctionCold(const Function &F) const;
183 bool shouldOutlineFrom(const Function &F) const;
184 bool outlineColdRegions(Function &F, bool HasProfileSummary);
185 Function *extractColdRegion(const BlockSequence &Region, DominatorTree &DT,
186 BlockFrequencyInfo *BFI, TargetTransformInfo &TTI,
187 OptimizationRemarkEmitter &ORE,
188 AssumptionCache *AC, unsigned Count);
189 ProfileSummaryInfo *PSI;
190 function_ref GetBFI;
191 function_ref GetTTI;
192 std::function *GetORE;
193 function_ref LookupAC;
194 };
195164
196165 class HotColdSplittingLegacyPass : public ModulePass {
197166 public: