LLVM: lib/ProfileData/ProfileSummaryBuilder.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

18

19using namespace llvm;

20

21namespace llvm {

23 "profile-summary-contextless", cl::Hidden,

24 cl::desc("Merge context profiles before calculating thresholds."));

25

26

27

28

29

30

31

32

35 cl::desc("A count is hot if it exceeds the minimum count to"

36 " reach this percentile of total counts."));

37

40 cl::desc("A count is cold if it is below the minimum count"

41 " to reach this percentile of total counts."));

42

44 "profile-summary-huge-working-set-size-threshold", cl::Hidden,

46 cl::desc("The code working set size is considered huge if the number of"

47 " blocks required to reach the -profile-summary-cutoff-hot"

48 " percentile exceeds this count."));

49

51 "profile-summary-large-working-set-size-threshold", cl::Hidden,

53 cl::desc("The code working set size is considered large if the number of"

54 " blocks required to reach the -profile-summary-cutoff-hot"

55 " percentile exceeds this count."));

56

57

58

61 cl::desc("A fixed hot count that overrides the count derived from"

62 " profile-summary-cutoff-hot"));

63

66 cl::desc("A fixed cold count that overrides the count derived from"

67 " profile-summary-cutoff-cold"));

68}

69

70

71

73 10000,

74 100000,

75 200000, 300000, 400000, 500000, 600000, 700000, 800000,

76 900000, 950000, 990000, 999000, 999900, 999990, 999999};

79

80

81

82

83

85

89 if (Percentile == 0)

91

93 return Entry.Cutoff < Percentile;

94 });

95

96

97 if (It == DS.end())

99 return *It;

100}

101

103

104

105

106

107

109 return;

110

112 for (size_t I = 1, E = R.Counts.size(); I < E; ++I)

114}

115

116

117

120 if (!isCallsiteSample) {

124 } else if (FS.getContext().hasAttribute(

126

127

128 return;

129 }

130

131 for (const auto &I : FS.getBodySamples()) {

134 }

135 for (const auto &I : FS.getCallsiteSamples())

136 for (const auto &CS : I.second)

138}

139

140

141

143 if (DetailedSummaryCutoffs.empty())

144 return;

146 auto Iter = CountFrequencies.begin();

147 const auto End = CountFrequencies.end();

148

151

152 for (const uint32_t Cutoff : DetailedSummaryCutoffs) {

153 assert(Cutoff <= 999999);

155 APInt N(128, Cutoff);

157 Temp *= N;

158 Temp = Temp.sdiv(D);

161 while (CurrSum < DesiredCount && Iter != End) {

162 Count = Iter->first;

163 uint32_t Freq = Iter->second;

164 CurrSum += (Count * Freq);

165 CountsSeen += Freq;

166 Iter++;

167 }

168 assert(CurrSum >= DesiredCount);

171 }

172}

173

176 auto &HotEntry =

178 uint64_t HotCountThreshold = HotEntry.MinCount;

181 return HotCountThreshold;

182}

183

193

196 return std::make_unique(

199}

200

201std::unique_ptr

205 "This can only be called on an empty summary builder");

208

209

210

211

212

213

217 ProfilesToUse = &ContextLessProfiles;

218 }

219

220 for (const auto &I : *ProfilesToUse) {

223 }

224

226}

227

230 return std::make_unique(

233}

234

237 "Count value should be less than the max count value.");

242}

243

246 "Count value should be less than the max count value.");

248 if (Count > MaxInternalBlockCount)

249 MaxInternalBlockCount = Count;

250}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")

static cl::opt< unsigned > ColdCountThreshold("mfs-count-threshold", cl::desc("Minimum number of times a block must be executed to be retained."), cl::init(1), cl::Hidden)

static const ProfileSummaryEntry ZeroCutoffEntry

Definition ProfileSummaryBuilder.cpp:84

static const uint32_t DefaultCutoffsData[]

Definition ProfileSummaryBuilder.cpp:72

Class for arbitrary precision integers.

uint64_t getZExtValue() const

Get zero extended value.

LLVM_ABI APInt sdiv(const APInt &RHS) const

Signed division function for APInt.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

LLVM_ABI void addInternalCount(uint64_t Count)

Definition ProfileSummaryBuilder.cpp:244

LLVM_ABI std::unique_ptr< ProfileSummary > getSummary()

Definition ProfileSummaryBuilder.cpp:228

LLVM_ABI void addRecord(const InstrProfRecord &)

Definition ProfileSummaryBuilder.cpp:102

LLVM_ABI void addEntryCount(uint64_t Count)

Definition ProfileSummaryBuilder.cpp:235

LLVM_ABI void computeDetailedSummary()

Definition ProfileSummaryBuilder.cpp:142

void addCount(uint64_t Count)

This is called when a count is seen in the profile.

static LLVM_ABI const ProfileSummaryEntry & getEntryForPercentile(const SummaryEntryVector &DS, uint64_t Percentile)

Find the summary entry for a desired percentile of counts.

Definition ProfileSummaryBuilder.cpp:87

uint64_t MaxFunctionCount

static LLVM_ABI const ArrayRef< uint32_t > DefaultCutoffs

A vector of useful cutoff values for detailed summary.

SummaryEntryVector DetailedSummary

static LLVM_ABI uint64_t getHotCountThreshold(const SummaryEntryVector &DS)

Definition ProfileSummaryBuilder.cpp:175

static LLVM_ABI uint64_t getColdCountThreshold(const SummaryEntryVector &DS)

Definition ProfileSummaryBuilder.cpp:185

LLVM_ABI std::unique_ptr< ProfileSummary > getSummary()

Definition ProfileSummaryBuilder.cpp:194

LLVM_ABI std::unique_ptr< ProfileSummary > computeSummaryForProfiles(const sampleprof::SampleProfileMap &Profiles)

Definition ProfileSummaryBuilder.cpp:202

LLVM_ABI void addRecord(const sampleprof::FunctionSamples &FS, bool isCallsiteSample=false)

Definition ProfileSummaryBuilder.cpp:118

Representation of the samples collected for a function.

static LLVM_ABI bool ProfileIsCS

static void flattenProfile(SampleProfileMap &ProfileMap, bool ProfileIsCS=false)

This class provides operator overloads to the map container using MD5 as the key type,...

initializer< Ty > init(const Ty &Val)

@ ContextDuplicatedIntoBase

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI cl::opt< uint64_t > ProfileSummaryHotCount

auto partition_point(R &&Range, Predicate P)

Binary search for the first iterator in a range where a predicate is false.

LLVM_ABI cl::opt< bool > UseContextLessSummary

LLVM_ABI cl::opt< uint64_t > ProfileSummaryColdCount

uint64_t getInstrMaxCountValue()

Return the max count value. We reserver a few large values for special use.

void sort(IteratorTy Start, IteratorTy End)

LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)

FunctionAddr VTableAddr Count

LLVM_ABI cl::opt< int > ProfileSummaryCutoffCold

LLVM_ABI cl::opt< unsigned > ProfileSummaryLargeWorkingSetSizeThreshold

LLVM_ABI cl::opt< int > ProfileSummaryCutoffHot

std::vector< ProfileSummaryEntry > SummaryEntryVector

LLVM_ABI cl::opt< unsigned > ProfileSummaryHugeWorkingSetSizeThreshold

Profiling information for a single function.