|
LLVM
10.0.0
|
The goal of hot/cold splitting is to improve the memory locality of code. More...
#include "llvm/Transforms/IPO/HotColdSplitting.h"#include "llvm/ADT/PostOrderIterator.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/Statistic.h"#include "llvm/Analysis/AliasAnalysis.h"#include "llvm/Analysis/BlockFrequencyInfo.h"#include "llvm/Analysis/BranchProbabilityInfo.h"#include "llvm/Analysis/CFG.h"#include "llvm/Analysis/OptimizationRemarkEmitter.h"#include "llvm/Analysis/PostDominators.h"#include "llvm/Analysis/ProfileSummaryInfo.h"#include "llvm/Analysis/TargetTransformInfo.h"#include "llvm/IR/BasicBlock.h"#include "llvm/IR/CFG.h"#include "llvm/IR/CallSite.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/DiagnosticInfo.h"#include "llvm/IR/Dominators.h"#include "llvm/IR/Function.h"#include "llvm/IR/Instruction.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/Metadata.h"#include "llvm/IR/Module.h"#include "llvm/IR/PassManager.h"#include "llvm/IR/Type.h"#include "llvm/IR/Use.h"#include "llvm/IR/User.h"#include "llvm/IR/Value.h"#include "llvm/InitializePasses.h"#include "llvm/Pass.h"#include "llvm/Support/BlockFrequency.h"#include "llvm/Support/BranchProbability.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Debug.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Transforms/IPO.h"#include "llvm/Transforms/Scalar.h"#include "llvm/Transforms/Utils/BasicBlockUtils.h"#include "llvm/Transforms/Utils/Cloning.h"#include "llvm/Transforms/Utils/CodeExtractor.h"#include "llvm/Transforms/Utils/Local.h"#include "llvm/Transforms/Utils/ValueMapper.h"#include <algorithm>#include <cassert>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). More... | |
Functions | |
| STATISTIC (NumColdRegionsFound, "Number of cold regions found.") | |
| STATISTIC (NumColdRegionsOutlined, "Number of cold regions outlined.") | |
| static int | getOutliningBenefit (ArrayRef< BasicBlock *> Region, TargetTransformInfo &TTI) |
Get the benefit score of outlining Region. More... | |
| static int | getOutliningPenalty (ArrayRef< BasicBlock *> Region, unsigned NumInputs, unsigned NumOutputs) |
Get the penalty score for outlining Region. More... | |
| INITIALIZE_PASS_BEGIN (HotColdSplittingLegacyPass, "hotcoldsplit", "Hot Cold Splitting", false, false) INITIALIZE_PASS_END(HotColdSplittingLegacyPass | |
Variables | |
| static cl::opt< bool > | EnableStaticAnalyis ("hot-cold-static-analysis", cl::init(true), cl::Hidden) |
| static cl::opt< int > | SplittingThreshold ("hotcoldsplit-threshold", cl::init(2), cl::Hidden, cl::desc("Base penalty for splitting cold code (as a " "multiple of TCC_Basic)")) |
| hotcoldsplit | |
| Hot Cold | Splitting |
| Hot Cold | false |
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.
| #define DEBUG_TYPE "hotcoldsplit" |
Definition at line 74 of file HotColdSplitting.cpp.
Referenced by getOutliningPenalty().
| using BlockTy = std::pair<BasicBlock *, unsigned> |
A pair of (basic block, score).
Definition at line 361 of file HotColdSplitting.cpp.
|
static |
Get the benefit score of outlining Region.
Definition at line 225 of file HotColdSplitting.cpp.
References llvm::TargetTransformInfo::getInstructionCost(), llvm::BasicBlock::getTerminator(), llvm::BasicBlock::instructionsWithoutDebug(), and llvm::TargetTransformInfo::TCK_CodeSize.
Referenced by getOutliningPenalty().
|
static |
Get the penalty score for outlining Region.
Definition at line 240 of file HotColdSplitting.cpp.
References assert(), llvm::sys::path::begin(), llvm::AMDGPUISD::BFI, llvm::CallingConv::Cold, llvm::dbgs(), DEBUG_TYPE, llvm::OptimizationRemarkEmitter::emit(), llvm::SmallVectorBase::empty(), llvm::SmallPtrSetImplBase::empty(), llvm::find(), llvm::SmallVectorTemplateCommon< T, typename >::front(), getOutliningBenefit(), llvm::GlobalObject::getSection(), llvm::BasicBlock::getTerminator(), llvm::GlobalObject::hasSection(), llvm::SmallPtrSetImpl< PtrType >::insert(), LLVM_DEBUG, llvm::CallBase::setIsNoInline(), llvm::SetVector< T, Vector, Set >::size(), llvm::SmallPtrSetImplBase::size(), SplittingThreshold, llvm::succ_empty(), llvm::successors(), llvm::TargetTransformInfo::TCC_Basic, llvm::to_string(), llvm::TargetTransformInfo::useColdCCForColdCall(), and llvm::Value::user_begin().
| INITIALIZE_PASS_BEGIN | ( | HotColdSplittingLegacyPass | , |
| "hotcoldsplit" | , | ||
| "Hot Cold Splitting" | , | ||
| false | , | ||
| false | |||
| ) |
Referenced by llvm::HotColdSplittingPass::run().
| STATISTIC | ( | NumColdRegionsFound | , |
| "Number of cold regions found." | |||
| ) |
| STATISTIC | ( | NumColdRegionsOutlined | , |
| "Number of cold regions outlined." | |||
| ) |
| Hot Cold false |
Definition at line 739 of file HotColdSplitting.cpp.
| hotcoldsplit |
Definition at line 739 of file HotColdSplitting.cpp.
| Hot Cold Splitting |
Definition at line 739 of file HotColdSplitting.cpp.
|
static |
Referenced by getOutliningPenalty().
1.8.13