Debian Codegraph @

gcc/testsuite/g++.dg/tree-prof/pr35545.C

raw
1 // devirt.cc
2 /* { dg-options "-O2 -fdump-ipa-profile_estimate -fdump-tree-optimized" } */
3
4 class A {
5 public:
6 virtual int foo() {
7 return 1;
8 }
9
10 int i;
11 };
12
13 class B : public A
14 {
15 public:
16 virtual int foo() {
17 return 2;
18 }
19
20 int b;
21 } ;
22
23
24 int main()
25 {
26 int i;
27
28 A* ap = 0;
29
30 for (i = 0; i < 1000000; i++)
31 {
32
33 if (i%7==0)
34 {
35 ap = new A();
36 }
37 else
38 ap = new B();
39
40 ap->foo();
41
42 delete ap;
43
44 }
45
46 return 0;
47
48 }
49 /* { dg-final-use { scan-ipa-dump "Indirect call -> direct call" "profile_estimate" } } */
50 /* { dg-final-use { scan-tree-dump-not "OBJ_TYPE_REF" "optimized" } } */