| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O3 -fdump-ipa-cp-details" } */ |
| 3 |
|
| 4 |
#define N 4 |
| 5 |
|
| 6 |
typedef int (* const A[N])(int); |
| 7 |
|
| 8 |
typedef struct S |
| 9 |
{ |
| 10 |
int add_offset; |
| 11 |
A a; |
| 12 |
} S; |
| 13 |
|
| 14 |
extern const S *gs; |
| 15 |
|
| 16 |
static int __attribute__((noinline)) |
| 17 |
bar (const S *f, int x) |
| 18 |
{ |
| 19 |
gs = f; |
| 20 |
x = f->a[2](x); |
| 21 |
x = f->a[2](x); |
| 22 |
x = f->a[2](x); |
| 23 |
return x; |
| 24 |
} |
| 25 |
|
| 26 |
static int |
| 27 |
zero (int x) |
| 28 |
{ |
| 29 |
return 0; |
| 30 |
} |
| 31 |
|
| 32 |
static int |
| 33 |
addone (int x) |
| 34 |
{ |
| 35 |
return x + 1; |
| 36 |
} |
| 37 |
|
| 38 |
static int |
| 39 |
sq (int x) |
| 40 |
{ |
| 41 |
return x * x; |
| 42 |
} |
| 43 |
|
| 44 |
static int |
| 45 |
cube (int x) |
| 46 |
{ |
| 47 |
return x * x * x; |
| 48 |
} |
| 49 |
|
| 50 |
static const S s = {64, {zero, addone, sq, cube}}; |
| 51 |
|
| 52 |
int |
| 53 |
g (int x) |
| 54 |
{ |
| 55 |
return bar (&s, x); |
| 56 |
} |
| 57 |
|
| 58 |
int |
| 59 |
obfuscate (int x) |
| 60 |
{ |
| 61 |
return bar ((S *) 0, x); |
| 62 |
} |
| 63 |
|
| 64 |
/* { dg-final { scan-ipa-dump-times "Discovered an indirect call to a known target" 3 "cp" } } */ |