Skip to content

Commit 040deec

Browse files
committed
simplify
Created using spr 1.3.4
1 parent cc7cea0 commit 040deec

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

bolt/tools/merge-fdata/merge-fdata.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,14 @@ void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) {
271271
"(.*) ([0-9]+) ([0-9]+)";
272272
Regex FdataRegex(FdataCountersPattern);
273273
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;
279279
return *this;
280280
}
281+
CounterTy operator+(const CounterTy &O) { return *this += O; }
281282
};
282283
typedef StringMap<CounterTy> ProfileTy;
283284

@@ -317,19 +318,18 @@ void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) {
317318
SmallVector<StringRef> Lines;
318319
SplitString(Buf, Lines, "\n");
319320
for (StringRef Line : Lines) {
320-
CounterTy CurrCount;
321321
SmallVector<StringRef, 4> Fields;
322322
if (!FdataRegex.match(Line, &Fields))
323323
report_error(Filename, "Malformed / corrupted profile");
324324
StringRef Signature = Fields[1];
325-
if (Fields[2].getAsInteger(10, CurrCount.MispredCount))
325+
CounterTy Count;
326+
if (Fields[2].getAsInteger(10, Count.Mispred))
326327
report_error(Filename, "Malformed / corrupted execution count");
327-
if (Fields[3].getAsInteger(10, CurrCount.Count))
328+
if (Fields[3].getAsInteger(10, Count.Exec))
328329
report_error(Filename, "Malformed / corrupted misprediction count");
329330

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);
333333
}
334334
};
335335

@@ -354,7 +354,7 @@ void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) {
354354
if (BoltedCollection.value_or(false))
355355
output() << "boltedcollection\n";
356356
for (const auto &[Key, Value] : MergedProfile)
357-
output() << Key << " " << Value.MispredCount << " " << Value.Count << "\n";
357+
output() << Key << " " << Value.Mispred << " " << Value.Exec << "\n";
358358

359359
errs() << "Profile from " << Filenames.size() << " files merged.\n";
360360
}

0 commit comments

Comments
 (0)