]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
AutoFDO: Update bootstrap gcov_version to 3 and add testcases
authorDhruv Chawla <dhruvc@nvidia.com>
Thu, 16 Oct 2025 05:17:26 +0000 (22:17 -0700)
committerDhruv Chawla <dhruvc@nvidia.com>
Tue, 23 Dec 2025 05:22:45 +0000 (10:52 +0530)
Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/c/ChangeLog:

* Make-lang.in: Bump GCOV version to 3.

gcc/cp/ChangeLog:

* Make-lang.in: Bump GCOV version to 3.

gcc/lto/ChangeLog:

* Make-lang.in: Bump GCOV version to 3.

gcc/testsuite/ChangeLog:

* lib/profopt.exp: Bump GCOV version to 3.
* gcc.dg/tree-prof/afdo-lto_priv-basic-0.c: New test.
* gcc.dg/tree-prof/afdo-lto_priv-basic-1.c: Likewise.
* gcc.dg/tree-prof/afdo-lto_priv-header-0.c: Likewise.
* gcc.dg/tree-prof/afdo-lto_priv-header-0.h: Likewise.
* gcc.dg/tree-prof/afdo-lto_priv-header-1.c: Likewise.
* gcc.dg/tree-prof/afdo-lto_priv-header-1.h: Likewise.

