---
gcc/Makefile.in | 2 +-
gcc/auto-profile.cc | 1 -
gcc/auto-profile.h | 2 ++
gcc/c/Make-lang.in | 6 +++---
gcc/common.opt | 6 ++++++
gcc/cp/Make-lang.in | 6 +++---
gcc/doc/invoke.texi | 7 +++++++
gcc/gcc.cc | 8 ++++++++
gcc/lto/Make-lang.in | 6 +++---
gcc/testsuite/lib/profopt.exp | 5 ++++-
10 files changed, 37 insertions(+), 12 deletions(-)
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 9e8da255186..6da805fbb62 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -4818,7 +4818,7 @@ paranoia: paranoia.o real.o $(LIBIBERTY)
g++ -o $@ paranoia.o real.o $(LIBIBERTY)
all.fda: $(ALL_FDAS)
- $(PROFILE_MERGER) $(ALL_FDAS) --output_file all.fda -gcov_version 3
+ $(PROFILE_MERGER) $(ALL_FDAS) --output_file all.fda -gcov_version
`../stage1-gcc/xgcc$(exeext) --print-autofdo-gcov-version`
# These exist for maintenance purposes.
diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc
index b448565376d..34f863a7731 100644
--- a/gcc/auto-profile.cc
+++ b/gcc/auto-profile.cc
@@ -122,7 +122,6 @@ along with GCC; see the file COPYING3. If not see
*/
#define DEFAULT_AUTO_PROFILE_FILE "fbdata.afdo"
-#define AUTO_PROFILE_VERSION 3
/* profile counts determined by AFDO smaller than afdo_hot_bb_threshold are
considered cols. */
diff --git a/gcc/auto-profile.h b/gcc/auto-profile.h
index d971401238e..2685a1453c5 100644
--- a/gcc/auto-profile.h
+++ b/gcc/auto-profile.h
@@ -21,6 +21,8 @@ along with GCC; see the file COPYING3. If not see
#ifndef AUTO_PROFILE_H
#define AUTO_PROFILE_H
+#define AUTO_PROFILE_VERSION 3
+
/* Read, process, finalize AutoFDO data structures. */
extern void read_autofdo_file (void);
extern void end_auto_profile (void);
diff --git a/gcc/c/Make-lang.in b/gcc/c/Make-lang.in
index fd127caba91..313bba88835 100644
--- a/gcc/c/Make-lang.in
+++ b/gcc/c/Make-lang.in
@@ -93,7 +93,7 @@ components_in_prev = "bfd opcodes binutils fixincludes gas
gcc gmp mpfr mpc isl
components_in_prev_target = "libstdc++-v3 libsanitizer libvtv libgcc libbacktrace
libphobos zlib libgomp libatomic"
cc1.fda: create_fdas_for_cc1
- $(PROFILE_MERGER) $(shell ls -ha cc1_*.fda) --output_file cc1.fda
-gcov_version 3
+ $(PROFILE_MERGER) $(shell ls -ha cc1_*.fda) --output_file cc1.fda
-gcov_version `../stage1-gcc/xgcc$(exeext) --print-autofdo-gcov-version`
create_fdas_for_cc1: ../stage1-gcc/cc1$(exeext) ../prev-gcc/$(PERF_DATA)
for component_in_prev in "$(components_in_prev)"; do \
@@ -102,7 +102,7 @@ create_fdas_for_cc1: ../stage1-gcc/cc1$(exeext)
../prev-gcc/$(PERF_DATA)
echo $$perf_path; \
if [ -f $$perf_path ]; then \
profile_name=cc1_$$component_in_prev.fda; \
- $(CREATE_GCOV) -binary ../stage1-gcc/cc1$(exeext) -gcov
$$profile_name -profile $$perf_path -gcov_version 3 || exit 1; \
+ $(CREATE_GCOV) -binary ../stage1-gcc/cc1$(exeext) -gcov
$$profile_name -profile $$perf_path -gcov_version `../stage1-gcc/xgcc$(exeext)
--print-autofdo-gcov-version` || exit 1; \
fi; \
done;
@@ -112,7 +112,7 @@ create_fdas_for_cc1: ../stage1-gcc/cc1$(exeext)
../prev-gcc/$(PERF_DATA)
echo $$perf_path; \
if [ -f $$perf_path ]; then \
profile_name=cc1_$$component_in_prev_target.fda; \
- $(CREATE_GCOV) -binary ../prev-gcc/cc1$(exeext) -gcov $$profile_name
-profile $$perf_path -gcov_version 3 || exit 1; \
+ $(CREATE_GCOV) -binary ../prev-gcc/cc1$(exeext) -gcov $$profile_name
-profile $$perf_path -gcov_version `../prev-gcc/xgcc$(exeext)
--print-autofdo-gcov-version` || exit 1; \
fi; \
done;
diff --git a/gcc/common.opt b/gcc/common.opt
index 88b79bbf8f5..e46f249e380 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -349,6 +349,9 @@ Driver JoinedOrMissing Alias(B)
-preprocess
Driver Alias(E)
+-print-autofdo-gcov-version
+Driver Alias(print-autofdo-gcov-version)
+
-print-file-name
Driver Separate Alias(print-file-name=)
@@ -3902,6 +3905,9 @@ Driver
pipe
Driver Var(use_pipes)
+print-autofdo-gcov-version
+Driver Var(print_autofdo_gcov_version)
+
print-file-name=
Driver JoinedOrMissing Var(print_file_name)
diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
index 55be730f502..621c53632fc 100644
--- a/gcc/cp/Make-lang.in
+++ b/gcc/cp/Make-lang.in
@@ -210,7 +210,7 @@ components_in_prev = "bfd opcodes binutils fixincludes gas
gcc gmp mpfr mpc isl
components_in_prev_target = "libstdc++-v3 libsanitizer libvtv libgcc libbacktrace
libphobos zlib libgomp libatomic"
cc1plus.fda: create_fdas_for_cc1plus
- $(PROFILE_MERGER) $(shell ls -ha cc1plus_*.fda) --output_file cc1plus.fda
-gcov_version 3
+ $(PROFILE_MERGER) $(shell ls -ha cc1plus_*.fda) --output_file cc1plus.fda
-gcov_version `../stage1-gcc/xgcc$(exeext) --print-autofdo-gcov-version`
create_fdas_for_cc1plus: ../stage1-gcc/cc1plus$(exeext)
../prev-gcc/$(PERF_DATA)
for component_in_prev in "$(components_in_prev)"; do \
@@ -219,7 +219,7 @@ create_fdas_for_cc1plus: ../stage1-gcc/cc1plus$(exeext)
../prev-gcc/$(PERF_DATA)
echo $$perf_path; \
if [ -f $$perf_path ]; then \
profile_name=cc1plus_$$component_in_prev.fda; \
- $(CREATE_GCOV) -binary ../stage1-gcc/cc1plus$(exeext) -gcov
$$profile_name -profile $$perf_path -gcov_version 3 || exit 1; \
+ $(CREATE_GCOV) -binary ../stage1-gcc/cc1plus$(exeext) -gcov
$$profile_name -profile $$perf_path -gcov_version `../stage1-gcc/xgcc$(exeext)
--print-autofdo-gcov-version` || exit 1; \
fi; \
done;
@@ -229,7 +229,7 @@ create_fdas_for_cc1plus: ../stage1-gcc/cc1plus$(exeext)
../prev-gcc/$(PERF_DATA)
echo $$perf_path; \
if [ -f $$perf_path ]; then \
profile_name=cc1plus_$$component_in_prev_target.fda; \
- $(CREATE_GCOV) -binary ../prev-gcc/cc1plus$(exeext) -gcov
$$profile_name -profile $$perf_path -gcov_version 3 || exit 1; \
+ $(CREATE_GCOV) -binary ../prev-gcc/cc1plus$(exeext) -gcov
$$profile_name -profile $$perf_path -gcov_version `../prev-gcc/xgcc$(exeext)
--print-autofdo-gcov-version` || exit 1; \
fi; \
done;
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 60d0b570710..ee5487824aa 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -865,6 +865,7 @@ Objective-C and Objective-C++ Dialects}.
-fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose
-fstats -fstack-usage -ftime-report -ftime-report-details
-fvar-tracking-assignments-toggle -gtoggle
+-print-autofdo-gcov-version
-print-file-name=@var{library} -print-libgcc-file-name
-print-multi-directory -print-multi-lib -print-multi-os-directory
-print-multiarch
@@ -872,6 +873,7 @@ Objective-C and Objective-C++ Dialects}.
-print-sysroot -print-sysroot-headers-suffix
-save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}
--dump=@var{letters}
+--print-autofdo-gcov-version
--print-file-name=@var{library} --print-libgcc-file-file-name
--print-multi-directory --print-multi-lib --print-multi-os-directory
--print-multiarch --print-prog-name=@var{program}
@@ -21027,6 +21029,11 @@ For example, with
@option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
eleventh invocation.
For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
+@opindex print-autofdo-gcov-version
+@item -print-autofdo-gcov-version
+@itemx --print-autofdo-gcov-version
+Print the current version of GCOV being used by the AutoFDO infrastructure.
+
@opindex print-file-name
@item -print-file-name=@var{library}
@itemx --print-file-name=@var{library}
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 065f69c9d8b..aa8e5553982 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -54,6 +54,7 @@ compilation is specified by a string called a "spec". */
#include "common/common-target.h"
#include "gcc-urlifier.h"
#include "opts-diagnostic.h"
+#include "auto-profile.h" /* for AUTO_PROFILE_VERSION. */
#ifndef MATH_LIBRARY
#define MATH_LIBRARY "m"
@@ -4297,6 +4298,7 @@ driver_handle_option (struct gcc_options *opts,
case OPT__no_sysroot_suffix:
case OPT_pass_exit_codes:
case OPT_print_search_dirs:
+ case OPT_print_autofdo_gcov_version:
case OPT_print_file_name_:
case OPT_print_prog_name_:
case OPT_print_multi_lib:
@@ -8830,6 +8832,12 @@ driver::maybe_print_and_exit () const
return (0);
}
+ if (print_autofdo_gcov_version)
+ {
+ printf ("%d\n", AUTO_PROFILE_VERSION);
+ return (0);
+ }
+
if (print_file_name)
{
printf ("%s\n", find_file (print_file_name));
diff --git a/gcc/lto/Make-lang.in b/gcc/lto/Make-lang.in
index eacfe53ca14..3d8c1f55376 100644
--- a/gcc/lto/Make-lang.in
+++ b/gcc/lto/Make-lang.in
@@ -106,7 +106,7 @@ components_in_prev = "bfd opcodes binutils fixincludes gas
gcc gmp mpfr mpc isl
components_in_prev_target = "libstdc++-v3 libsanitizer libvtv libgcc libbacktrace
libphobos zlib libgomp libatomic"
lto1.fda: create_fdas_for_lto1
- $(PROFILE_MERGER) $(shell ls -ha lto1_*.fda) --output_file lto1.fda
-gcov_version 3
+ $(PROFILE_MERGER) $(shell ls -ha lto1_*.fda) --output_file lto1.fda
-gcov_version `../stage1-gcc/xgcc$(exeext) --print-autofdo-gcov-version`
create_fdas_for_lto1: ../stage1-gcc/lto1$(exeext) ../prev-gcc/$(PERF_DATA)
for component_in_prev in "$(components_in_prev)"; do \
@@ -115,7 +115,7 @@ create_fdas_for_lto1: ../stage1-gcc/lto1$(exeext)
../prev-gcc/$(PERF_DATA)
echo $$perf_path; \
if [ -f $$perf_path ]; then \
profile_name=lto1_$$component_in_prev.fda; \
- $(CREATE_GCOV) -binary ../stage1-gcc/lto1$(exeext) -gcov
$$profile_name -profile $$perf_path -gcov_version 3 || exit 1; \
+ $(CREATE_GCOV) -binary ../stage1-gcc/lto1$(exeext) -gcov
$$profile_name -profile $$perf_path -gcov_version `../stage1-gcc/xgcc$(exeext)
--print-autofdo-gcov-version` || exit 1; \
fi; \
done;
@@ -125,7 +125,7 @@ create_fdas_for_lto1: ../stage1-gcc/lto1$(exeext)
../prev-gcc/$(PERF_DATA)
echo $$perf_path; \
if [ -f $$perf_path ]; then \
profile_name=lto1_$$component_in_prev_target.fda; \
- $(CREATE_GCOV) -binary ../prev-gcc/lto1$(exeext) -gcov $$profile_name
-profile $$perf_path -gcov_version 3 || exit 1; \
+ $(CREATE_GCOV) -binary ../prev-gcc/lto1$(exeext) -gcov $$profile_name
-profile $$perf_path -gcov_version `../prev-gcc/xgcc$(exeext)
--print-autofdo-gcov-version` || exit 1; \
fi; \
done;
diff --git a/gcc/testsuite/lib/profopt.exp b/gcc/testsuite/lib/profopt.exp
index c9f5ae53d49..d1266539003 100644
--- a/gcc/testsuite/lib/profopt.exp
+++ b/gcc/testsuite/lib/profopt.exp
@@ -313,6 +313,7 @@ proc profopt-execute { src } {
global verbose
global testname_with_flags
global additional_sources_used
+ global GCC_UNDER_TEST
if ![info exists profile_option] {
error "No profile option specified for first compile."
@@ -453,7 +454,9 @@ proc profopt-execute { src } {
# convert profile
if { $run_autofdo == 1 } {
set bprefix "afdo."
- set cmd "create_gcov --binary $execname1
--profile=$tmpdir/$base.perf.data --gcov_version=3 --gcov=$tmpdir/$bprefix$base.$ext"
+ set compiler [lindex $GCC_UNDER_TEST 0]
+ set autofdo_version [string trim [lindex [remote_exec target
"$compiler --print-autofdo-gcov-version"] 1] ]
+ set cmd "create_gcov --binary $execname1
--profile=$tmpdir/$base.perf.data --gcov_version=$autofdo_version
--gcov=$tmpdir/$bprefix$base.$ext"
verbose "Running $cmd"
set id [remote_spawn "" $cmd]
if { $id < 0 } {
--
2.52.0