Debian Codegraph @

gcc/testsuite/g++.dg/tree-prof/reorder.C

raw
1 /* { dg-options "-O2 -fno-devirtualize --param=profile-func-internal-id=0 -fdump-ipa-profile-optimized -fdump-ipa-afdo-optimized -Wno-coverage-mismatch -Wno-attributes" } */
2
3 #ifdef _PROFILE_USE
4 #include "reorder_class1.h"
5 #include "reorder_class2.h"
6 #else
7 #include "reorder_class2.h"
8 #include "reorder_class1.h"
9 #endif
10
11 int g;
12 static __attribute__((always_inline))
13 void test1 (A *tc)
14 {
15 int i;
16 for (i = 0; i < 10000000; i++)
17 g += tc->foo();
18 if (g<100) g++;
19 }
20
21 static __attribute__((always_inline))
22 void test2 (B *tc)
23 {
24 int i;
25 for (i = 0; i < 10000000; i++)
26 g += tc->foo();
27 }
28
29
30 #ifdef _PROFILE_USE
31 __attribute__((noinline)) void test_a(A *ap) { test1 (ap); }
32 __attribute__((noinline)) void test_b(B *bp) { test2 (bp); }
33 #else
34 __attribute__((noinline)) void test_b(B *bp) { test2 (bp); }
35 __attribute__((noinline)) void test_a(A *ap) { test1 (ap); }
36 #endif
37
38 int main()
39 {
40 A* ap = new A();
41 B* bp = new B();
42
43 test_a(ap);
44 test_b(bp);
45 }
46
47 /* { dg-final-use-not-autofdo { scan-ipa-dump-times "Indirect call -> direct call" 2 "profile" } } */
48 /* { dg-final-use-autofdo { scan-ipa-dump-times "Indirect call -> direct call" 2 "afdo" } } */