aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_0.C
blob: 3052344b5a98580c410dc41189b5fdf1803bd6eb (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
/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */
#include <stdio.h>
struct A {
  A () {}
  virtual int AA (void) { return 0; }
};

extern A* getB (void);
extern A* getC (void);

int g;

int
main (void)
{
  A* p;
  int i;
  int s = 0;

  p = getB();
  for (i = 0; i < 100; i++)
   {
      s += p->AA();
   }

  for (i = 0; i < 100; i++)
   {
      if (i%10 == 0)
        p = getB();
      else
        p = getC();

      s += p->AA();
   }
   printf ("result = %d\n",s);
}

/* { dg-final-use { scan-ipa-dump-times "Indirect call -> direct call" 2 "profile" } } */
/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized" } } */
/* { dg-final-use { cleanup-tree-dump "optimized" } } */
/* { dg-final-use { cleanup-ipa-dump "profile" } } */