Skip to content

Commit c480dcd

Browse files
authored
[BOLT][NFC] Move LBREntry from DataReader to DataAggregator (#143287)
LBREntry is only used in DataAggregator. Test Plan: NFC
1 parent 4fbf67f commit c480dcd

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ class DataAggregator : public DataReader {
7878
static bool checkPerfDataMagic(StringRef FileName);
7979

8080
private:
81+
struct LBREntry {
82+
uint64_t From;
83+
uint64_t To;
84+
bool Mispred;
85+
};
86+
friend raw_ostream &operator<<(raw_ostream &OS, const LBREntry &);
87+
8188
struct PerfBranchSample {
8289
SmallVector<LBREntry, 32> LBR;
8390
};
@@ -476,7 +483,6 @@ class DataAggregator : public DataReader {
476483

477484
/// Debugging dump methods
478485
void dump() const;
479-
void dump(const LBREntry &LBR) const;
480486
void dump(const PerfBranchSample &Sample) const;
481487
void dump(const PerfMemSample &Sample) const;
482488

@@ -504,6 +510,12 @@ class DataAggregator : public DataReader {
504510

505511
friend class YAMLProfileWriter;
506512
};
513+
514+
inline raw_ostream &operator<<(raw_ostream &OS,
515+
const DataAggregator::LBREntry &L) {
516+
OS << formatv("{0:x} -> {1:x}/{2}", L.From, L.To, L.Mispred ? 'M' : 'P');
517+
return OS;
518+
}
507519
} // namespace bolt
508520
} // namespace llvm
509521

bolt/include/bolt/Profile/DataReader.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@ namespace bolt {
3232

3333
class BinaryFunction;
3434

35-
struct LBREntry {
36-
uint64_t From;
37-
uint64_t To;
38-
bool Mispred;
39-
};
40-
41-
inline raw_ostream &operator<<(raw_ostream &OS, const LBREntry &LBR) {
42-
OS << "0x" << Twine::utohexstr(LBR.From) << " -> 0x"
43-
<< Twine::utohexstr(LBR.To);
44-
return OS;
45-
}
46-
4735
struct Location {
4836
bool IsSymbol;
4937
StringRef Name;

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ bool DataAggregator::recordExit(BinaryFunction &BF, uint64_t From, bool Mispred,
972972
return true;
973973
}
974974

975-
ErrorOr<LBREntry> DataAggregator::parseLBREntry() {
975+
ErrorOr<DataAggregator::LBREntry> DataAggregator::parseLBREntry() {
976976
LBREntry Res;
977977
ErrorOr<StringRef> FromStrRes = parseString('/');
978978
if (std::error_code EC = FromStrRes.getError())
@@ -2398,16 +2398,10 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
23982398

23992399
void DataAggregator::dump() const { DataReader::dump(); }
24002400

2401-
void DataAggregator::dump(const LBREntry &LBR) const {
2402-
Diag << "From: " << Twine::utohexstr(LBR.From)
2403-
<< " To: " << Twine::utohexstr(LBR.To) << " Mispred? " << LBR.Mispred
2404-
<< "\n";
2405-
}
2406-
24072401
void DataAggregator::dump(const PerfBranchSample &Sample) const {
24082402
Diag << "Sample LBR entries: " << Sample.LBR.size() << "\n";
24092403
for (const LBREntry &LBR : Sample.LBR)
2410-
dump(LBR);
2404+
Diag << LBR << '\n';
24112405
}
24122406

24132407
void DataAggregator::dump(const PerfMemSample &Sample) const {

0 commit comments

Comments
 (0)