aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-prof/clone-test.c
blob: 74d648bf915c6e42836c8b3efc6f2c3d0f6d11c1 (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
56
57
58
59
60
61
62
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"} } */