annotate gcc/testsuite/g++.dg/ipa/devirt-41.C @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* { dg-do compile } */
kono
parents:
diff changeset
2 /* { dg-options "-O3 -fdump-ipa-inline-details -fno-early-inlining -fno-ipa-cp" } */
kono
parents:
diff changeset
3 struct A {virtual int foo () {return 1;}};
kono
parents:
diff changeset
4 struct B:A {virtual int foo () {return 2;}};
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 void dostuff(struct A *);
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 static void
kono
parents:
diff changeset
9 test (struct A *a)
kono
parents:
diff changeset
10 {
kono
parents:
diff changeset
11 dostuff (a);
kono
parents:
diff changeset
12 if (a->foo ()!= 2)
kono
parents:
diff changeset
13 __builtin_abort ();
kono
parents:
diff changeset
14 }
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 main()
kono
parents:
diff changeset
17 {
kono
parents:
diff changeset
18 struct B a;
kono
parents:
diff changeset
19 dostuff (&a);
kono
parents:
diff changeset
20 test (&a);
kono
parents:
diff changeset
21 }
kono
parents:
diff changeset
22 /* Inlining of dostuff into main should combine polymorphic context
kono
parents:
diff changeset
23 specifying Outer type:struct B offset 0
kono
parents:
diff changeset
24 with Outer type (dynamic):struct A (or a derived type) offset 0
kono
parents:
diff changeset
25 and enable devirtualization.
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 Because the type is in static storage, we know it won't change type in dostuff
kono
parents:
diff changeset
28 and from callstack we can tell that is is not in construction/destruction. */
kono
parents:
diff changeset
29 /* { dg-final { scan-ipa-dump "Second type is base of first" "inline" } } */
kono
parents:
diff changeset
30 /* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target" 1 "inline" } } */