gcc/c/Make-lang.in
gcc/cp/Make-lang.in
gcc/lto/Make-lang.in
gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-basic-0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-basic-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-0.h [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-1.h [new file with mode: 0644]
gcc/testsuite/lib/profopt.exp

index f09fc99467b90ea9a0f7920828a147030c4581b8..95a7dad83504eaee7d340066d82e451957f5beeb 100644 (file)
@@ -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 2 || exit 1; \
+           $(CREATE_GCOV) -binary ../stage1-gcc/cc1$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 3 || 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 2 || exit 1; \
+           $(CREATE_GCOV) -binary ../prev-gcc/cc1$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 3 || exit 1; \
          fi; \
        done;
 
index 70cfe2b16636ed488161b585afbbe913f6d6f421..20ae96c18ed2957ec3b5bb2358fdbe443a25e37f 100644 (file)
@@ -201,7 +201,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 2 || exit 1; \
+           $(CREATE_GCOV) -binary ../stage1-gcc/cc1plus$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 3 || exit 1; \
          fi; \
        done;
 
@@ -211,7 +211,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 2 || exit 1; \
+           $(CREATE_GCOV) -binary ../prev-gcc/cc1plus$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 3 || exit 1; \
          fi; \
        done;
 
index 2af8bba44ca92c6fdc39b5b902062894f2b18238..a24fa059a7a23dc752fad1c395ee0276a28e2be8 100644 (file)
@@ -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 2 || exit 1; \
+           $(CREATE_GCOV) -binary ../stage1-gcc/lto1$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 3 || 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 2 || exit 1; \
+           $(CREATE_GCOV) -binary ../prev-gcc/lto1$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 3 || exit 1; \
          fi; \
        done;
 
diff --git a/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-basic-0.c b/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-basic-0.c
new file mode 100644 (file)
index 0000000..551e5a8
--- /dev/null
@@ -0,0 +1,47 @@
+/* { dg-require-effective-target lto } */
+/* { dg-additional-sources "afdo-lto_priv-basic-1.c" } */
+/* { dg-options "-O2 -flto -fdump-ipa-afdo" } */
+/* { dg-require-profiling "-fauto-profile" } */ 
+
+#define TRIP 1000000000
+
+/* Check against exported symbols.  */
+__attribute__ ((noinline, noipa)) void effect_1 () {}
+__attribute__ ((noinline, noipa)) void effect_2 () {}
+__attribute__ ((noinline, noipa)) static int foo () { return 5; }
+
+/* Prevent GCC from optimizing the loop.  */
+__attribute__ ((noinline, noipa)) int
+use (int x)
+{
+  volatile int y = x;
+  return x;
+}
+
+extern void global ();
+
+int
+main ()
+{
+  for (int i = 0; i < TRIP; i++)
+    {
+      /* Call only 50% of the time.  */
+      if (use (i) < TRIP / 2)
+       global ();
+
+      if (foo () < 5)
+       /* This function is never called.  */
+       effect_1 ();
+      else
+       effect_2 ();
+    }
+}
+
+/* Check that the annotation actually occurs.  */
+/* { dg-final-use-autofdo { scan-ipa-dump-not "No afdo profile for main" afdo } } */
+/* { dg-final-use-autofdo { scan-ipa-dump-not "No afdo profile for use" afdo } } */
+/* { dg-final-use-autofdo { scan-ipa-dump-not "No afdo profile for foo" afdo } } */
+/* { dg-final-use-autofdo { scan-ipa-dump-not "No afdo profile for effect_2" afdo } } */
+
+/* There should be no collision with effect_1 from afdo-lto_priv-basic-1.c.  */
+/* { dg-final-use-autofdo { scan-ipa-dump "No afdo profile for effect_1" afdo } } */
diff --git a/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-basic-1.c b/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-basic-1.c
new file mode 100644 (file)
index 0000000..38601d1
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-require-effective-target lto } */
+/* { dg-additional-sources "afdo-lto_priv-basic-0.c" } */
+/* { dg-options "-O2 -flto -fdump-ipa-afdo" } */
+/* { dg-require-profiling "-fauto-profile" } */ 
+
+__attribute__((noinline, noipa)) static void do_nothing() {}
+__attribute__((noinline, noipa)) static void effect_1() { do_nothing(); }
+__attribute__((noinline, noipa)) static void effect_2() { do_nothing(); }
+
+void global()
+{
+  effect_1();
+  effect_2();
+}
+
+/* Check that the annotation actually occurs.  */
+/* { dg-final-use-autofdo { scan-ipa-dump-not "No afdo profile for global" afdo } } */
+/* { dg-final-use-autofdo { scan-ipa-dump-not "No afdo profile for effect_2" afdo } } */
+/* { dg-final-use-autofdo { scan-ipa-dump-not "No afdo profile for effect_1" afdo } } */
+/* { dg-final-use-autofdo { scan-ipa-dump-not "No afdo profile for do_nothing" afdo } } */
diff --git a/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-0.c b/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-0.c
new file mode 100644 (file)
index 0000000..b304122
--- /dev/null
@@ -0,0 +1,47 @@
+/* { dg-require-effective-target lto } */
+/* { dg-additional-sources "afdo-lto_priv-header-1.c" } */
+/* { dg-options "-O2 -flto -fdump-ipa-afdo" } */
+/* { dg-require-profiling "-fauto-profile" } */ 
+
+/* Verify that symbols included from headers get their file names set and
+   compared correctly.  */
+
+#define TRIP 1000000000
+
+#include "afdo-lto_priv-header-0.h"
+
+/* Prevent GCC from optimizing the loop.  */
+__attribute__ ((noinline, noipa)) int
+use (int x)
+{
+  volatile int y = x;
+  return x;
+}
+
+extern void global ();
+
+int
+main ()
+{
+  for (int i = 0; i < TRIP; i++)
+    {
+      /* Call only 50% of the time.  */
+      if (use (i) < TRIP / 2)
+       global ();
+
+      if (foo () < 5)
+       /* This function is never called.  */
+       effect_1 ();
+      else
+       effect_2 ();
+    }
+}
+
+/* Check that the annotation actually occurs.  */
+/* { dg-final-use-autofdo { scan-ipa-dump-not "No afdo profile for main" afdo } } */
+/* { dg-final-use-autofdo { scan-ipa-dump-not "No afdo profile for use" afdo } } */
+/* { dg-final-use-autofdo { scan-ipa-dump-not "No afdo profile for foo" afdo } } */
+/* { dg-final-use-autofdo { scan-ipa-dump-not "No afdo profile for effect_2" afdo } } */
+
+/* There should be no collision with effect_1 from afdo-lto_priv-header-1.c.  */
+/* { dg-final-use-autofdo { scan-ipa-dump "No afdo profile for effect_1" afdo } } */
diff --git a/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-0.h b/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-0.h
new file mode 100644 (file)
index 0000000..ee2a14d
--- /dev/null
@@ -0,0 +1,3 @@
+__attribute__ ((noinline, noipa)) static void effect_1 () {}
+__attribute__ ((noinline, noipa)) static void effect_2 () {}
+__attribute__ ((noinline, noipa)) static int foo () { return 5; }
diff --git a/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-1.c b/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-1.c
new file mode 100644 (file)
index 0000000..b9dfe92
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-require-effective-target lto } */
+/* { dg-additional-sources "afdo-lto_priv-header-0.c" } */
+/* { dg-options "-O2 -flto -fdump-ipa-afdo" } */
+/* { dg-require-profiling "-fauto-profile" } */ 
+
+#include "afdo-lto_priv-header-1.h"
+
+void global()
+{
+  effect_1();
+  effect_2();
+}
+
+/* Check that the annotation actually occurs.  */
+/* { dg-final-use-autofdo { scan-ipa-dump-not "No afdo profile for global" afdo } } */
+/* { dg-final-use-autofdo { scan-ipa-dump-not "No afdo profile for effect_2" afdo } } */
+/* { dg-final-use-autofdo { scan-ipa-dump-not "No afdo profile for effect_1" afdo } } */
+/* { dg-final-use-autofdo { scan-ipa-dump-not "No afdo profile for do_nothing" afdo } } */
diff --git a/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-1.h b/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-1.h
new file mode 100644 (file)
index 0000000..249c970
--- /dev/null
@@ -0,0 +1,3 @@
+__attribute__((noinline, noipa)) static void do_nothing() {}
+__attribute__((noinline, noipa)) static void effect_1() { do_nothing(); }
+__attribute__((noinline, noipa)) static void effect_2() { do_nothing(); }
index 81d86c632d17f88f153f5a03f8472de885f0d5ee..0001f6798dd3b11035b14477c9f2cb3c7f94faff 100644 (file)
@@ -452,7 +452,7 @@ 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=2 --gcov=$tmpdir/$bprefix$base.$ext"
+               set cmd "create_gcov --binary $execname1 --profile=$tmpdir/$base.perf.data --gcov_version=3 --gcov=$tmpdir/$bprefix$base.$ext"
                verbose "Running $cmd"
                set id [remote_spawn "" $cmd]
                if { $id < 0 } {