1  /* { dg-require-effective-target lto } */
       2  /* { dg-additional-sources "crossmodule-indir-call-topn-1a.c" } */
       3  /* { dg-require-profiling "-fprofile-generate" } */
       4  /* { dg-options "-O2 -flto -DDOJOB=1 -fdump-ipa-profile_estimate" } */
       5  
       6  #ifdef FOR_AUTOFDO_TESTING
       7  #define MAXITER 350000000
       8  #else
       9  #define MAXITER 3500000
      10  #endif
      11  
      12  #include <stdio.h>
      13  
      14  typedef int (*fptr) (int);
      15  int
      16  one (int a);
      17  
      18  int
      19  two (int a);
      20  
      21  fptr table[] = {&one, &two};
      22  
      23  int
      24  main()
      25  {
      26    int i, x;
      27    fptr p = &one;
      28  
      29    x = one (3);
      30  
      31    for (i = 0; i < MAXITER; i++)
      32      {
      33        x = (*p) (3);
      34        p = table[x];
      35      }
      36    printf ("done:%d\n", x);
      37  }
      38  
      39  /* { dg-final-use-not-autofdo { scan-pgo-wpa-ipa-dump "2 \\(200.00%\\) speculations produced." "profile_estimate" } } */