@@ -581,26 +581,6 @@ void DataAggregator::imputeFallThroughs() {
581
581
outs () << " BOLT-INFO: imputed " << InferredTraces << " traces\n " ;
582
582
}
583
583
584
- void DataAggregator::registerProfiledFunctions () {
585
- DenseSet<uint64_t > Addrs;
586
- for (const auto &Trace : llvm::make_first_range (Traces)) {
587
- if (Trace.Branch != Trace::FT_ONLY &&
588
- Trace.Branch != Trace::FT_EXTERNAL_ORIGIN)
589
- Addrs.insert (Trace.Branch );
590
- Addrs.insert (Trace.From );
591
- }
592
-
593
- for (const auto [PC, _] : BasicSamples)
594
- Addrs.insert (PC);
595
-
596
- for (const PerfMemSample &MemSample : MemSamples)
597
- Addrs.insert (MemSample.PC );
598
-
599
- for (const uint64_t Addr : Addrs)
600
- if (BinaryFunction *Func = getBinaryFunctionContainingAddress (Addr))
601
- Func->setHasProfileAvailable ();
602
- }
603
-
604
584
Error DataAggregator::preprocessProfile (BinaryContext &BC) {
605
585
this ->BC = &BC;
606
586
@@ -623,7 +603,6 @@ Error DataAggregator::preprocessProfile(BinaryContext &BC) {
623
603
exit (0 );
624
604
}
625
605
626
- registerProfiledFunctions ();
627
606
return Error::success ();
628
607
}
629
608
@@ -1368,6 +1347,10 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
1368
1347
}
1369
1348
1370
1349
const uint64_t FromOffset = Addr[0 ]->Offset ;
1350
+ BinaryFunction *FromFunc = getBinaryFunctionContainingAddress (FromOffset);
1351
+ if (FromFunc)
1352
+ FromFunc->setHasProfileAvailable ();
1353
+
1371
1354
int64_t Count = Counters[0 ];
1372
1355
int64_t Mispreds = Counters[1 ];
1373
1356
@@ -1378,6 +1361,11 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
1378
1361
return std::error_code ();
1379
1362
}
1380
1363
1364
+ const uint64_t ToOffset = Addr[1 ]->Offset ;
1365
+ BinaryFunction *ToFunc = getBinaryFunctionContainingAddress (ToOffset);
1366
+ if (ToFunc)
1367
+ ToFunc->setHasProfileAvailable ();
1368
+
1381
1369
// / For fall-through types, adjust locations to match Trace container.
1382
1370
if (Type == FT || Type == FT_EXTERNAL_ORIGIN || Type == FT_EXTERNAL_RETURN) {
1383
1371
Addr[2 ] = Location (Addr[1 ]->Offset ); // Trace To
@@ -1625,6 +1613,9 @@ std::error_code DataAggregator::parseBranchEvents() {
1625
1613
Traces.reserve (TraceMap.size ());
1626
1614
for (const auto &[Trace, Info] : TraceMap) {
1627
1615
Traces.emplace_back (Trace, Info);
1616
+ for (const uint64_t Addr : {Trace.Branch , Trace.From })
1617
+ if (BinaryFunction *BF = getBinaryFunctionContainingAddress (Addr))
1618
+ BF->setHasProfileAvailable ();
1628
1619
}
1629
1620
clear (TraceMap);
1630
1621
@@ -1685,6 +1676,9 @@ std::error_code DataAggregator::parseBasicEvents() {
1685
1676
continue ;
1686
1677
++NumTotalSamples;
1687
1678
1679
+ if (BinaryFunction *BF = getBinaryFunctionContainingAddress (Sample->PC ))
1680
+ BF->setHasProfileAvailable ();
1681
+
1688
1682
++BasicSamples[Sample->PC ];
1689
1683
EventNames.insert (Sample->EventName );
1690
1684
}
@@ -1722,6 +1716,9 @@ std::error_code DataAggregator::parseMemEvents() {
1722
1716
if (std::error_code EC = Sample.getError ())
1723
1717
return EC;
1724
1718
1719
+ if (BinaryFunction *BF = getBinaryFunctionContainingAddress (Sample->PC ))
1720
+ BF->setHasProfileAvailable ();
1721
+
1725
1722
MemSamples.emplace_back (std::move (Sample.get ()));
1726
1723
}
1727
1724
0 commit comments