aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/morefunc.C
blob: d5cee40cd26953d0b96e9dd3184c5351893a143c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* { dg-options "-O2 -fno-devirtualize --param=profile-func-internal-id=0 -fdump-ipa-profile -Wno-attributes -Wno-coverage-mismatch" } */
#include "reorder_class1.h"
#include "reorder_class2.h"

int g;

#ifdef _PROFILE_USE
/* Another function not existing
 * in profile-gen  */

__attribute__((noinline)) void
new_func (int i)
{
   g += i;
}
#endif

static __attribute__((always_inline))
void test1 (A *tc)
{
  int i;
  for (i = 0; i < 1000; i++)
     g += tc->foo(); 
   if (g<100) g++;
}

static __attribute__((always_inline))
void test2 (B *tc)
{
  int i;
  for (i = 0; i < 1000; i++)
     g += tc->foo();
}


__attribute__((noinline)) void test_a(A *ap) { test1 (ap); }
__attribute__((noinline)) void test_b(B *bp) { test2 (bp); }


int main()
{
  A* ap = new A();
  B* bp = new B();

  test_a(ap);
  test_b(bp);

#ifdef _PROFILE_USE
  new_func(10);
#endif

}

/* { dg-final-use { scan-ipa-dump-times "Indirect call -> direct call" 2 "profile" } } */