LLVM: lib/Analysis/IndirectCallPromotionAnalysis.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
20
21using namespace llvm;
22
23#define DEBUG_TYPE "pgo-icall-prom-analysis"
24
25namespace llvm {
26
27
28
31 cl::desc("The percentage threshold against remaining unpromoted indirect "
32 "call count for the promotion"));
33
34
35
39 cl::desc("The percentage threshold against total "
40 "count for the promotion"));
41
42
43
46 cl::desc("Minimum absolute count for promotion candidate"));
47
48
49
52 cl::desc("Max number of promotions for a single indirect "
53 "call callsite"));
54
57 cl::desc("Max number of vtables annotated for a vtable load instruction."));
58
59}
60
61bool ICallPromotionAnalysis::isPromotionProfitable(uint64_t Count,
67}
68
69
70
71
72uint32_t ICallPromotionAnalysis::getProfitablePromotionCandidates(
73 const Instruction *Inst, uint64_t TotalCount) {
75 << " Num_targets: " << ValueDataArray.size() << "\n");
76
77 uint32_t I = 0;
78 uint64_t RemainingCount = TotalCount;
80 uint64_t Count = ValueDataArray[I].Count;
83 << " Target_func: " << ValueDataArray[I].Value << "\n");
84
85 if (!isPromotionProfitable(Count, TotalCount, RemainingCount)) {
87 return I;
88 }
89 RemainingCount -= Count;
90 }
91 return I;
92}
93
99 if (ValueDataArray.empty()) {
100 NumCandidates = 0;
102 }
103 NumCandidates = getProfitablePromotionCandidates(I, TotalCount);
104 return ValueDataArray;
105}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
cl::opt< unsigned > MaxNumVTableAnnotations("icp-max-num-vtables", cl::init(6), cl::Hidden, cl::desc("Max number of vtables annotated for a vtable load instruction."))
static cl::opt< unsigned > ICPMinimumCountThreshold("icp-minimum-count-threshold", cl::init(0), cl::Hidden, cl::desc("Minimum absolute count for promotion candidate"))
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionAddr VTableAddr Count
LLVM_ABI SmallVector< InstrProfValueData, 4 > getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind, uint32_t MaxNumValueData, uint64_t &TotalC, bool GetNoICPValue=false)
Extract the value profile data from Inst and returns them if Inst is annotated with value profile dat...
MutableArrayRef(T &OneElt) -> MutableArrayRef< T >
static cl::opt< unsigned > ICPRemainingPercentThreshold("icp-remaining-percent-threshold", cl::init(30), cl::Hidden, cl::desc("The percentage threshold against remaining unpromoted indirect " "call count for the promotion"))
static cl::opt< unsigned > MaxNumPromotions("icp-max-prom", cl::init(3), cl::Hidden, cl::desc("Max number of promotions for a single indirect " "call callsite"))
static cl::opt< uint64_t > ICPTotalPercentThreshold("icp-total-percent-threshold", cl::init(5), cl::Hidden, cl::desc("The percentage threshold against total " "count for the promotion"))