@@ -564,30 +564,30 @@ void DataAggregator::imputeFallThroughs() {
564564 // Skip fall-throughs in external code.
565565 if (Trace.From == Trace::EXTERNAL)
566566 continue ;
567- std::pair CurrentBranch (Trace.Branch , Trace.From );
567+ if (std::pair CurrentBranch (Trace.Branch , Trace.From );
568+ CurrentBranch != PrevBranch) {
569+ // New group: reset aggregates.
570+ AggregateCount = AggregateFallthroughSize = 0 ;
571+ PrevBranch = CurrentBranch;
572+ }
568573 // BR_ONLY must be the last trace in the group
569574 if (Trace.To == Trace::BR_ONLY) {
570575 // If the group is not empty, use aggregate values, otherwise 0-length
571576 // for unconditional jumps (call/ret/uncond branch) or 1-length for others
572577 uint64_t InferredBytes =
573- PrevBranch == CurrentBranch
578+ AggregateFallthroughSize
574579 ? AggregateFallthroughSize / AggregateCount
575580 : !checkUnconditionalControlTransfer (Trace.From );
576581 Trace.To = Trace.From + InferredBytes;
577582 LLVM_DEBUG (dbgs () << " imputed " << Trace << " (" << InferredBytes
578583 << " bytes)\n " );
579584 ++InferredTraces;
580585 } else {
581- // Trace with a valid fall-through
582- // New group: reset aggregates.
583- if (CurrentBranch != PrevBranch)
584- AggregateCount = AggregateFallthroughSize = 0 ;
585586 // Only use valid fall-through lengths
586587 if (Trace.To != Trace::EXTERNAL)
587588 AggregateFallthroughSize += (Trace.To - Trace.From ) * Info.TakenCount ;
588589 AggregateCount += Info.TakenCount ;
589590 }
590- PrevBranch = CurrentBranch;
591591 }
592592 if (opts::Verbosity >= 1 )
593593 outs () << " BOLT-INFO: imputed " << InferredTraces << " traces\n " ;
0 commit comments