Debian Codegraph @

gcc/testsuite/c-c++-common/musttail14.c

raw
1 /* PR tree-optimization/118430 */
2 /* { dg-do compile { target musttail } } */
3 /* { dg-options "-O2 -fdump-tree-optimized" } */
4 /* { dg-final { scan-tree-dump-times " \[^\n\r]* = bar \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
5 /* { dg-final { scan-tree-dump-times " \[^\n\r]* = freddy \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
6 /* { dg-final { scan-tree-dump-not " (?:bar|freddy) \\\(\[^\n\r]*\\\); \\\[tail call\\\]" "optimized" } } */
7
8 __attribute__ ((noipa)) void
9 foo (int x)
10 {
11 (void) x;
12 }
13
14 __attribute__ ((noinline)) int
15 bar (int x)
16 {
17 foo (x);
18 return 1;
19 }
20
21 __attribute__ ((noinline)) int
22 baz (int *x)
23 {
24 foo (*x);
25 return 2;
26 }
27
28 __attribute__((noipa)) int
29 qux (int x)
30 {
31 {
32 int v;
33 foo (x);
34 baz (&v);
35 }
36 [[gnu::musttail]]
37 return bar (x);
38 }
39
40 __attribute__((noipa)) int
41 corge (int x)
42 {
43 {
44 int v;
45 foo (x);
46 baz (&v);
47 }
48 return bar (x) + 1;
49 }
50
51 __attribute__ ((noinline)) float
52 freddy (int x)
53 {
54 foo (x);
55 return 1.75f;
56 }
57
58 __attribute__((noipa)) float
59 garply (int x)
60 {
61 {
62 int v;
63 foo (x);
64 baz (&v);
65 }
66 [[gnu::musttail]]
67 return freddy (x);
68 }
69
70 __attribute__((noipa)) float
71 quux (int x)
72 {
73 {
74 int v;
75 foo (x);
76 baz (&v);
77 }
78 return freddy (x) + 0.25f;
79 }
80
81 int v;
82
83 int
84 main ()
85 {
86 qux (v);
87 corge (v);
88 garply (v);
89 quux (v);
90 }