blob: ffeabe54293605cdca3c036c951814e2d47f9763 (
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
|
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-tailc-details" } */
struct s { int x; };
void f_direct (struct s);
void f_indirect (struct s *);
void f_void (void);
/* Tail call. */
void
g1 (struct s param)
{
f_direct (param);
}
/* Tail call. */
void
g2 (struct s *param_ptr)
{
f_direct (*param_ptr);
}
/* Tail call. */
void
g3 (struct s *param_ptr)
{
f_indirect (param_ptr);
}
/* Tail call. */
void
g4 (struct s *param_ptr)
{
f_indirect (param_ptr);
f_void ();
}
/* Tail call. */
void
g5 (struct s param)
{
struct s local = param;
f_direct (local);
}
/* Tail call. */
void
g6 (struct s param)
{
struct s local = param;
f_direct (local);
f_void ();
}
/* Not a tail call. */
void
g7 (struct s param)
{
struct s local = param;
f_indirect (&local);
}
/* Not a tail call. */
void
g8 (struct s *param_ptr)
{
struct s local = *param_ptr;
f_indirect (&local);
}
/* Not a tail call. */
void
g9 (struct s *param_ptr)
{
struct s local = *param_ptr;
f_indirect (&local);
f_void ();
}
/* { dg-final { scan-tree-dump-times "Found tail call" 6 "tailc" } } */
|