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 1616#include " bolt/Core/BinaryContext.h"
1717#include " bolt/Core/BinaryFunction.h"
1818#include " bolt/Core/DynoStats.h"
19+ #include " bolt/Profile/BoltAddressTranslation.h"
1920#include " llvm/Support/CommandLine.h"
2021#include < atomic>
2122#include < set>
@@ -399,8 +400,11 @@ class PrintProfileStats : public BinaryFunctionPass {
399400// / Prints a list of the top 100 functions sorted by a set of
400401// / dyno stats categories.
401402class PrintProgramStats : public BinaryFunctionPass {
403+ BoltAddressTranslation *BAT = nullptr ;
404+
402405public:
403- explicit PrintProgramStats () : BinaryFunctionPass(false ) {}
406+ explicit PrintProgramStats (BoltAddressTranslation *BAT = nullptr )
407+ : BinaryFunctionPass(false ), BAT(BAT) {}
404408
405409 const char *getName () const override { return " print-stats" ; }
406410 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) {
13901390 if (Function.isPLTFunction ())
13911391 continue ;
13921392
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+
13931400 ++NumRegularFunctions;
13941401
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) {
13961406 if (Function.hasProfile ())
13971407 ++NumNonSimpleProfiledFunctions;
13981408 continue ;
Original file line number Diff line number Diff line change @@ -613,7 +613,8 @@ Error DataAggregator::readProfile(BinaryContext &BC) {
613613 if (std::error_code EC = writeBATYAML (BC, opts::SaveProfile))
614614 report_error (" cannot create output data file" , EC);
615615 }
616- BC.logBOLTErrorsAndQuitOnFatal (PrintProgramStats ().runOnFunctions (BC));
616+ PrintProgramStats PPS (BAT);
617+ BC.logBOLTErrorsAndQuitOnFatal (PPS.runOnFunctions (BC));
617618 }
618619
619620 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
3131RUN: 2>&1 | FileCheck --check-prefix READ-BAT-CHECK %s
3232RUN: FileCheck --input-file %t.yaml --check-prefix YAML-BAT-CHECK %s
3333# 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
3536RUN: FileCheck --input-file %t.yaml-fdata --check-prefix YAML-BAT-CHECK %s
3637
3738# 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
4546READ-BAT-CHECK-NOT: BOLT-ERROR: unable to save profile in YAML format for input file processed by BOLT
4647READ-BAT-CHECK: BOLT-INFO: Parsed 5 BAT entries
4748READ-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
4851
4952YAML-BAT-CHECK: functions:
5053# Function not covered by BAT - has insns in basic block
You can’t perform that action at this time.
0 commit comments