LLVM  8.0.1
IndirectCallPromotionAnalysis.h
Go to the documentation of this file.
1 //===- IndirectCallPromotionAnalysis.h - Indirect call analysis -*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 /// Interface to identify indirect call promotion candidates.
11 ///
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_ANALYSIS_INDIRECTCALLPROMOTIONANALYSIS_H
15 #define LLVM_ANALYSIS_INDIRECTCALLPROMOTIONANALYSIS_H
16 
18 
19 namespace llvm {
20 
21 class Instruction;
22 
23 // Class for identifying profitable indirect call promotion candidates when
24 // the indirect-call value profile metadata is available.
26 private:
27  // Allocate space to read the profile annotation.
28  std::unique_ptr<InstrProfValueData[]> ValueDataArray;
29 
30  // Count is the call count for the direct-call target.
31  // TotalCount is the total call count for the indirect-call callsite.
32  // RemainingCount is the TotalCount minus promoted-direct-call count.
33  // Return true we should promote this indirect-call target.
34  bool isPromotionProfitable(uint64_t Count, uint64_t TotalCount,
35  uint64_t RemainingCount);
36 
37  // Returns the number of profitable candidates to promote for the
38  // current ValueDataArray and the given \p Inst.
39  uint32_t getProfitablePromotionCandidates(const Instruction *Inst,
40  uint32_t NumVals,
41  uint64_t TotalCount);
42 
43  // Noncopyable
44  ICallPromotionAnalysis(const ICallPromotionAnalysis &other) = delete;
46  operator=(const ICallPromotionAnalysis &other) = delete;
47 
48 public:
50 
51  /// Returns reference to array of InstrProfValueData for the given
52  /// instruction \p I.
53  ///
54  /// The \p NumVals, \p TotalCount and \p NumCandidates
55  /// are set to the number of values in the array, the total profile count
56  /// of the indirect call \p I, and the number of profitable candidates
57  /// in the given array (which is sorted in reverse order of profitability).
58  ///
59  /// The returned array space is owned by this class, and overwritten on
60  /// subsequent calls.
63  uint64_t &TotalCount,
64  uint32_t &NumCandidates);
65 };
66 
67 } // end namespace llvm
68 
69 #endif
ArrayRef< InstrProfValueData > getPromotionCandidatesForInstruction(const Instruction *I, uint32_t &NumVals, uint64_t &TotalCount, uint32_t &NumCandidates)
Returns reference to array of InstrProfValueData for the given instruction I.
This class represents lattice values for constants.
Definition: AllocatorList.h:24
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
#define I(x, y, z)
Definition: MD5.cpp:58