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