LLVM 18.0.0git
|
Utility to calculate the size and a few similar metrics for a set of basic blocks. More...
#include "llvm/Analysis/CodeMetrics.h"
Public Member Functions | |
void | analyzeBasicBlock (const BasicBlock *BB, const TargetTransformInfo &TTI, const SmallPtrSetImpl< const Value * > &EphValues, bool PrepareForLTO=false) |
Add information about a block to the current state. | |
Static Public Member Functions | |
static void | collectEphemeralValues (const Loop *L, AssumptionCache *AC, SmallPtrSetImpl< const Value * > &EphValues) |
Collect a loop's ephemeral values (those used only by an assume or similar intrinsics in the loop). | |
static void | collectEphemeralValues (const Function *L, AssumptionCache *AC, SmallPtrSetImpl< const Value * > &EphValues) |
Collect a functions's ephemeral values (those used only by an assume or similar intrinsics in the function). | |
Public Attributes | |
bool | exposesReturnsTwice = false |
True if this function contains a call to setjmp or other functions with attribute "returns twice" without having the attribute itself. | |
bool | isRecursive = false |
True if this function calls itself. | |
bool | notDuplicatable = false |
True if this function cannot be duplicated. | |
bool | convergent = false |
True if this function contains a call to a convergent function. | |
bool | usesDynamicAlloca = false |
True if this function calls alloca (in the C sense). | |
InstructionCost | NumInsts = 0 |
Code size cost of the analyzed blocks. | |
unsigned | NumBlocks = false |
Number of analyzed blocks. | |
DenseMap< const BasicBlock *, InstructionCost > | NumBBInsts |
Keeps track of basic block code size estimates. | |
unsigned | NumCalls = false |
Keep track of the number of calls to 'big' functions. | |
unsigned | NumInlineCandidates = 0 |
The number of calls to internal functions with a single caller. | |
unsigned | NumVectorInsts = 0 |
How many instructions produce vector values. | |
unsigned | NumRets = 0 |
How many 'ret' instructions the blocks contain. | |
Utility to calculate the size and a few similar metrics for a set of basic blocks.
Definition at line 31 of file CodeMetrics.h.
void CodeMetrics::analyzeBasicBlock | ( | const BasicBlock * | BB, |
const TargetTransformInfo & | TTI, | ||
const SmallPtrSetImpl< const Value * > & | EphValues, | ||
bool | PrepareForLTO = false |
||
) |
Add information about a block to the current state.
Fill in the current structure with information gleaned from the specified block.
Definition at line 116 of file CodeMetrics.cpp.
References convergent, llvm::SmallPtrSetImpl< PtrType >::count(), F, llvm::TargetTransformInfo::getInstructionCost(), llvm::BasicBlock::getParent(), llvm::BasicBlock::getTerminator(), I, llvm::TargetTransformInfo::isLoweredToCall(), isRecursive, notDuplicatable, NumBBInsts, NumBlocks, NumCalls, NumInlineCandidates, NumInsts, NumRets, NumVectorInsts, llvm::TargetTransformInfo::TCK_CodeSize, and usesDynamicAlloca.
|
static |
Collect a functions's ephemeral values (those used only by an assume or similar intrinsics in the function).
Definition at line 94 of file CodeMetrics.cpp.
References appendSpeculatableOperands(), assert(), llvm::AssumptionCache::assumptions(), completeEphemeralValues(), F, I, and llvm::SmallPtrSetImpl< PtrType >::insert().
|
static |
Collect a loop's ephemeral values (those used only by an assume or similar intrinsics in the loop).
Definition at line 70 of file CodeMetrics.cpp.
References appendSpeculatableOperands(), llvm::AssumptionCache::assumptions(), completeEphemeralValues(), I, and llvm::SmallPtrSetImpl< PtrType >::insert().
Referenced by llvm::slpvectorizer::BoUpSLP::BoUpSLP(), llvm::LoopVectorizationCostModel::collectValuesToIgnore(), computeHeuristicUnrollFactor(), findBestNonTrivialUnswitchCandidate(), llvm::PPCTTIImpl::isHardwareLoopProfitable(), llvm::IVUsers::IVUsers(), llvm::FunctionSpecializer::run(), tryToUnrollAndJamLoop(), and tryToUnrollLoop().
bool llvm::CodeMetrics::convergent = false |
True if this function contains a call to a convergent function.
Definition at line 46 of file CodeMetrics.h.
Referenced by analyzeBasicBlock().
bool llvm::CodeMetrics::exposesReturnsTwice = false |
True if this function contains a call to setjmp or other functions with attribute "returns twice" without having the attribute itself.
Definition at line 34 of file CodeMetrics.h.
bool llvm::CodeMetrics::isRecursive = false |
True if this function calls itself.
Definition at line 37 of file CodeMetrics.h.
Referenced by analyzeBasicBlock().
bool llvm::CodeMetrics::notDuplicatable = false |
True if this function cannot be duplicated.
True if this function contains one or more indirect branches, or it contains one or more 'noduplicate' instructions.
Definition at line 43 of file CodeMetrics.h.
Referenced by analyzeBasicBlock().
DenseMap<const BasicBlock *, InstructionCost> llvm::CodeMetrics::NumBBInsts |
Keeps track of basic block code size estimates.
Definition at line 58 of file CodeMetrics.h.
Referenced by analyzeBasicBlock().
unsigned llvm::CodeMetrics::NumBlocks = false |
Number of analyzed blocks.
Definition at line 55 of file CodeMetrics.h.
Referenced by analyzeBasicBlock().
unsigned llvm::CodeMetrics::NumCalls = false |
Keep track of the number of calls to 'big' functions.
Definition at line 61 of file CodeMetrics.h.
Referenced by analyzeBasicBlock().
unsigned llvm::CodeMetrics::NumInlineCandidates = 0 |
The number of calls to internal functions with a single caller.
These are likely targets for future inlining, likely exposed by interleaved devirtualization.
Definition at line 67 of file CodeMetrics.h.
Referenced by analyzeBasicBlock().
InstructionCost llvm::CodeMetrics::NumInsts = 0 |
Code size cost of the analyzed blocks.
Definition at line 52 of file CodeMetrics.h.
Referenced by analyzeBasicBlock().
unsigned llvm::CodeMetrics::NumRets = 0 |
How many 'ret' instructions the blocks contain.
Definition at line 75 of file CodeMetrics.h.
Referenced by analyzeBasicBlock().
unsigned llvm::CodeMetrics::NumVectorInsts = 0 |
How many instructions produce vector values.
The inliner is more aggressive with inlining vector kernels.
Definition at line 72 of file CodeMetrics.h.
Referenced by analyzeBasicBlock().
bool llvm::CodeMetrics::usesDynamicAlloca = false |
True if this function calls alloca (in the C sense).
Definition at line 49 of file CodeMetrics.h.
Referenced by analyzeBasicBlock().