Skip to content

[BOLT][NFC] Move LBREntry from DataReader to DataAggregator #143287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion bolt/include/bolt/Profile/DataAggregator.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ class DataAggregator : public DataReader {
static bool checkPerfDataMagic(StringRef FileName);

private:
struct LBREntry {
uint64_t From;
uint64_t To;
bool Mispred;
};
friend raw_ostream &operator<<(raw_ostream &OS, const LBREntry &);

struct PerfBranchSample {
SmallVector<LBREntry, 32> LBR;
};
Expand Down Expand Up @@ -476,7 +483,6 @@ class DataAggregator : public DataReader {

/// Debugging dump methods
void dump() const;
void dump(const LBREntry &LBR) const;
void dump(const PerfBranchSample &Sample) const;
void dump(const PerfMemSample &Sample) const;

Expand Down Expand Up @@ -504,6 +510,12 @@ class DataAggregator : public DataReader {

friend class YAMLProfileWriter;
};

inline raw_ostream &operator<<(raw_ostream &OS,
const DataAggregator::LBREntry &L) {
OS << formatv("{0:x} -> {1:x}/{2}", L.From, L.To, L.Mispred ? 'M' : 'P');
return OS;
}
} // namespace bolt
} // namespace llvm

Expand Down
12 changes: 0 additions & 12 deletions bolt/include/bolt/Profile/DataReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,6 @@ namespace bolt {

class BinaryFunction;

struct LBREntry {
uint64_t From;
uint64_t To;
bool Mispred;
};

inline raw_ostream &operator<<(raw_ostream &OS, const LBREntry &LBR) {
OS << "0x" << Twine::utohexstr(LBR.From) << " -> 0x"
<< Twine::utohexstr(LBR.To);
return OS;
}

struct Location {
bool IsSymbol;
StringRef Name;
Expand Down
10 changes: 2 additions & 8 deletions bolt/lib/Profile/DataAggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ bool DataAggregator::recordExit(BinaryFunction &BF, uint64_t From, bool Mispred,
return true;
}

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

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

void DataAggregator::dump(const LBREntry &LBR) const {
Diag << "From: " << Twine::utohexstr(LBR.From)
<< " To: " << Twine::utohexstr(LBR.To) << " Mispred? " << LBR.Mispred
<< "\n";
}

void DataAggregator::dump(const PerfBranchSample &Sample) const {
Diag << "Sample LBR entries: " << Sample.LBR.size() << "\n";
for (const LBREntry &LBR : Sample.LBR)
dump(LBR);
Diag << LBR << '\n';
}

void DataAggregator::dump(const PerfMemSample &Sample) const {
Expand Down
Loading