annotate gcc/testsuite/g++.dg/ipa/devirt-36.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
1 /* { dg-do compile } */
111
kono
parents:
diff changeset
2 /* { dg-options "-O2 -fdump-ipa-devirt-details -fdump-tree-fre1-details" } */
kono
parents:
diff changeset
3 struct A {virtual int t(void) {return 1;}};
kono
parents:
diff changeset
4 struct B:A {B(); virtual int t(void) {return 2;}};
kono
parents:
diff changeset
5 struct C {int a; struct B b;};
kono
parents:
diff changeset
6 void test2(struct A *);
kono
parents:
diff changeset
7 int
kono
parents:
diff changeset
8 m(struct B *b)
kono
parents:
diff changeset
9 {
kono
parents:
diff changeset
10 struct C *c = new (C);
kono
parents:
diff changeset
11 struct A *a = &c->b;
kono
parents:
diff changeset
12 a->t(); // This call should be devirtualized by
kono
parents:
diff changeset
13 // FRE because we know type from ctor call
kono
parents:
diff changeset
14 ((struct B *)a)->B::t(); // Make devirt possible
kono
parents:
diff changeset
15 // C++ FE won't produce inline body without this
kono
parents:
diff changeset
16 test2(a);
kono
parents:
diff changeset
17 return a->t(); // This call should be devirtualized speculatively because
kono
parents:
diff changeset
18 // test2 may change the type of A by placement new.
kono
parents:
diff changeset
19 // C++ standard is bit imprecise about this.
kono
parents:
diff changeset
20 }
kono
parents:
diff changeset
21 /* { dg-final { scan-tree-dump "converting indirect call to function virtual int B::t" "fre1" } } */
kono
parents:
diff changeset
22 /* { dg-final { scan-ipa-dump "to virtual int B::t" "devirt" } } */
kono
parents:
diff changeset
23 /* { dg-final { scan-ipa-dump "1 speculatively devirtualized" "devirt" } } */
kono
parents:
diff changeset
24