@@ -126,9 +126,8 @@ void printCFGContinuityStats(raw_ostream &OS,
126126 const unsigned BBIndex = Queue.front ();
127127 const BinaryBasicBlock *BB = Layout.getBlock (BBIndex);
128128 Queue.pop ();
129- for (const auto &Tuple : llvm::zip (BB->successors (), BB->branch_info ())) {
130- const auto *Succ = std::get<0 >(Tuple);
131- const auto &BI = std::get<1 >(Tuple);
129+ for (const auto &[Succ, BI] :
130+ llvm::zip (BB->successors (), BB->branch_info ())) {
132131 const uint64_t Count = BI.Count ;
133132 if (Count == BinaryBasicBlock::COUNT_NO_PROFILE || Count == 0 ||
134133 !Visited.insert (Succ->getLayoutIndex ()).second )
@@ -272,7 +271,9 @@ void printCFGFlowConservationStats(raw_ostream &OS,
272271 std::vector<double > CFGGapsWeightedAvg;
273272 std::vector<double > CFGGapsWorst;
274273 std::vector<uint64_t > CFGGapsWorstAbs;
275-
274+ // We only consider blocks with execution counts > MinBlockCount when
275+ // reporting the distribution of worst gaps.
276+ const uint16_t MinBlockCount = 500 ;
276277 for (const BinaryFunction *Function : Functions) {
277278 if (Function->size () <= 1 || !Function->isSimple ())
278279 continue ;
@@ -305,11 +306,12 @@ void printCFGFlowConservationStats(raw_ostream &OS,
305306 Weight = log (Weight);
306307 WeightedGapSum += Gap * Weight;
307308 WeightSum += Weight;
308- if (BB.getKnownExecutionCount () > 500 && Gap > WorstGap) {
309+ if (BB.getKnownExecutionCount () > MinBlockCount && Gap > WorstGap) {
309310 WorstGap = Gap;
310311 BBWorstGap = &BB;
311312 }
312- if (BB.getKnownExecutionCount () > 500 && Max - Min > WorstGapAbs) {
313+ if (BB.getKnownExecutionCount () > MinBlockCount &&
314+ Max - Min > WorstGapAbs) {
313315 WorstGapAbs = Max - Min;
314316 BBWorstGapAbs = &BB;
315317 }
@@ -351,7 +353,8 @@ void printCFGFlowConservationStats(raw_ostream &OS,
351353 if (opts::Verbosity >= 1 ) {
352354 OS << " distribution of weighted CFG flow conservation gaps\n " ;
353355 printDistribution (OS, CFGGapsWeightedAvg, /* Fraction=*/ true );
354- OS << " Consider only blocks with execution counts > 500:\n "
356+ OS << format (" Consider only blocks with execution counts > %zu:\n " ,
357+ MinBlockCount)
355358 << " distribution of worst block flow conservation gap per "
356359 " function \n " ;
357360 printDistribution (OS, CFGGapsWorst, /* Fraction=*/ true );
@@ -379,9 +382,8 @@ void computeFlowMappings(const BinaryContext &BC, FlowInfo &TotalFlowMap) {
379382 continue ;
380383 for (const BinaryBasicBlock &BB : *Function) {
381384 uint64_t TotalOutgoing = 0ULL ;
382- for (const auto &Tuple : llvm::zip (BB.successors (), BB.branch_info ())) {
383- const auto *Succ = std::get<0 >(Tuple);
384- const auto &BI = std::get<1 >(Tuple);
385+ for (const auto &[Succ, BI] :
386+ llvm::zip (BB.successors (), BB.branch_info ())) {
385387 const uint64_t Count = BI.Count ;
386388 if (Count == BinaryBasicBlock::COUNT_NO_PROFILE || Count == 0 )
387389 continue ;
0 commit comments