[llvm] [BOLT]Improve profile quality reporting (PR #130810)
Amir Ayupov via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 7 11:33:15 PDT 2025
================
@@ -365,6 +396,74 @@ void printCFGFlowConservationStats(raw_ostream &OS,
}
}
+void printExceptionHandlingStats(const BinaryContext &BC, raw_ostream &OS,
+ iterator_range<function_iterator> &Functions) {
+ std::vector<double> LPCountFractionsOfTotalBBEC;
+ std::vector<double> LPCountFractionsOfTotalInvokeEC;
+ for (const BinaryFunction *Function : Functions) {
+ size_t LPECSum = 0;
+ size_t BBECSum = 0;
+ size_t InvokeECSum = 0;
+ for (BinaryBasicBlock &BB : *Function) {
+ const size_t BBEC = BB.getKnownExecutionCount();
+ BBECSum += BBEC;
+ if (BB.isLandingPad())
+ LPECSum += BBEC;
+ for (const MCInst &Inst : BB) {
+ if (!BC.MIB->isCall(Inst))
+ continue;
+ if (BC.MIB->isInvoke(Inst)) {
+ const std::optional<MCPlus::MCLandingPad> EHInfo =
+ BC.MIB->getEHInfo(Inst);
+ if (EHInfo->first)
+ InvokeECSum += BBEC;
+ }
+ }
+ }
+ // We only consider functions with at least MinLPECSum counts in landing
+ // pads to avoid false positives due to sampling noise
+ const uint16_t MinLPECSum = 50;
----------------
aaupov wrote:
Move out to the header or the beginning of this file as a constant?
https://github.com/llvm/llvm-project/pull/130810
More information about the llvm-commits
mailing list