Make FDO more tolerant to source changes
[official-gcc.git] / gcc / testsuite / g++.dg / tree-prof / reorder.C
blob223bcf94f4fa50c7169f845b961d1ab71df6364f
1 /* { dg-options "-O2 -fno-devirtualize --param=profile-func-internal-id=0 -fdump-ipa-profile -Wno-coverage-mismatch -Wno-attributes" } */
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
11 int g;
12 static __attribute__((always_inline))
13 void test1 (A *tc)
15   int i;
16   for (i = 0; i < 1000; i++)
17      g += tc->foo(); 
18    if (g<100) g++;
21 static __attribute__((always_inline))
22 void test2 (B *tc)
24   int i;
25   for (i = 0; i < 1000; i++)
26      g += tc->foo();
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
38 int main()
40   A* ap = new A();
41   B* bp = new B();
43   test_a(ap);
44   test_b(bp);
47 /* { dg-final-use { scan-ipa-dump-times "Indirect call -> direct call" 2 "profile" } } */