From: Dhruv Chawla <[email protected]>
Signed-off-by: Dhruv Chawla <[email protected]>
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 | 4 +-
gcc/cp/Make-lang.in | 4 +-
gcc/lto/Make-lang.in | 4 +-
.../gcc.dg/tree-prof/afdo-lto_priv-basic-0.c | 47 +++++++++++++++++++
.../gcc.dg/tree-prof/afdo-lto_priv-basic-1.c | 20 ++++++++
.../gcc.dg/tree-prof/afdo-lto_priv-header-0.c | 47 +++++++++++++++++++
.../gcc.dg/tree-prof/afdo-lto_priv-header-0.h | 3 ++
.../gcc.dg/tree-prof/afdo-lto_priv-header-1.c | 18 +++++++
.../gcc.dg/tree-prof/afdo-lto_priv-header-1.h | 3 ++
gcc/testsuite/lib/profopt.exp | 2 +-
10 files changed, 145 insertions(+), 7 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-basic-0.c
create mode 100644 gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-basic-1.c
create mode 100644 gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-0.c
create mode 100644 gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-0.h
create mode 100644 gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-1.c
create mode 100644 gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-1.h
diff --git a/gcc/c/Make-lang.in b/gcc/c/Make-lang.in
index f09fc99467b..95a7dad8350 100644
--- a/gcc/c/Make-lang.in
+++ b/gcc/c/Make-lang.in
@@ -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;
diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
index 70cfe2b1663..20ae96c18ed 100644
--- a/gcc/cp/Make-lang.in
+++ b/gcc/cp/Make-lang.in
@@ -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;
diff --git a/gcc/lto/Make-lang.in b/gcc/lto/Make-lang.in
index 2af8bba44ca..a24fa059a7a 100644
--- a/gcc/lto/Make-lang.in
+++ b/gcc/lto/Make-lang.in
@@ -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
index 00000000000..551e5a8a425
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-basic-0.c
@@ -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
index 00000000000..38601d1a38e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-basic-1.c
@@ -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
index 00000000000..b30412284c6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-0.c
@@ -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
index 00000000000..ee2a14d8eca
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-0.h
@@ -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
index 00000000000..b9dfe92676e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-1.c
@@ -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
index 00000000000..249c97081d3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/afdo-lto_priv-header-1.h
@@ -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(); }
diff --git a/gcc/testsuite/lib/profopt.exp b/gcc/testsuite/lib/profopt.exp
index 81d86c632d1..0001f6798dd 100644
--- a/gcc/testsuite/lib/profopt.exp
+++ b/gcc/testsuite/lib/profopt.exp
@@ -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 } {
--
2.44.0