LLVM 19.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
20class Instruction;
21
22// Class for identifying profitable indirect call promotion candidates when
23// the indirect-call value profile metadata is available.
25private:
26 // Allocate space to read the profile annotation.
28
29 // Count is the call count for the direct-call target.
30 // TotalCount is the total call count for the indirect-call callsite.
31 // RemainingCount is the TotalCount minus promoted-direct-call count.
32 // Return true we should promote this indirect-call target.
33 bool isPromotionProfitable(uint64_t Count, uint64_t TotalCount,
34 uint64_t RemainingCount);
35
36 // Returns the number of profitable candidates to promote for the
37 // current ValueDataArray and the given \p Inst.
38 uint32_t getProfitablePromotionCandidates(const Instruction *Inst,
39 uint64_t TotalCount);
40
41 // Noncopyable
44 operator=(const ICallPromotionAnalysis &other) = delete;
45
46public:
48
49 /// Returns reference to array of InstrProfValueData for the given
50 /// instruction \p I.
51 ///
52 /// The \p NumVals, \p TotalCount and \p NumCandidates
53 /// are set to the number of values in the array, the total profile count
54 /// of the indirect call \p I, and the number of profitable candidates
55 /// in the given array (which is sorted in reverse order of profitability).
56 ///
57 /// The returned array space is owned by this class, and overwritten on
58 /// subsequent calls.
60 const Instruction *I, uint64_t &TotalCount, uint32_t &NumCandidates);
61};
62
63} // end namespace llvm
64
65#endif
#define I(x, y, z)
Definition: MD5.cpp:58
MutableArrayRef< InstrProfValueData > getPromotionCandidatesForInstruction(const Instruction *I, uint64_t &TotalCount, uint32_t &NumCandidates)
Returns reference to array of InstrProfValueData for the given instruction I.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:307
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18