LLVM 24.0.0git
HotColdSplitting.h
Go to the documentation of this file.
1//===- HotColdSplitting.h ---- Outline Cold Regions -------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//===----------------------------------------------------------------------===//
7//
8// This pass outlines cold regions to a separate function.
9//
10//===----------------------------------------------------------------------===//
11
12#ifndef LLVM_TRANSFORMS_IPO_HOTCOLDSPLITTING_H
13#define LLVM_TRANSFORMS_IPO_HOTCOLDSPLITTING_H
14
15#include "llvm/IR/PassManager.h"
17
18namespace llvm {
19
20struct IPOOptions;
21class Module;
23class BasicBlock;
27class AssumptionCache;
28class DominatorTree;
29class CodeExtractor;
31
32/// A sequence of basic blocks.
33///
34/// A 0-sized SmallVector is slightly cheaper to move than a std::vector.
36
38public:
39 HotColdSplitting(const IPOOptions &Opts, ProfileSummaryInfo *ProfSI,
42 std::function<OptimizationRemarkEmitter &(Function &)> *GORE,
44 : Opts(Opts), PSI(ProfSI), GetBFI(GBFI), GetTTI(GTTI), GetORE(GORE),
45 LookupAC(LAC) {}
46 LLVM_ABI bool run(Module &M);
47
48private:
49 bool isFunctionCold(const Function &F) const;
50 bool isBasicBlockCold(BasicBlock *BB, BranchProbability ColdProbThresh,
51 SmallPtrSetImpl<BasicBlock *> &AnnotatedColdBlocks,
52 BlockFrequencyInfo *BFI) const;
53 bool shouldOutlineFrom(const Function &F) const;
54 bool outlineColdRegions(Function &F, bool HasProfileSummary);
55 bool isSplittingBeneficial(CodeExtractor &CE, const BlockSequence &Region,
57 Function *extractColdRegion(BasicBlock &EntryPoint, CodeExtractor &CE,
61 const IPOOptions &Opts;
65 std::function<OptimizationRemarkEmitter &(Function &)> *GetORE;
67};
68
69/// Pass to outline cold regions.
71 : public OptionalPassInfoMixin<HotColdSplittingPass> {
72public:
74};
75
76} // end namespace llvm
77
78#endif // LLVM_TRANSFORMS_IPO_HOTCOLDSPLITTING_H
79
#define LLVM_ABI
Definition Compiler.h:211
This header defines various interfaces for pass management in LLVM.
#define F(x, y, z)
Definition MD5.cpp:54
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
Definition BasicBlock.h:62
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
A cache for the CodeExtractor analysis.
Utility class for extracting code into a new function.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition Dominators.h:122
Pass to outline cold regions.
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
LLVM_ABI bool run(Module &M)
HotColdSplitting(const IPOOptions &Opts, ProfileSummaryInfo *ProfSI, function_ref< BlockFrequencyInfo *(Function &)> GBFI, function_ref< TargetTransformInfo &(Function &)> GTTI, std::function< OptimizationRemarkEmitter &(Function &)> *GORE, function_ref< AssumptionCache *(Function &)> LAC)
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
The optimization diagnostic interface.
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
Analysis providing profile information.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
An efficient, type-erasing, non-owning reference to a callable.
This is an optimization pass for GlobalISel generic memory operations.
SmallVector< BasicBlock *, 0 > BlockSequence
A sequence of basic blocks.
TargetTransformInfo TTI
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
A CRTP mix-in for passes that can be skipped.