Debian Codegraph @

gcc/testsuite/gcc.dg/tree-ssa/tailcall-7.c

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