LLVM
24.0.0git
include
llvm
Analysis
IndirectCallPromotionAnalysis.h
Go to the documentation of this file.
1
//===- IndirectCallPromotionAnalysis.h - Indirect call analysis -*- 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
/// \file
9
/// Interface to identify indirect call promotion candidates.
10
///
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_ANALYSIS_INDIRECTCALLPROMOTIONANALYSIS_H
14
#define LLVM_ANALYSIS_INDIRECTCALLPROMOTIONANALYSIS_H
15
16
#include "
llvm/ProfileData/InstrProf.h
"
17
18
namespace
llvm
{
19
20
struct
AnalysisOptions;
21
class
Instruction
;
22
class
LLVMContext
;
23
24
/// Return -icp-max-num-vtables.
25
LLVM_ABI
unsigned
getMaxNumVTableAnnotations
(
const
LLVMContext
&
C
);
26
27
// Class for identifying profitable indirect call promotion candidates when
28
// the indirect-call value profile metadata is available.
29
class
ICallPromotionAnalysis {
30
private
:
31
// Allocate space to read the profile annotation.
32
SmallVector<InstrProfValueData, 4>
ValueDataArray;
33
34
// Count is the call count for the direct-call target.
35
// TotalCount is the total call count for the indirect-call callsite.
36
// RemainingCount is the TotalCount minus promoted-direct-call count.
37
// Return true we should promote this indirect-call target.
38
bool
isPromotionProfitable(
const
AnalysisOptions &Opts,
uint64_t
Count
,
39
uint64_t
TotalCount,
uint64_t
RemainingCount);
40
41
// Returns the number of profitable candidates to promote for the
42
// current ValueDataArray and the given \p Inst.
43
uint32_t
getProfitablePromotionCandidates(
const
AnalysisOptions &Opts,
44
const
Instruction
*Inst,
45
uint64_t
TotalCount);
46
47
// Noncopyable
48
ICallPromotionAnalysis
(
const
ICallPromotionAnalysis &other) =
delete
;
49
ICallPromotionAnalysis &
50
operator=(
const
ICallPromotionAnalysis &other) =
delete
;
51
52
public
:
53
ICallPromotionAnalysis
() =
default
;
54
55
/// Returns reference to array of InstrProfValueData for the given
56
/// instruction \p I.
57
///
58
/// The \p TotalCount and \p NumCandidates are set to the the total profile
59
/// count of the indirect call \p I and the number of profitable candidates
60
/// in the given array (which is sorted in reverse order of profitability).
61
/// The value of \p MaxNumValueData can be used to override the max set
62
/// from the -icp-max-prom option with a larger value.
63
///
64
/// The returned array space is owned by this class, and overwritten on
65
/// subsequent calls.
66
LLVM_ABI
MutableArrayRef<InstrProfValueData>
67
getPromotionCandidatesForInstruction
(
const
Instruction
*
I
,
68
uint64_t
&TotalCount,
69
uint32_t
&NumCandidates,
70
unsigned
MaxNumValueData = 0);
71
};
72
73
}
// end namespace llvm
74
75
#endif
uint64_t
uint64_t uint64_t
Definition
AMDGPUDisassembler.cpp:553
C
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
LLVM_ABI
#define LLVM_ABI
Definition
Compiler.h:211
InstrProf.h
I
#define I(x, y, z)
Definition
MD5.cpp:57
llvm::ICallPromotionAnalysis::getPromotionCandidatesForInstruction
LLVM_ABI MutableArrayRef< InstrProfValueData > getPromotionCandidatesForInstruction(const Instruction *I, uint64_t &TotalCount, uint32_t &NumCandidates, unsigned MaxNumValueData=0)
Returns reference to array of InstrProfValueData for the given instruction I.
Definition
IndirectCallPromotionAnalysis.cpp:64
llvm::ICallPromotionAnalysis::ICallPromotionAnalysis
ICallPromotionAnalysis()=default
llvm::Instruction
Definition
Instruction.h:66
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition
LLVMContext.h:76
llvm::MutableArrayRef
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
Definition
ArrayRef.h:294
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition
SmallVector.h:1261
uint32_t
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition
DefaultTargetInfo.h:21
llvm::Count
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
Definition
InstrProf.h:145
llvm::getMaxNumVTableAnnotations
LLVM_ABI unsigned getMaxNumVTableAnnotations(const LLVMContext &C)
Return -icp-max-num-vtables.
Definition
IndirectCallPromotionAnalysis.cpp:25
Generated on
for LLVM by
1.14.0