aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-prof/crossmodule-indir-call-topn-2.c
blob: 2ace3c3b9bf1c7345ed3746d5413917ce1b47bab (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
/* { dg-require-effective-target lto } */
/* { dg-require-profiling "-fprofile-generate" } */
/* { dg-additional-sources "crossmodule-indir-call-topn-1a.c" } */
/* { dg-options "-O2 -flto -DDOJOB=1 -fdump-ipa-profile_estimate" } */

#ifdef FOR_AUTOFDO_TESTING
#define MAXITER 350000000
#else
#define MAXITER 3500000
#endif

#include <stdio.h>

typedef int (*fptr) (int);
int
one (int a);

int
two (int a);

fptr table[] = {&one, &two};

int foo ()
{
  int i, x;
  fptr p = &one;

  x = one (3);

  for (i = 0; i < MAXITER; i++)
    {
      x = (*p) (3);
      p = table[x];
    }
  return x;
}

int
main()
{
  int x = foo ();
  printf ("done:%d\n", x);
}

/* { dg-final-use-not-autofdo { scan-pgo-wpa-ipa-dump "2 \\(200.00%\\) speculations produced." "profile_estimate" } } */