| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fdump-tree-tailc-details" } */ |
| 3 |
|
| 4 |
struct s { int x; }; |
| 5 |
void f_direct (struct s); |
| 6 |
void f_indirect (struct s *); |
| 7 |
void f_void (void); |
| 8 |
|
| 9 |
/* Tail call. */ |
| 10 |
void |
| 11 |
g1 (struct s param) |
| 12 |
{ |
| 13 |
f_direct (param); |
| 14 |
} |
| 15 |
|
| 16 |
/* Tail call. */ |
| 17 |
void |
| 18 |
g2 (struct s *param_ptr) |
| 19 |
{ |
| 20 |
f_direct (*param_ptr); |
| 21 |
} |
| 22 |
|
| 23 |
/* Tail call. */ |
| 24 |
void |
| 25 |
g3 (struct s *param_ptr) |
| 26 |
{ |
| 27 |
f_indirect (param_ptr); |
| 28 |
} |
| 29 |
|
| 30 |
/* Tail call. */ |
| 31 |
void |
| 32 |
g4 (struct s *param_ptr) |
| 33 |
{ |
| 34 |
f_indirect (param_ptr); |
| 35 |
f_void (); |
| 36 |
} |
| 37 |
|
| 38 |
/* Tail call. */ |
| 39 |
void |
| 40 |
g5 (struct s param) |
| 41 |
{ |
| 42 |
struct s local = param; |
| 43 |
f_direct (local); |
| 44 |
} |
| 45 |
|
| 46 |
/* Tail call. */ |
| 47 |
void |
| 48 |
g6 (struct s param) |
| 49 |
{ |
| 50 |
struct s local = param; |
| 51 |
f_direct (local); |
| 52 |
f_void (); |
| 53 |
} |
| 54 |
|
| 55 |
/* Not a tail call. */ |
| 56 |
void |
| 57 |
g7 (struct s param) |
| 58 |
{ |
| 59 |
struct s local = param; |
| 60 |
f_indirect (&local); |
| 61 |
} |
| 62 |
|
| 63 |
/* Not a tail call. */ |
| 64 |
void |
| 65 |
g8 (struct s *param_ptr) |
| 66 |
{ |
| 67 |
struct s local = *param_ptr; |
| 68 |
f_indirect (&local); |
| 69 |
} |
| 70 |
|
| 71 |
/* Not a tail call. */ |
| 72 |
void |
| 73 |
g9 (struct s *param_ptr) |
| 74 |
{ |
| 75 |
struct s local = *param_ptr; |
| 76 |
f_indirect (&local); |
| 77 |
f_void (); |
| 78 |
} |
| 79 |
|
| 80 |
/* { dg-final { scan-tree-dump-times "Found tail call" 6 "tailc" } } */ |