LLVM 24.0.0git
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
17
18namespace llvm {
19
20struct AnalysisOptions;
21class Instruction;
22class LLVMContext;
23
24/// Return -icp-max-num-vtables.
26
27// Class for identifying profitable indirect call promotion candidates when
28// the indirect-call value profile metadata is available.
29class ICallPromotionAnalysis {
30private:
31 // Allocate space to read the profile annotation.
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
52public:
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.
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
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define LLVM_ABI
Definition Compiler.h:211
#define I(x, y, z)
Definition MD5.cpp:57
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.
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:76
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:294
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This is an optimization pass for GlobalISel generic memory operations.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
Definition InstrProf.h:145
LLVM_ABI unsigned getMaxNumVTableAnnotations(const LLVMContext &C)
Return -icp-max-num-vtables.