Debian Codegraph @

gcc/testsuite/g++.dg/ipa/devirt-24.C

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O3 -fno-ipa-sra -fdump-ipa-inline -fdump-ipa-cp" } */
3 void pad(void);
4 class A {};
5 class B {
6 public:
7 A &operator[](int);
8 };
9 class C : B {
10 public:
11 virtual int m_fn1() { return 0; }
12 inline A &operator[](int p1) {
13 int a;
14 a = m_fn1();
15 static_cast<void>(__builtin_expect(a, 0) ?: 0);
16 return B::operator[](p1);
17 }
18 };
19
20 int *e;
21 static void sort(C &p1, C &p2) {
22 for (int i=0;; i++) {
23 A c, d = p2[0];
24 pad();
25 pad();
26 pad();
27 }
28 }
29
30 int test ();
31
32 void update_sources() {
33 while (test()) {
34 C f;
35 C *b = new (C);
36 sort(f, *b);
37 }
38 }
39 /* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target" 1 "inline" { xfail *-*-* } } } */
40 /* We used to have IPA CP see two aggregates passed to sort() but as the
41 first argument is unused DSE now elides the vptr initialization. */
42 /* { dg-final { scan-ipa-dump-times "Aggregate passed by reference" 1 "cp" } } */