Skip to content

Commit 39ea54a

Browse files
authored
gh-160381: Show LLVM profile statistics after PGO training (#160373)
LLVM PGO builds merge the training profiles without showing the profile-count distribution or functions with the hottest basic blocks. Run `llvm-profdata show --detailed-summary --topn=500` after merging to make it easier to compare training workloads. Addresses [astral-sh/python-build-standalone#1033](astral-sh/python-build-standalone#1033) tracking upstreaming of this patch.
1 parent fd8f475 commit 39ea54a

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎Makefile.pre.in‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ GITBRANCH= @GITBRANCH@
5050
PGO_PROF_GEN_FLAG=@PGO_PROF_GEN_FLAG@
5151
PGO_PROF_USE_FLAG=@PGO_PROF_USE_FLAG@
5252
LLVM_PROF_MERGER=@LLVM_PROF_MERGER@
53+
LLVM_PROF_SHOW=@LLVM_PROF_SHOW@
5354
LLVM_PROF_FILE=@LLVM_PROF_FILE@
5455
LLVM_PROF_ERR=@LLVM_PROF_ERR@
5556
DTRACE= @DTRACE@
@@ -857,6 +858,7 @@ profile-run-stamp:
857858
@ # FIXME: can't run for a cross build
858859
$(LLVM_PROF_FILE) $(RUNSHARED) ./$(BUILDPYTHON) $(PROFILE_TASK)
859860
$(LLVM_PROF_MERGER)
861+
$(LLVM_PROF_SHOW)
860862
# Remove profile generation binary since we are done with it.
861863
$(MAKE) clean-retain-profile
862864
# This is an expensive target to build and it does not have proper

‎configure‎

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎configure.ac‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,6 +2292,7 @@ fi
22922292
AC_SUBST([PGO_PROF_GEN_FLAG])
22932293
AC_SUBST([PGO_PROF_USE_FLAG])
22942294
AC_SUBST([LLVM_PROF_MERGER])
2295+
AC_SUBST([LLVM_PROF_SHOW])
22952296
AC_SUBST([LLVM_PROF_FILE])
22962297
AC_SUBST([LLVM_PROF_ERR])
22972298
AC_SUBST([LLVM_PROFDATA])
@@ -2316,6 +2317,7 @@ then
23162317
fi
23172318
fi
23182319
LLVM_PROF_ERR=no
2320+
LLVM_PROF_SHOW=true
23192321

23202322
case "$ac_cv_cc_name" in
23212323
clang|icx)
@@ -2328,6 +2330,10 @@ case "$ac_cv_cc_name" in
23282330
\"\$(shell pwd)\"/*.profclangr
23292331
")
23302332
LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"\$(shell pwd)/code-%p.profclangr\""
2333+
LLVM_PROF_SHOW=m4_normalize("
2334+
${LLVM_PROFDATA} show --detailed-summary --topn=500
2335+
\"\$(shell pwd)/code.profclangd\"
2336+
")
23312337
if test $LLVM_PROF_FOUND = not-found
23322338
then
23332339
LLVM_PROF_ERR=yes

0 commit comments

Comments
 (0)