Skip to content

[BOLT] Support dumping intermediate profile storage from DataAggregator #141897

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions bolt/lib/Profile/DataAggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ static cl::opt<bool>
cl::desc("aggregate basic samples (without LBR info)"),
cl::cat(AggregatorCategory));

extern cl::opt<bool> DumpData;

static cl::opt<std::string>
ITraceAggregation("itrace",
cl::desc("Generate LBR info with perf itrace argument"),
Expand Down Expand Up @@ -586,6 +588,9 @@ void DataAggregator::processProfile(BinaryContext &BC) {
for (auto &MemEvents : NamesToMemEvents)
llvm::stable_sort(MemEvents.second.Data);

if (opts::DumpData)
dump();

// Release intermediate storage.
clear(BranchLBRs);
clear(FallthroughLBRs);
Expand Down
44 changes: 21 additions & 23 deletions bolt/lib/Profile/DataReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ namespace opts {
extern cl::OptionCategory BoltCategory;
extern llvm::cl::opt<unsigned> Verbosity;

static cl::opt<bool>
DumpData("dump-data",
cl::desc("dump parsed bolt data for debugging"),
cl::Hidden,
cl::cat(BoltCategory));
cl::opt<bool> DumpData("dump-data",
cl::desc("dump parsed bolt data for debugging"),
cl::Hidden, cl::cat(BoltCategory));

} // namespace opts

Expand Down Expand Up @@ -1353,35 +1351,35 @@ bool DataReader::hasLocalsWithFileName() const {
}

void DataReader::dump() const {
for (const auto &KV : NamesToBranches) {
const StringRef Name = KV.first;
const FuncBranchData &FBD = KV.second;
Diag << Name << " branches:\n";
for (const BranchInfo &BI : FBD.Data)
for (const auto &[Name, FBD] : NamesToBranches) {
Diag << Name << ": " << FBD.Data.size() << " branches:\n";
size_t Branches = 0;
size_t EntryCount = 1;
for (const BranchInfo &BI : FBD.Data) {
Diag << BI.From.Name << " " << BI.From.Offset << " " << BI.To.Name << " "
<< BI.To.Offset << " " << BI.Mispreds << " " << BI.Branches << "\n";
Diag << Name << " entry points:\n";
for (const BranchInfo &BI : FBD.EntryData)
Branches += BI.Branches;
}
Diag << Name << ": " << FBD.EntryData.size() << " entry points:\n";
for (const BranchInfo &BI : FBD.EntryData) {
Diag << BI.From.Name << " " << BI.From.Offset << " " << BI.To.Name << " "
<< BI.To.Offset << " " << BI.Mispreds << " " << BI.Branches << "\n";
EntryCount += BI.Branches;
}
Diag << Name << " branches/entry: " << 1.0 * Branches / EntryCount << '\n';
}

for (auto I = EventNames.begin(), E = EventNames.end(); I != E; ++I) {
StringRef Event = I->getKey();
for (StringRef Event : EventNames.keys())
Diag << "Data was collected with event: " << Event << "\n";
}
for (const auto &KV : NamesToBasicSamples) {
const StringRef Name = KV.first;
const FuncBasicSampleData &FSD = KV.second;
Diag << Name << " samples:\n";

for (const auto &[Name, FSD] : NamesToBasicSamples) {
Diag << Name << ": " << FSD.Data.size() << " basic samples:\n";
for (const BasicSampleInfo &SI : FSD.Data)
Diag << SI.Loc.Name << " " << SI.Loc.Offset << " " << SI.Hits << "\n";
}

for (const auto &KV : NamesToMemEvents) {
const StringRef Name = KV.first;
const FuncMemData &FMD = KV.second;
Diag << "Memory events for " << Name;
for (const auto &[Name, FMD] : NamesToMemEvents) {
Diag << Name << ": " << FMD.Data.size() << " memory events:\n";
Location LastOffset(0);
for (const MemInfo &MI : FMD.Data) {
if (MI.Offset == LastOffset)
Expand Down
Loading