@@ -271,13 +271,14 @@ void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) {
271
271
" (.*) ([0-9]+) ([0-9]+)" ;
272
272
Regex FdataRegex (FdataCountersPattern);
273
273
struct CounterTy {
274
- uint64_t Count ;
275
- uint64_t MispredCount ;
276
- CounterTy &operator +(const CounterTy &O) {
277
- Count += O.Count ;
278
- MispredCount += O.MispredCount ;
274
+ uint64_t Exec{ 0 } ;
275
+ uint64_t Mispred{ 0 } ;
276
+ CounterTy &operator += (const CounterTy &O) {
277
+ Exec += O.Exec ;
278
+ Mispred += O.Mispred ;
279
279
return *this ;
280
280
}
281
+ CounterTy operator +(const CounterTy &O) { return *this += O; }
281
282
};
282
283
typedef StringMap<CounterTy> ProfileTy;
283
284
@@ -317,19 +318,18 @@ void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) {
317
318
SmallVector<StringRef> Lines;
318
319
SplitString (Buf, Lines, " \n " );
319
320
for (StringRef Line : Lines) {
320
- CounterTy CurrCount;
321
321
SmallVector<StringRef, 4 > Fields;
322
322
if (!FdataRegex.match (Line, &Fields))
323
323
report_error (Filename, " Malformed / corrupted profile" );
324
324
StringRef Signature = Fields[1 ];
325
- if (Fields[2 ].getAsInteger (10 , CurrCount.MispredCount ))
325
+ CounterTy Count;
326
+ if (Fields[2 ].getAsInteger (10 , Count.Mispred ))
326
327
report_error (Filename, " Malformed / corrupted execution count" );
327
- if (Fields[3 ].getAsInteger (10 , CurrCount. Count ))
328
+ if (Fields[3 ].getAsInteger (10 , Count. Exec ))
328
329
report_error (Filename, " Malformed / corrupted misprediction count" );
329
330
330
- CounterTy Counter = Profile->lookup (Signature);
331
- Counter = Counter + CurrCount;
332
- Profile->insert_or_assign (Signature, Counter);
331
+ Count += Profile->lookup (Signature);
332
+ Profile->insert_or_assign (Signature, Count);
333
333
}
334
334
};
335
335
@@ -354,7 +354,7 @@ void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) {
354
354
if (BoltedCollection.value_or (false ))
355
355
output () << " boltedcollection\n " ;
356
356
for (const auto &[Key, Value] : MergedProfile)
357
- output () << Key << " " << Value.MispredCount << " " << Value.Count << " \n " ;
357
+ output () << Key << " " << Value.Mispred << " " << Value.Exec << " \n " ;
358
358
359
359
errs () << " Profile from " << Filenames.size () << " files merged.\n " ;
360
360
}
0 commit comments