@@ -52,6 +52,16 @@ struct FlowInfo {
5252 FunctionFlowMapTy CallGraphIncomingFlows;
5353};
5454
55+ // When reporting exception handling stats, we only consider functions with at
56+ // least MinLPECSum counts in landing pads to avoid false positives due to
57+ // sampling noise
58+ const uint16_t MinLPECSum = 50 ;
59+
60+ // When reporting CFG flow conservation stats, we only consider blocks with
61+ // execution counts > MinBlockCount when reporting the distribution of worst
62+ // gaps.
63+ const uint16_t MinBlockCount = 500 ;
64+
5565template <typename T>
5666void printDistribution (raw_ostream &OS, std::vector<T> &values,
5767 bool Fraction = false ) {
@@ -245,7 +255,7 @@ void printCallGraphFlowConservationStats(
245255 const double CallGraphGap = 1 - (double )Min / Max;
246256
247257 if (opts::Verbosity >= 2 && CallGraphGap >= 0.5 ) {
248- OS << " Nontrivial call graph gap of size "
258+ OS << " Non-trivial call graph gap of size "
249259 << formatv (" {0:P}" , CallGraphGap) << " observed in function "
250260 << Function->getPrintName () << " \n " ;
251261 if (opts::Verbosity >= 3 )
@@ -275,9 +285,6 @@ void printCFGFlowConservationStats(const BinaryContext &BC, raw_ostream &OS,
275285 std::vector<double > CFGGapsWeightedAvg;
276286 std::vector<double > CFGGapsWorst;
277287 std::vector<uint64_t > CFGGapsWorstAbs;
278- // We only consider blocks with execution counts > MinBlockCount when
279- // reporting the distribution of worst gaps.
280- const uint16_t MinBlockCount = 500 ;
281288 for (const BinaryFunction *Function : Functions) {
282289 if (Function->size () <= 1 || !Function->isSimple ()) {
283290 CFGGapsWeightedAvg.push_back (0.0 );
@@ -311,14 +318,9 @@ void printCFGFlowConservationStats(const BinaryContext &BC, raw_ostream &OS,
311318 if (BB.isLandingPad ())
312319 continue ;
313320
314- bool HasPosECLP = false ;
315- for (const BinaryBasicBlock *LP : BB.landing_pads ()) {
316- if (LP->getKnownExecutionCount () > 0 ) {
317- HasPosECLP = true ;
318- break ;
319- }
320- }
321- if (HasPosECLP)
321+ auto isPosEC = std::bind (&BinaryBasicBlock::getKnownExecutionCount,
322+ std::placeholders::_1);
323+ if (llvm::any_of (BB.landing_pads (), isPosEC))
322324 continue ;
323325
324326 // We don't consider blocks that end with a recursive call instruction
@@ -354,7 +356,7 @@ void printCFGFlowConservationStats(const BinaryContext &BC, raw_ostream &OS,
354356 if (WeightSum > 0 )
355357 WeightedGap /= WeightSum;
356358 if (opts::Verbosity >= 2 && WorstGap >= 0.9 ) {
357- OS << " Nontrivial CFG gap observed in function "
359+ OS << " Non-trivial CFG gap observed in function "
358360 << Function->getPrintName () << " \n "
359361 << " Weighted gap: " << formatv (" {0:P}" , WeightedGap) << " \n " ;
360362 if (BBWorstGap)
@@ -420,9 +422,7 @@ void printExceptionHandlingStats(const BinaryContext &BC, raw_ostream &OS,
420422 }
421423 }
422424 }
423- // We only consider functions with at least MinLPECSum counts in landing
424- // pads to avoid false positives due to sampling noise
425- const uint16_t MinLPECSum = 50 ;
425+
426426 if (LPECSum <= MinLPECSum) {
427427 LPCountFractionsOfTotalBBEC.push_back (0.0 );
428428 LPCountFractionsOfTotalInvokeEC.push_back (0.0 );
0 commit comments