@@ -861,14 +861,17 @@ bool DataAggregator::doTrace(const LBREntry &First, const LBREntry &Second,
861861 return true ;
862862}
863863
864- bool DataAggregator::recordTrace (
865- BinaryFunction &BF, const LBREntry &FirstLBR, const LBREntry &SecondLBR,
866- uint64_t Count,
867- SmallVector<std::pair<uint64_t , uint64_t >, 16 > &Branches) const {
864+ std::optional<SmallVector<std::pair<uint64_t , uint64_t >, 16 >>
865+ DataAggregator::getFallthroughsInTrace (BinaryFunction &BF,
866+ const LBREntry &FirstLBR,
867+ const LBREntry &SecondLBR,
868+ uint64_t Count) const {
869+ SmallVector<std::pair<uint64_t , uint64_t >, 16 > Branches;
870+
868871 BinaryContext &BC = BF.getBinaryContext ();
869872
870873 if (!BF.isSimple ())
871- return false ;
874+ return std:: nullopt ;
872875
873876 assert (BF.hasCFG () && " can only record traces in CFG state" );
874877
@@ -877,13 +880,13 @@ bool DataAggregator::recordTrace(
877880 const uint64_t To = SecondLBR.From - BF.getAddress ();
878881
879882 if (From > To)
880- return false ;
883+ return std:: nullopt ;
881884
882885 const BinaryBasicBlock *FromBB = BF.getBasicBlockContainingOffset (From);
883886 const BinaryBasicBlock *ToBB = BF.getBasicBlockContainingOffset (To);
884887
885888 if (!FromBB || !ToBB)
886- return false ;
889+ return std:: nullopt ;
887890
888891 // Adjust FromBB if the first LBR is a return from the last instruction in
889892 // the previous block (that instruction should be a call).
@@ -907,7 +910,7 @@ bool DataAggregator::recordTrace(
907910 // within the same basic block, e.g. when two call instructions are in the
908911 // same block. In this case we skip the processing.
909912 if (FromBB == ToBB)
910- return true ;
913+ return Branches ;
911914
912915 // Process blocks in the original layout order.
913916 BinaryBasicBlock *BB = BF.getLayout ().getBlock (FromBB->getIndex ());
@@ -921,7 +924,7 @@ bool DataAggregator::recordTrace(
921924 LLVM_DEBUG (dbgs () << " no fall-through for the trace:\n "
922925 << " " << FirstLBR << ' \n '
923926 << " " << SecondLBR << ' \n ' );
924- return false ;
927+ return std:: nullopt ;
925928 }
926929
927930 const MCInst *Instr = BB->getLastNonPseudoInstr ();
@@ -945,20 +948,7 @@ bool DataAggregator::recordTrace(
945948 BI.Count += Count;
946949 }
947950
948- return true ;
949- }
950-
951- std::optional<SmallVector<std::pair<uint64_t , uint64_t >, 16 >>
952- DataAggregator::getFallthroughsInTrace (BinaryFunction &BF,
953- const LBREntry &FirstLBR,
954- const LBREntry &SecondLBR,
955- uint64_t Count) const {
956- SmallVector<std::pair<uint64_t , uint64_t >, 16 > Res;
957-
958- if (!recordTrace (BF, FirstLBR, SecondLBR, Count, Res))
959- return std::nullopt ;
960-
961- return Res;
951+ return Branches;
962952}
963953
964954bool DataAggregator::recordEntry (BinaryFunction &BF, uint64_t To, bool Mispred,
0 commit comments