1//===- CodeMetrics.h - Code cost measurements -------------------*- C++ -*-===//
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
7//===----------------------------------------------------------------------===//
9// This file implements various weight measurements for code, helping
10// the Inliner and other passes decide whether to duplicate its contents.
12//===----------------------------------------------------------------------===//
14#ifndef LLVM_ANALYSIS_CODEMETRICS_H
15#define LLVM_ANALYSIS_CODEMETRICS_H
32/// Utility to calculate the size and a few similar metrics for a set
35 /// True if this function contains a call to setjmp or other functions
36 /// with attribute "returns twice" without having the attribute itself.
39 /// True if this function calls itself.
42 /// True if this function cannot be duplicated.
44 /// True if this function contains one or more indirect branches, or it contains
45 /// one or more 'noduplicate' instructions.
48 /// The kind of convergence specified in this function.
51 /// True if this function calls alloca (in the C sense).
54 /// Code size cost of the analyzed blocks.
57 /// Number of analyzed blocks.
60 /// Keeps track of basic block code size estimates.
63 /// Keep track of the number of calls to 'big' functions.
66 /// The number of calls to internal functions with a single caller.
68 /// These are likely targets for future inlining, likely exposed by
69 /// interleaved devirtualization.
72 /// How many instructions produce vector values.
74 /// The inliner is more aggressive with inlining vector kernels.
77 /// How many 'ret' instructions the blocks contain.
80 /// Add information about a block to the current state.
84 bool PrepareForLTO =
false,
const Loop *L =
nullptr);
86 /// Collect a loop's ephemeral values (those used only by an assume
87 /// or similar intrinsics in the loop).
92 /// Collect a functions's ephemeral values (those used only by an
93 /// assume or similar intrinsics in the function).
This file defines the DenseMap class.
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
Represents a single loop in the control flow graph.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
LLVM Value Representation.
This is an optimization pass for GlobalISel generic memory operations.
Utility to calculate the size and a few similar metrics for a set of basic blocks.
bool usesDynamicAlloca
True if this function calls alloca (in the C sense).
unsigned NumBlocks
Number of analyzed blocks.
ConvergenceKind Convergence
The kind of convergence specified in this function.
bool notDuplicatable
True if this function cannot be duplicated.
unsigned NumInlineCandidates
The number of calls to internal functions with a single caller.
bool isRecursive
True if this function calls itself.
static LLVM_ABI 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).
unsigned NumRets
How many 'ret' instructions the blocks contain.
bool exposesReturnsTwice
True if this function contains a call to setjmp or other functions with attribute "returns twice" wit...
DenseMap< const BasicBlock *, InstructionCost > NumBBInsts
Keeps track of basic block code size estimates.
LLVM_ABI void analyzeBasicBlock(const BasicBlock *BB, const TargetTransformInfo &TTI, const SmallPtrSetImpl< const Value * > &EphValues, bool PrepareForLTO=false, const Loop *L=nullptr)
Add information about a block to the current state.
unsigned NumCalls
Keep track of the number of calls to 'big' functions.
unsigned NumVectorInsts
How many instructions produce vector values.
InstructionCost NumInsts
Code size cost of the analyzed blocks.