@@ -90,13 +90,7 @@ struct BranchInfo {
9090 }
9191
9292 bool operator <(const BranchInfo &RHS) const {
93- if (From < RHS.From )
94- return true ;
95-
96- if (From == RHS.From )
97- return (To < RHS.To );
98-
99- return false ;
93+ return std::tie (From, To) < std::tie (RHS.From , RHS.To );
10094 }
10195
10296 // / Merges branch and misprediction counts of \p BI with those of this object.
@@ -218,15 +212,16 @@ struct FuncMemData {
218212// / Similar to BranchInfo, but instead of recording from-to address (an edge),
219213// / it records the address of a perf event and the number of times samples hit
220214// / this address.
221- struct SampleInfo {
215+ struct BasicSampleInfo {
222216 Location Loc;
223217 int64_t Hits;
224218
225- SampleInfo (Location Loc, int64_t Hits) : Loc(std::move(Loc)), Hits(Hits) {}
219+ BasicSampleInfo (Location Loc, int64_t Hits)
220+ : Loc(std::move(Loc)), Hits(Hits) {}
226221
227- bool operator ==(const SampleInfo &RHS) const { return Loc == RHS.Loc ; }
222+ bool operator ==(const BasicSampleInfo &RHS) const { return Loc == RHS.Loc ; }
228223
229- bool operator <(const SampleInfo &RHS) const {
224+ bool operator <(const BasicSampleInfo &RHS) const {
230225 if (Loc < RHS.Loc )
231226 return true ;
232227
@@ -235,23 +230,26 @@ struct SampleInfo {
235230
236231 void print (raw_ostream &OS) const ;
237232
238- void mergeWith (const SampleInfo &SI);
233+ void mergeWith (const BasicSampleInfo &SI);
239234};
240235
241236// / Helper class to store samples recorded in the address space of a given
242237// / function, analogous to FuncBranchData but for samples instead of branches.
243- struct FuncSampleData {
244- typedef std::vector<SampleInfo > ContainerTy;
238+ struct FuncBasicSampleData {
239+ typedef std::vector<BasicSampleInfo > ContainerTy;
245240
246241 StringRef Name;
247242 ContainerTy Data;
248243
249- FuncSampleData (StringRef Name, ContainerTy Data)
244+ FuncBasicSampleData (StringRef Name, ContainerTy Data)
250245 : Name(Name), Data(std::move(Data)) {}
251246
252247 // / Get the number of samples recorded in [Start, End)
253248 uint64_t getSamples (uint64_t Start, uint64_t End) const ;
254249
250+ // / Returns the total number of samples recorded in this function.
251+ uint64_t getSamples () const ;
252+
255253 // / Aggregation helper
256254 DenseMap<uint64_t , size_t > Index;
257255
@@ -311,7 +309,7 @@ class DataReader : public ProfileReaderBase {
311309 // / The last step is to infer edge counts based on BB execution count. Note
312310 // / this is the opposite of the LBR way, where we infer BB execution count
313311 // / based on edge counts.
314- void readSampleData (BinaryFunction &BF);
312+ void readBasicSampleData (BinaryFunction &BF);
315313
316314 // / Convert function-level branch data into instruction annotations.
317315 void convertBranchData (BinaryFunction &BF) const ;
@@ -385,7 +383,8 @@ class DataReader : public ProfileReaderBase {
385383 // / Return mem data matching one of the names in \p FuncNames.
386384 FuncMemData *getMemDataForNames (const std::vector<StringRef> &FuncNames);
387385
388- FuncSampleData *getFuncSampleData (const std::vector<StringRef> &FuncNames);
386+ FuncBasicSampleData *
387+ getFuncBasicSampleData (const std::vector<StringRef> &FuncNames);
389388
390389 // / Return a vector of all FuncBranchData matching the list of names.
391390 // / Internally use fuzzy matching to match special names like LTO-generated
@@ -428,7 +427,7 @@ class DataReader : public ProfileReaderBase {
428427 }
429428
430429 using NamesToBranchesMapTy = std::map<StringRef, FuncBranchData>;
431- using NamesToSamplesMapTy = std::map<StringRef, FuncSampleData >;
430+ using NamesToBasicSamplesMapTy = std::map<StringRef, FuncBasicSampleData >;
432431 using NamesToMemEventsMapTy = std::map<StringRef, FuncMemData>;
433432 using FuncsToBranchesMapTy =
434433 std::unordered_map<const BinaryFunction *, FuncBranchData *>;
@@ -477,7 +476,7 @@ class DataReader : public ProfileReaderBase {
477476 return parseLocation (EndChar, EndNl, true );
478477 }
479478 ErrorOr<BranchInfo> parseBranchInfo ();
480- ErrorOr<SampleInfo > parseSampleInfo ();
479+ ErrorOr<BasicSampleInfo > parseSampleInfo ();
481480 ErrorOr<MemInfo> parseMemInfo ();
482481 ErrorOr<bool > maybeParseNoLBRFlag ();
483482 ErrorOr<bool > maybeParseBATFlag ();
@@ -491,7 +490,7 @@ class DataReader : public ProfileReaderBase {
491490 unsigned Line{0 };
492491 unsigned Col{0 };
493492 NamesToBranchesMapTy NamesToBranches;
494- NamesToSamplesMapTy NamesToSamples ;
493+ NamesToBasicSamplesMapTy NamesToBasicSamples ;
495494 NamesToMemEventsMapTy NamesToMemEvents;
496495 FuncsToBranchesMapTy FuncsToBranches;
497496 FuncsToMemDataMapTy FuncsToMemData;
0 commit comments