LLVM 24.0.0git
HotColdSplitting.cpp File Reference

The goal of hot/cold splitting is to improve the memory locality of code. More...

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "hotcoldsplit"

Typedefs

using BlockTy = std::pair<BasicBlock *, unsigned>
 A pair of (basic block, score).

Functions

 STATISTIC (NumColdRegionsFound, "Number of cold regions found.")
 STATISTIC (NumColdRegionsOutlined, "Number of cold regions outlined.")
static InstructionCost getOutliningBenefit (ArrayRef< BasicBlock * > Region, TargetTransformInfo &TTI)
 Get the benefit score of outlining Region.
static int getOutliningPenalty (const IPOOptions &Opts, ArrayRef< BasicBlock * > Region, unsigned NumInputs, unsigned NumOutputs)
 Get the penalty score for outlining Region.

Detailed Description

The goal of hot/cold splitting is to improve the memory locality of code.

The splitting pass does this by identifying cold blocks and moving them into separate functions.

When the splitting pass finds a cold block (referred to as "the sink"), it grows a maximal cold region around that block. The maximal region contains all blocks (post-)dominated by the sink [*]. In theory, these blocks are as cold as the sink. Once a region is found, it's split out of the original function provided it's profitable to do so.

[*] In practice, there is some added complexity because some blocks are not safe to extract.

TODO: Use the PM to get domtrees, and preserve BFI/BPI. TODO: Reorder outlined functions.

Definition in file HotColdSplitting.cpp.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "hotcoldsplit"

Definition at line 60 of file HotColdSplitting.cpp.

Typedef Documentation

◆ BlockTy

using BlockTy = std::pair<BasicBlock *, unsigned>

A pair of (basic block, score).

Definition at line 430 of file HotColdSplitting.cpp.

Function Documentation

◆ getOutliningBenefit()

InstructionCost getOutliningBenefit ( ArrayRef< BasicBlock * > Region,
TargetTransformInfo & TTI )
static

Get the benefit score of outlining Region.

Definition at line 257 of file HotColdSplitting.cpp.

References I, and llvm::TargetTransformInfo::TCK_CodeSize.

◆ getOutliningPenalty()

◆ STATISTIC() [1/2]

STATISTIC ( NumColdRegionsFound ,
"Number of cold regions found."  )

◆ STATISTIC() [2/2]

STATISTIC ( NumColdRegionsOutlined ,
"Number of cold regions outlined."  )

References I.