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 CodeExtractor;
30
31/// A sequence of basic blocks.
32///
33/// A 0-sized SmallVector is slightly cheaper to move than a std::vector.
35
37public:
38 HotColdSplitting(const IPOOptions &Opts, ProfileSummaryInfo *ProfSI,
41 std::function<OptimizationRemarkEmitter &(Function &)> *GORE,
43 : Opts(Opts), PSI(ProfSI), GetBFI(GBFI), GetTTI(GTTI), GetORE(GORE),
44 LookupAC(LAC) {}
45 LLVM_ABI bool run(Module &M);
46
47private:
48 bool isFunctionCold(const Function &F) const;
49 bool isBasicBlockCold(BasicBlock *BB, BranchProbability ColdProbThresh,
50 SmallPtrSetImpl<BasicBlock *> &AnnotatedColdBlocks,
51 BlockFrequencyInfo *BFI) const;
52 bool shouldOutlineFrom(const Function &F) const;
53 bool outlineColdRegions(Function &F, bool HasProfileSummary);
54 bool isSplittingBeneficial(CodeExtractor &CE, const BlockSequence &Region,
56 Function *extractColdRegion(BasicBlock &EntryPoint, CodeExtractor &CE,
60 const IPOOptions &Opts;
64 std::function<OptimizationRemarkEmitter &(Function &)> *GetORE;
66};
67
68/// Pass to outline cold regions.
70 : public OptionalPassInfoMixin<HotColdSplittingPass> {
71public:
73};
74
75} // end namespace llvm
76
77#endif // LLVM_TRANSFORMS_IPO_HOTCOLDSPLITTING_H
78
#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:61
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.
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.