From: Dhruv Chawla <[email protected]>

Forgot the Signed-off-by clause, resending. My apologies.

---- >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 consolidates the file name into
one location at least, so that it is easier to modify later on.

Autoprofilebootstrapped and regtested on aarch64-linux-gnu with SPE.

Signed-off-by: Dhruv Chawla <[email protected]>

ChangeLog:

        * Makefile.in: Regenerate.
        * Makefile.tpl: Pass "perf.data" to gcc-auto-profile. Separate the
        make invocation from perf using "--".

gcc/ChangeLog:

        * config/aarch64/gcc-auto-profile: Replace explicit perf.data
        with perf_file variable.
        * config/i386/gcc-auto-profile: Likewise.
---
 Makefile.in                         | 2 +-
 Makefile.tpl                        | 2 +-
 gcc/config/aarch64/gcc-auto-profile | 9 ++++++---
 gcc/config/i386/gcc-auto-profile    | 7 +++++--
 4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index f34142cc077..fa8e749c395 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.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..47054133d6a 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.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/gcc/config/aarch64/gcc-auto-profile 
b/gcc/config/aarch64/gcc-auto-profile
index 8f7502b30e3..78c0eac29b8 100755
--- a/gcc/config/aarch64/gcc-auto-profile
+++ b/gcc/config/aarch64/gcc-auto-profile
@@ -38,21 +38,24 @@ elif [ "$1" = "--all" ] ; then
   shift
 fi
 
+perf_file="$1"
+shift
+
 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..82411e853f3 100755
--- a/gcc/config/i386/gcc-auto-profile
+++ b/gcc/config/i386/gcc-auto-profile
@@ -24,6 +24,9 @@ if [ "$1" = "--all" ] ; then
   shift
 fi
 
+perf_file="$1"
+shift
+
 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 +120,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

Reply via email to