1 //===- IndirectCallPromotionAnalysis.h - Indirect call analysis -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 /// Interface to identify indirect call promotion candidates.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_ANALYSIS_INDIRECTCALLPROMOTIONANALYSIS_H
15 #define LLVM_ANALYSIS_INDIRECTCALLPROMOTIONANALYSIS_H
17 #include "llvm/ProfileData/InstrProf.h"
23 // Class for identifying profitable indirect call promotion candidates when
24 // the indirect-call value profile metadata is available.
25 class ICallPromotionAnalysis {
27 // Allocate space to read the profile annotation.
28 std::unique_ptr<InstrProfValueData[]> ValueDataArray;
30 // Count is the call count for the direct-call target and
31 // TotalCount is the call count for the indirect-call callsite.
32 // Return true we should promote this indirect-call target.
33 bool isPromotionProfitable(uint64_t Count, uint64_t TotalCount);
35 // Returns the number of profitable candidates to promote for the
36 // current ValueDataArray and the given \p Inst.
37 uint32_t getProfitablePromotionCandidates(const Instruction *Inst,
42 ICallPromotionAnalysis(const ICallPromotionAnalysis &other) = delete;
43 ICallPromotionAnalysis &
44 operator=(const ICallPromotionAnalysis &other) = delete;
47 ICallPromotionAnalysis();
49 /// \brief Returns reference to array of InstrProfValueData for the given
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).
57 /// The returned array space is owned by this class, and overwritten on
59 ArrayRef<InstrProfValueData>
60 getPromotionCandidatesForInstruction(const Instruction *I, uint32_t &NumVals,
62 uint32_t &NumCandidates);
65 } // end namespace llvm