From: Dhruv Chawla <[email protected]>
Thanks Andi, I was not aware of this script. I have updated it thusly as
well. (The prior incorrect change was mine too...)
--- >8 ---
As a follow up to r16-7956-g2e3d991ea1855d, this patch passes the perf profile
name from Makefile.tpl to the gcc-auto-profile scripts. I initially
wanted to do this via the PERF_DATA make variable, however the
autoprofile stage (which invokes gcc-auto-profile) and the autofeedback
stage (which defines PERF_DATA) don't share the variable definition, so
there was no clean way to do it. This at least consolidates the file name into
one location, so that it is easier to modify later on.
Autoprofilebootstrapped and regtested on aarch64-linux-gnu with SPE.
ChangeLog:
* Makefile.in: Regenerate.
* Makefile.tpl: Pass "--perf perf.data" to gcc-auto-profile. Separate
the make invocation from perf using "--".
contrib/ChangeLog:
* gen_autofdo_event.py: Add missed updates for passing "--inherit" and
"-o $perf_file" to perf.
gcc/ChangeLog:
* config/aarch64/gcc-auto-profile: Replace explicit perf.data
with perf_file variable. Add parsing for "--perf" flag.
* config/i386/gcc-auto-profile: Likewise.
---
Makefile.in | 2 +-
Makefile.tpl | 2 +-
contrib/gen_autofdo_event.py | 10 ++++++++--
gcc/config/aarch64/gcc-auto-profile | 12 +++++++++---
gcc/config/i386/gcc-auto-profile | 10 ++++++++--
5 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index f34142cc077..584705aeb44 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -423,7 +423,7 @@ MAKEINFO = @MAKEINFO@
EXPECT = @EXPECT@
RUNTEST = @RUNTEST@
-AUTO_PROFILE = gcc-auto-profile --all -c 10000000
+AUTO_PROFILE = gcc-auto-profile --all --perf perf.data -c 10000000 --
# This just becomes part of the MAKEINFO definition passed down to
# sub-makes. It lets flags be given on the command line while still
diff --git a/Makefile.tpl b/Makefile.tpl
index 5891b67b697..eb26dc14c55 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -426,7 +426,7 @@ MAKEINFO = @MAKEINFO@
EXPECT = @EXPECT@
RUNTEST = @RUNTEST@
-AUTO_PROFILE = gcc-auto-profile --all -c 10000000
+AUTO_PROFILE = gcc-auto-profile --all --perf perf.data -c 10000000 --
# This just becomes part of the MAKEINFO definition passed down to
# sub-makes. It lets flags be given on the command line while still
diff --git a/contrib/gen_autofdo_event.py b/contrib/gen_autofdo_event.py
index 1fcea0a6d63..751fbc2ffee 100755
--- a/contrib/gen_autofdo_event.py
+++ b/contrib/gen_autofdo_event.py
@@ -138,6 +138,12 @@ if [ "$1" = "--all" ] ; then
shift
fi
+perf_file="perf.data"
+if [ "$1" = "--perf" ]; then
+ perf_file="$2"
+ shift 2
+fi
+
if grep -q AuthenticAMD /proc/cpuinfo ; then
vendor=AMD
if ! grep -q " brs" /proc/cpuinfo && ! grep -q amd_lbr_v2 /proc/cpuinfo ;
then
@@ -175,14 +181,14 @@ echo >&2 "AMD CPU without support for ex_ret_brn_tkn
event"
fi ;;''')
print(r"esac")
print(r"set -x")
- print(r'if ! perf record -e $E -b "$@" ; then')
+ print(r'if ! perf record --inherit -o "$perf_file" -e $E -b "$@" ; then')
print(r' # PEBS may not actually be working even if the processor
supports it')
print(r' # (e.g., in a virtual machine). Trying to run without /p.')
print(r' set +x')
print(r' echo >&2 "Retrying without /p."')
print(r' E="$(echo "${E}" | sed -e \'s/\/p/\//\ -e s/:p//)"')
print(r' set -x')
- print(r' exec perf record -e $E -b "$@"')
+ print(r' exec perf record --inherit -o "$perf_file" -e $E -b "$@"')
print(r' set +x')
print(r'fi')
diff --git a/gcc/config/aarch64/gcc-auto-profile
b/gcc/config/aarch64/gcc-auto-profile
index 8f7502b30e3..6902ce82a5a 100755
--- a/gcc/config/aarch64/gcc-auto-profile
+++ b/gcc/config/aarch64/gcc-auto-profile
@@ -38,21 +38,27 @@ elif [ "$1" = "--all" ] ; then
shift
fi
+perf_file="perf.data"
+if [ "$1" = "--perf" ]; then
+ perf_file="$2"
+ shift 2
+fi
+
if [ "$use_brbe" = true ] ; then
if grep -q hypervisor /proc/cpuinfo ; then
echo >&2 "Warning: branch profiling may not be functional in VMs"
fi
set -x
- perf record --inherit -o perf.data -j any,$FLAGS "$@"
+ perf record --inherit -o "$perf_file" -j any,$FLAGS "$@"
set +x
elif [ -n "$(perf list | grep arm_spe)" ] ; then
echo >&2 "Info: Using SPE to collect branch profiles"
set -x
- perf record --inherit -o perf.data -e arm_spe_0/branch_filter=1/ "$@"
+ perf record --inherit -o "$perf_file" -e arm_spe_0/branch_filter=1/ "$@"
set +x
else
echo >&2 "Warning: branch profiling may not be functional without BRBE"
set -x
- perf record --inherit -o perf.data "$@"
+ perf record --inherit -o "$perf_file" "$@"
set +x
fi
diff --git a/gcc/config/i386/gcc-auto-profile b/gcc/config/i386/gcc-auto-profile
index c7772a2800f..fc07b20f941 100755
--- a/gcc/config/i386/gcc-auto-profile
+++ b/gcc/config/i386/gcc-auto-profile
@@ -24,6 +24,12 @@ if [ "$1" = "--all" ] ; then
shift
fi
+perf_file="perf.data"
+if [ "$1" = "--perf" ]; then
+ perf_file="$2"
+ shift 2
+fi
+
if grep -q AuthenticAMD /proc/cpuinfo ; then
vendor=AMD
if ! grep -q " brs" /proc/cpuinfo && ! grep -q amd_lbr_v2 /proc/cpuinfo ;
then
@@ -117,13 +123,13 @@ echo >&2 "AMD CPU without support for ex_ret_brn_tkn
event"
fi ;;
esac
set -x
-if ! perf record --inherit -o perf.data -e $E -b "$@" ; then
+if ! perf record --inherit -o "$perf_file" -e $E -b "$@" ; then
# PEBS may not actually be working even if the processor supports it
# (e.g., in a virtual machine). Trying to run without /p.
set +x
echo >&2 "Retrying without /p."
E="$(echo "${E}" | sed -e \'s/\/p/\//\ -e s/:p//)"
set -x
- exec perf record --inherit -o perf.data -e $E -b "$@"
+ exec perf record --inherit -o "$perf_file" -e $E -b "$@"
set +x
fi
--
2.43.0