aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-prof
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/tree-prof')
-rw-r--r--gcc/testsuite/gcc.dg/tree-prof/afdo-crossmodule-1.c29
-rw-r--r--gcc/testsuite/gcc.dg/tree-prof/afdo-crossmodule-1b.c10
-rw-r--r--gcc/testsuite/gcc.dg/tree-prof/afdo-inline.c27
-rw-r--r--gcc/testsuite/gcc.dg/tree-prof/afdo-vpt-earlyinline.c38
-rw-r--r--gcc/testsuite/gcc.dg/tree-prof/clone-merge-1.c34
-rw-r--r--gcc/testsuite/gcc.dg/tree-prof/clone-test.c63
-rw-r--r--gcc/testsuite/gcc.dg/tree-prof/indir-call-prof-2.c6
7 files changed, 204 insertions, 3 deletions
diff --git a/gcc/testsuite/gcc.dg/tree-prof/afdo-crossmodule-1.c b/gcc/testsuite/gcc.dg/tree-prof/afdo-crossmodule-1.c
new file mode 100644
index 0000000..574a085
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/afdo-crossmodule-1.c
@@ -0,0 +1,29 @@
+/* { dg-require-effective-target lto } */
+/* { dg-additional-sources "afdo-crossmodule-1b.c" } */
+/* { dg-options "-O3 -flto -fdump-ipa-afdo_offline -fdump-tree-einline-details" } */
+/* { dg-require-profiling "-fauto-profile" } */
+volatile int c;
+
+int foo2 ()
+{
+ c++;
+ return 1;
+}
+int foo (int (*fooptr) ())
+{
+ return fooptr ();
+}
+extern int bar (int (*fooptr) (int (*)()));
+
+int
+main()
+{
+ int n = 1000000;
+ int s = 0;
+ for (int i = 0; i < n; i++)
+ s += bar (foo);
+ return n != s;
+}
+/* { dg-final-use-autofdo { scan-ipa-dump "Removing external inline: main:5 bar" "afdo_offline"} } */
+/* { dg-final-use-autofdo { scan-ipa-dump "Offlining function inlined to other module: bar:2 foo" "afdo_offline"} } */
+/* { dg-final-use-autofdo { scan-tree-dump "Indirect call -> speculative call foo.. => foo2" "einline"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-prof/afdo-crossmodule-1b.c b/gcc/testsuite/gcc.dg/tree-prof/afdo-crossmodule-1b.c
new file mode 100644
index 0000000..dd53295
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/afdo-crossmodule-1b.c
@@ -0,0 +1,10 @@
+extern int foo2 ();
+
+int bar (int (*fooptr) (int (*)()))
+{
+ return fooptr (foo2);
+}
+/* { dg-final-use-autofdo { scan-ipa-dump "Offlining function inlined to other module: main:5 bar" "afdo_offline"} } */
+/* { dg-final-use-autofdo { scan-ipa-dump "Offlining function inlined to other module: bar:2 main:5 foo" "afdo_offline"} } */
+/* It would be nice to speculate call to foo, but offlining does not preserve jump target
+ and currently afdo does not do cross-module indirect call promotion. */
diff --git a/gcc/testsuite/gcc.dg/tree-prof/afdo-inline.c b/gcc/testsuite/gcc.dg/tree-prof/afdo-inline.c
new file mode 100644
index 0000000..b67b3cb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/afdo-inline.c
@@ -0,0 +1,27 @@
+/* { dg-options "-O2 -fdump-tree-einline-details --param early-inlining-insns=1" } */
+/* { dg-require-profiling "-fauto-profile" } */
+volatile int a[1000];
+int reta (int i)
+{
+ if (a[i])
+ __builtin_printf ("It is one\n");
+ if (a[i] == 2)
+ __builtin_printf ("It is two\n");
+ return a[i];
+}
+int test ()
+{
+ int s = 0;
+ for (int pos = 0; pos < 1000; pos++)
+ reta(pos);
+ if (s)
+ __builtin_printf ("sum error\n");
+}
+int main()
+{
+ for (int i = 0; i < 10000; i++)
+ test();
+ return 0;
+}
+/* { dg-final-use-autofdo { scan-tree-dump "Inlining using auto-profile test" "einline"} } */
+/* { dg-final-use-autofdo { scan-tree-dump "Inlining using auto-profile reta.*transitively inlined to main" "einline"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-prof/afdo-vpt-earlyinline.c b/gcc/testsuite/gcc.dg/tree-prof/afdo-vpt-earlyinline.c
new file mode 100644
index 0000000..b5c9024
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/afdo-vpt-earlyinline.c
@@ -0,0 +1,38 @@
+/* { dg-options "-O2 -fdump-ipa-afdo-details -fdump-tree-einline-details --param early-inlining-insns=1" } */
+/* { dg-require-profiling "-fauto-profile" } */
+
+volatile int array[1000];
+int reta (int i)
+{
+ return array[i];
+}
+struct wrapptr
+{
+ int (*ret)(int);
+};
+int test (struct wrapptr *p)
+{
+ int s = 0;
+ int (*ret)(int) = p->ret;
+ for (int pos = 0; pos < 1000; pos++)
+ ret(pos);
+ if (s)
+ __builtin_printf ("sum error\n");
+}
+int main()
+{
+ for (int i = 0; i < 10000; i++)
+ {
+ struct wrapptr p={reta};
+
+
+
+ test(&p);
+ }
+ return 0;
+}
+/* { dg-final-use-autofdo { scan-tree-dump "Inlining using auto-profile test" "einline"} } */
+/* { dg-final-use-autofdo { scan-tree-dump "Checking indirect call -> direct call ret_" "einline"} } */
+/* { dg-final-use-autofdo { scan-tree-dump "looks good" "einline"} } */
+/* If we inlined reta->test->main, it will contian array[pos]. */
+/* { dg-final-use-autofdo { scan-tree-dump "array.pos_" "einline"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-prof/clone-merge-1.c b/gcc/testsuite/gcc.dg/tree-prof/clone-merge-1.c
new file mode 100644
index 0000000..43a9090
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/clone-merge-1.c
@@ -0,0 +1,34 @@
+/* { dg-options "-O3 -fno-early-inlining -fdump-ipa-afdo_offline-all" } */
+/* { dg-require-profiling "-fauto-profile" } */
+
+__attribute__ ((used))
+int a[1000];
+
+__attribute__ ((noinline))
+void
+test2(int sz)
+{
+ a[sz]++;
+ asm volatile (""::"m"(a));
+}
+
+__attribute__ ((noinline))
+void
+test1 (int sz)
+{
+ for (int i = 0; i < 1000; i++)
+ if (i % 2)
+ test2 (sz);
+ else
+ test2 (i);
+
+}
+int main()
+{
+ for (int i = 0; i < 1000; i++)
+ test1 (1000);
+ return 0;
+}
+/* We will have profiles for test2 and test2.constprop.0 that will have to be
+ merged, */
+/* { dg-final-use-autofdo { scan-ipa-dump "Merging duplicate symbol test2" "afdo_offline"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-prof/clone-test.c b/gcc/testsuite/gcc.dg/tree-prof/clone-test.c
new file mode 100644
index 0000000..74d648b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/clone-test.c
@@ -0,0 +1,63 @@
+/* { dg-options "-O3 -fno-early-inlining -fdump-ipa-afdo-all" } */
+/* { dg-require-profiling "-fauto-profile" } */
+
+#define N 5000
+__attribute__ ((used))
+int a[N+1];
+
+__attribute__ ((noinline))
+static void
+test2(int sz)
+{
+ a[sz]++;
+ asm volatile (""::"m"(a));
+}
+
+struct list
+{
+ struct list *next;
+ int val;
+};
+
+__attribute__ ((noinline))
+static int
+test3(volatile struct list l, int v)
+{
+ a [(l.val + v) % N] = v;
+}
+
+__attribute__ ((noinline))
+void
+test1 (int sz)
+{
+ volatile struct list l = {0};
+ __attribute__ ((noinline))
+ void inner(int i)
+ {
+ if (i % 2)
+ test2 (500);
+ if (i % 3)
+ test3 (l,200);
+ else
+ test2 (i);
+ }
+ for (int i = 0; i < N; i++)
+ inner(i);
+
+}
+
+int main()
+{
+ for (int i = 0; i < N; i++)
+ {
+ test1 (N);
+ }
+ return 0;
+}
+/* Profile will have test1.constprop.0 */
+/* { dg-final-use-autofdo { scan-ipa-dump "Annotating BB profile of test1" "afdo"} } */
+/* { dg-final-use-autofdo { scan-ipa-dump "Annotating BB profile of test2" "afdo"} } */
+/* Profile will have test3.constprop.0.isra.0 */
+/* { dg-final-use-autofdo { scan-ipa-dump "Annotating BB profile of test3" "afdo"} } */
+/* { dg-final-use-autofdo { scan-ipa-dump "Annotating BB profile of inner" "afdo"} } */
+
diff --git a/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof-2.c b/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof-2.c
index 1d64d9f..b6c0e4a 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof-2.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof-2.c
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fno-early-inlining -fdump-ipa-profile-optimized -fdump-ipa-afdo-optimized" } */
+/* { dg-options "-O2 -fno-early-inlining -fdump-ipa-profile-details -fdump-tree-einline-details" } */
volatile int one;
static int
add1 (int val)
@@ -31,5 +31,5 @@ main (void)
}
/* { dg-final-use-not-autofdo { scan-ipa-dump "Indirect call -> direct call.* add1 .will resolve by ipa-profile" "profile"} } */
/* { dg-final-use-not-autofdo { scan-ipa-dump "Indirect call -> direct call.* sub1 .will resolve by ipa-profile" "profile"} } */
-/* { dg-final-use-autofdo { scan-ipa-dump "Inlining add1/1 into main/4." "afdo"} } */
-/* { dg-final-use-autofdo { scan-ipa-dump "Inlining sub1/2 into main/4." "afdo"} } */
+/* { dg-final-use-autofdo { scan-tree-dump "Inlining using auto-profile add1/. into do_op/. which is transitively inlined to main/" "einline"} } */
+/* { dg-final-use-autofdo { scan-tree-dump "Inlining using auto-profile sub1/. into do_op/. which is transitively inlined to main/" "einline"} } */