File tree Expand file tree Collapse file tree 4 files changed +22
-4
lines changed Expand file tree Collapse file tree 4 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 16
16
#include " bolt/Core/BinaryContext.h"
17
17
#include " bolt/Core/BinaryFunction.h"
18
18
#include " bolt/Core/DynoStats.h"
19
+ #include " bolt/Profile/BoltAddressTranslation.h"
19
20
#include " llvm/Support/CommandLine.h"
20
21
#include < atomic>
21
22
#include < set>
@@ -399,8 +400,11 @@ class PrintProfileStats : public BinaryFunctionPass {
399
400
// / Prints a list of the top 100 functions sorted by a set of
400
401
// / dyno stats categories.
401
402
class PrintProgramStats : public BinaryFunctionPass {
403
+ BoltAddressTranslation *BAT = nullptr ;
404
+
402
405
public:
403
- explicit PrintProgramStats () : BinaryFunctionPass(false ) {}
406
+ explicit PrintProgramStats (BoltAddressTranslation *BAT = nullptr )
407
+ : BinaryFunctionPass(false ), BAT(BAT) {}
404
408
405
409
const char *getName () const override { return " print-stats" ; }
406
410
bool shouldPrint (const BinaryFunction &) const override { return false ; }
Original file line number Diff line number Diff line change @@ -1390,9 +1390,19 @@ Error PrintProgramStats::runOnFunctions(BinaryContext &BC) {
1390
1390
if (Function.isPLTFunction ())
1391
1391
continue ;
1392
1392
1393
+ // Adjustment for BAT mode: the profile for BOLT split fragments is combined
1394
+ // so only count the hot fragment.
1395
+ const uint64_t Address = Function.getAddress ();
1396
+ bool IsHotParentOfBOLTSplitFunction = !Function.getFragments ().empty () &&
1397
+ BAT && BAT->isBATFunction (Address) &&
1398
+ !BAT->fetchParentAddress (Address);
1399
+
1393
1400
++NumRegularFunctions;
1394
1401
1395
- if (!Function.isSimple ()) {
1402
+ // In BOLTed binaries split functions are non-simple (due to non-relocation
1403
+ // mode), but the original function is known to be simple and we have a
1404
+ // valid profile for it.
1405
+ if (!Function.isSimple () && !IsHotParentOfBOLTSplitFunction) {
1396
1406
if (Function.hasProfile ())
1397
1407
++NumNonSimpleProfiledFunctions;
1398
1408
continue ;
Original file line number Diff line number Diff line change @@ -613,7 +613,8 @@ Error DataAggregator::readProfile(BinaryContext &BC) {
613
613
if (std::error_code EC = writeBATYAML (BC, opts::SaveProfile))
614
614
report_error (" cannot create output data file" , EC);
615
615
}
616
- BC.logBOLTErrorsAndQuitOnFatal (PrintProgramStats ().runOnFunctions (BC));
616
+ PrintProgramStats PPS (BAT);
617
+ BC.logBOLTErrorsAndQuitOnFatal (PPS.runOnFunctions (BC));
617
618
}
618
619
619
620
return Error::success ();
Original file line number Diff line number Diff line change @@ -31,7 +31,8 @@ RUN: perf2bolt %t.out --pa -p %p/Inputs/blarge_new_bat.preagg.txt -w %t.yaml -o
31
31
RUN: 2>&1 | FileCheck --check-prefix READ-BAT-CHECK %s
32
32
RUN: FileCheck --input-file %t.yaml --check-prefix YAML-BAT-CHECK %s
33
33
# Check that YAML converted from fdata matches YAML created directly with BAT.
34
- RUN: llvm-bolt %t.exe -data %t.fdata -w %t.yaml-fdata -o /dev/null
34
+ RUN: llvm-bolt %t.exe -data %t.fdata -w %t.yaml-fdata -o /dev/null \
35
+ RUN: 2>&1 | FileCheck --check-prefix READ-BAT-FDATA-CHECK %s
35
36
RUN: FileCheck --input-file %t.yaml-fdata --check-prefix YAML-BAT-CHECK %s
36
37
37
38
# Test resulting YAML profile with the original binary (no-stale mode)
@@ -45,6 +46,8 @@ WRITE-BAT-CHECK: BOLT-INFO: BAT section size (bytes): 384
45
46
READ-BAT-CHECK-NOT: BOLT-ERROR: unable to save profile in YAML format for input file processed by BOLT
46
47
READ-BAT-CHECK: BOLT-INFO: Parsed 5 BAT entries
47
48
READ-BAT-CHECK: PERF2BOLT: read 79 aggregated LBR entries
49
+ READ-BAT-CHECK: BOLT-INFO: 5 out of 21 functions in the binary (23.8%) have non-empty execution profile
50
+ READ-BAT-FDATA-CHECK: BOLT-INFO: 5 out of 16 functions in the binary (31.2%) have non-empty execution profile
48
51
49
52
YAML-BAT-CHECK: functions:
50
53
# Function not covered by BAT - has insns in basic block
You can’t perform that action at this time.
0 commit comments