PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / ipa / iinline-4.c
blobf50ffa58221f3d6eefb43ea6fecc663fba95bee5
1 /* Verify that simple indirect calls are inlined even without early
2 inlining.. */
3 /* { dg-do compile } */
4 /* { dg-options "-O3 -fdump-ipa-inline -fno-early-inlining -fno-ipa-icf" } */
6 struct S
8 int i;
9 void (*f)(struct S *);
10 unsigned u;
13 struct U
15 struct U *next;
16 struct S s;
17 short a[8];
20 extern void non_existent(struct S *p, int);
22 /* ----- 1 ----- */
24 static void hooray1 (struct S *p)
26 non_existent (p, 1);
29 static void hiphip1 (struct S *p)
31 p->f (p);
34 int test1 (void)
36 struct S s;
37 s.i = 1234;
38 s.f = hooray1;
39 s.u = 1001;
40 hiphip1 (&s);
41 return 0;
44 /* ----- 2 ----- */
46 struct S *gp;
48 static void hooray2 (struct S *p)
50 non_existent (p, 2);
53 static void hip2 (struct S *p)
55 p->f (p);
58 static void hiphip2 (struct S *p)
60 hip2 (p);
63 int test2 (void)
65 struct S *p = gp;
66 p->i = 2341;
67 p->f = hooray2;
68 p->u = 1002;
69 hiphip2 (p);
70 return 0;
73 /* ----- 3 ----- */
75 static void hooray3 (struct S *p)
77 non_existent (p, 2);
80 static void hip3 (struct S *p)
82 p->f (p);
85 static __attribute__ ((flatten)) void hiphip3 (struct S *p)
87 hip3 (p);
90 int test3 (void)
92 struct S *p = gp;
93 p->i = 2341;
94 p->f = hooray3;
95 p->u = 1003;
96 hiphip3 (p);
97 return 0;
100 /* ----- 4 ----- */
102 static void hooray4 (struct S *p)
104 non_existent (p, 3);
107 static void hiphip4 (struct S s)
109 s.f (&s);
112 int test4(void)
114 struct S s;
115 s.i = 3412;
116 s.f = hooray4;
117 s.u = 1004;
118 hiphip4 (s);
119 return 0;
122 /* ----- 5 ----- */
124 struct U *gu;
126 static void hooray5 (struct S *p)
128 non_existent (p, 5);
131 static void hip5 (struct S *p)
133 p->f (p);
136 static void hiphip5 (struct U *u)
138 hip5 (&u->s);
141 int test5 (void)
143 struct U *u = gu;
144 u->next = u;
145 u->s.i = 9876;
146 u->s.f = hooray5;
147 u->s.u = 1005;
148 hiphip5 (u);
149 return 0;
152 /* ----- 6 ----- */
154 static void hooray6 (struct S *p)
156 non_existent (p, 6);
159 static void hip6 (struct S *p)
161 p->f (p);
164 static __attribute__ ((flatten)) void hiphip6 (struct U *u)
166 hip6 (&u->s);
169 int test6 (void)
171 struct U *u = gu;
172 u->next = u;
173 u->s.i = 9876;
174 u->s.f = hooray6;
175 u->s.u = 1006;
176 hiphip6 (u);
177 return 0;
180 /* ----- 7 ----- */
182 struct S **gdp;
185 static void hooray7 (struct S *p)
187 non_existent (p, 7);
190 static void hip7 (struct S *p)
192 p->f (p);
193 gdp = &p;
196 static void hiphip7 (struct S *p)
198 hip7 (p);
199 gdp = &p;
202 int test7 (void)
204 struct S *p = gp;
205 p->i = 7341;
206 p->f = hooray7;
207 p->u = 1007;
208 hiphip7 (p);
209 return 0;
214 /* { dg-final { scan-ipa-dump "hooray1\[^\\n\]*inline copy in test1" "inline" } } */
215 /* { dg-final { scan-ipa-dump "hooray2\[^\\n\]*inline copy in test2" "inline" } } */
216 /* { dg-final { scan-ipa-dump "hooray3\[^\\n\]*inline copy in test3" "inline" } } */
217 /* { dg-final { scan-ipa-dump "hooray4\[^\\n\]*inline copy in test4" "inline" { xfail { { hppa*-*-* } && { ! lp64 } } } } } */
218 /* { dg-final { scan-ipa-dump "hooray5\[^\\n\]*inline copy in test5" "inline" } } */
219 /* { dg-final { scan-ipa-dump "hooray6\[^\\n\]*inline copy in test6" "inline" } } */
220 /* { dg-final { scan-ipa-dump "hooray7\[^\\n\]*inline copy in test7" "inline" } } */