1 /* { dg-do compile } */
2 /* { dg-options "-O3 -fdump-ipa-cp-details" } */
3 
4 typedef struct S
5 {
6   int add_offset;
7   int (*call)(int);
8 } S;
9 
10 extern const S *es, *fs;
11 
12 static int  __attribute__((noinline))
foo(const S f,int x)13 foo (const S f, int x)
14 {
15   es = &f; 			/* This disables IPA-SRA */
16   x = f.call(x+f.add_offset);
17   x = f.call(x);
18   x = f.call(x);
19   return x;
20 }
21 
22 static int  __attribute__((noinline))
bar(const S f,int x)23 bar (const S f, int x)
24 {
25   fs = &f; 			/* This disables IPA-SRA */
26   return foo (f, x);
27 }
28 
29 static int
sq(int x)30 sq (int x)
31 {
32   return x * x;
33 }
34 
35 static const S s = {16, sq};
36 
37 int
h(int x)38 h (int x)
39 {
40   return bar (s, x);
41 }
42 
43 /* { dg-final { scan-ipa-dump-times "Discovered an indirect call to a known target" 3 "cp" } } */
44