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