blob: d290450cd57e06fc39272d73791c18bf9cabdeca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
// { dg-do run }
// { dg-options "-O3 -fdump-ipa-cp -fdevirtualize" }
struct Distraction
{
char fc[8];
virtual Distraction * return_self ()
{ return this; }
};
namespace {
struct A;
static A * __attribute__ ((noinline, noclone)) get_an_A ();
static int go;
struct A
{
int fi;
A () : fi(777) {}
A (int pi) : fi (pi) {}
virtual void foo (int p) = 0;
};
struct B : public Distraction, A
{
B () : Distraction(), A() { }
B (int pi) : Distraction (), A (pi) {}
virtual void foo (int p)
{
int o = fi;
for (int i = 0; i < p; i++)
o += i + i * i;
go = o;
}
};
struct B gb (2);
static A * __attribute__ ((noinline, noclone))
get_an_A ()
{
return &gb;
}
}
static int __attribute__ ((noinline, noclone))
get_a_number ()
{
return 5;
}
extern "C" void abort (void);
static void __attribute__ ((noinline, noclone))
bar ()
{
for (int i = 0; i < get_a_number (); i++)
{
struct A *p = get_an_A ();
p->foo (4);
if (go != 22)
abort ();
}
}
int main (int argc, char *argv[])
{
for (int i = 0; i < get_a_number (); i++)
{
struct A *p = get_an_A ();
p->foo (4);
if (go != 22)
abort ();
}
bar ();
return 0;
}
/* { dg-final { scan-ipa-dump-times "Thunk fixed offset" 2 "cp"} } */
/* { dg-final { cleanup-ipa-dump "cp" } } */
|