LLVM 19.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
20class Module;
21class ProfileSummaryInfo;
22class BasicBlock;
23class BlockFrequencyInfo;
24class TargetTransformInfo;
25class OptimizationRemarkEmitter;
26class AssumptionCache;
27class DominatorTree;
28class CodeExtractor;
29class CodeExtractorAnalysisCache;
30
31/// A sequence of basic blocks.
32///
33/// A 0-sized SmallVector is slightly cheaper to move than a std::vector.
35
37public:
41 std::function<OptimizationRemarkEmitter &(Function &)> *GORE,
43 : PSI(ProfSI), GetBFI(GBFI), GetTTI(GTTI), GetORE(GORE), LookupAC(LAC) {}
44 bool run(Module &M);
45
46private:
47 bool isFunctionCold(const Function &F) const;
48 bool isBasicBlockCold(BasicBlock *BB, BranchProbability ColdProbThresh,
49 SmallPtrSetImpl<BasicBlock *> &AnnotatedColdBlocks,
50 BlockFrequencyInfo *BFI) const;
51 bool shouldOutlineFrom(const Function &F) const;
52 bool outlineColdRegions(Function &F, bool HasProfileSummary);
53 bool isSplittingBeneficial(CodeExtractor &CE, const BlockSequence &Region,
55 Function *extractColdRegion(BasicBlock &EntryPoint, CodeExtractor &CE,
62 std::function<OptimizationRemarkEmitter &(Function &)> *GetORE;
64};
65
66/// Pass to outline cold regions.
67class HotColdSplittingPass : public PassInfoMixin<HotColdSplittingPass> {
68public:
70};
71
72} // end namespace llvm
73
74#endif // LLVM_TRANSFORMS_IPO_HOTCOLDSPLITTING_H
75
#define F(x, y, z)
Definition: MD5.cpp:55
Machine Check Debug Module
This header defines various interfaces for pass management in LLVM.
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
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.
Definition: CodeExtractor.h:46
Utility class for extracting code into a new function.
Definition: CodeExtractor.h:85
Pass to outline cold regions.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
HotColdSplitting(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:65
The optimization diagnostic interface.
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:111
Analysis providing profile information.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:323
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
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.
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:69