From a82502d4a84ea47620c8d57a3bf37f5e6a06d7cd Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Mon, 8 Nov 2021 14:14:35 -0800 Subject: [PATCH] [BOLT][NFC] AsmDump: disable printing of empty profile data Summary: Moved the FDATA printing under the condition of non-empty profile data. The change reduces the assembly dumps. (cherry picked from FBD32262675) --- bolt/lib/Passes/AsmDump.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/bolt/lib/Passes/AsmDump.cpp b/bolt/lib/Passes/AsmDump.cpp index d75f26b649a2..f837a7f54fd9 100644 --- a/bolt/lib/Passes/AsmDump.cpp +++ b/bolt/lib/Passes/AsmDump.cpp @@ -183,9 +183,10 @@ void dumpFunction(const BinaryFunction &BF) { OS << FunctionName << ":\n"; // FDATA for the entry point - OS << "# FDATA: 0 [unknown] 0 " - << "1 " << FunctionName << " 0 " - << "0 " << BF.getKnownExecutionCount() << '\n'; + if (uint64_t EntryExecCount = BF.getKnownExecutionCount()) + OS << "# FDATA: 0 [unknown] 0 " + << "1 " << FunctionName << " 0 " + << "0 " << EntryExecCount << '\n'; // Binary data references from the function. std::unordered_set BDReferences; @@ -202,9 +203,8 @@ void dumpFunction(const BinaryFunction &BF) { for (const MCInst &Instr : *BB) { // Dump pseudo instructions (CFI) if (BC.MIB->isPseudo(Instr)) { - if (BC.MIB->isCFI(Instr)) { + if (BC.MIB->isCFI(Instr)) dumpCFI(BF, Instr, *MAP.get()); - } continue; } @@ -226,22 +226,25 @@ void dumpFunction(const BinaryFunction &BF) { } } - if (&Instr == LastInst && BB->succ_size()) - OS << BranchLabel << ": "; + if (&Instr == LastInst && (BB->succ_size() || IsCall)) + OS << BranchLabel << ":\n"; BC.InstPrinter->printInst(&Instr, 0, "", *BC.STI, OS); OS << '\n'; - // Dump profile data in FDATA format (as parsed by link_fdata.sh). + // Dump profile data in FDATA format (as parsed by link_fdata). if (BC.MIB->getJumpTable(Instr)) dumpJumpTableFdata(OS, BF, Instr, BranchLabel); else if (BC.MIB->isTailCall(Instr)) dumpTailCallFdata(OS, BF, Instr, BranchLabel); } - // Dump profile data in FDATA format (as parsed by link_fdata.sh). + // Dump profile data in FDATA format (as parsed by link_fdata). for (const BinaryBasicBlock *Succ : BB->successors()) { const BinaryBasicBlock::BinaryBranchInfo BI = BB->getBranchInfo(*Succ); + if (!BI.MispredictedCount && !BI.Count) + continue; + OS << "# FDATA: 1 " << FunctionName << " #" << BranchLabel << "# " << "1 " << FunctionName << " #" << Succ->getName() << "# " << BI.MispredictedCount << " " << BI.Count << '\n';