2013-10-21 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / ipa / iinline-5.c
blob8fb47caffccac78f8a4a10da33185d4aab32e3c3
1 /* Verify that simple indirect calls are inlined even without early
2 inlining.. */
3 /* { dg-do run } */
4 /* { dg-options "-O3 -fdump-ipa-inline -fno-early-inlining" } */
6 extern void abort (void);
8 struct S
10 int i;
11 void (*f)(struct S *);
12 int j,k,l;
15 struct Z
17 unsigned u;
18 void (*f)(struct Z *, int);
19 struct Z *next;
22 static struct Z *gz;
23 static struct S *gs;
24 static int gr = 111;
25 char gc[1024];
27 static __attribute__ ((noinline, noclone)) struct S *
28 get_s (void)
30 return (struct S *) &gc;
34 static void wrong_target_1 (struct S *s)
36 abort ();
39 static void wrong_target_2 (struct S *s)
41 abort ();
44 static void wrong_target_3 (struct S *s)
46 abort ();
49 static void good_target (struct Z *z, int i)
51 gr = 0;
54 static void good_target_3 (struct S *s)
56 gr = 0;
59 static void g1 (struct S *s)
61 struct Z *z = (struct Z*) s;
62 z->f (z, 8);
65 static void f1 (struct S *s)
67 gz->f = good_target;
68 g1 (s);
71 static void g2 (struct Z *z)
73 z->f (z, 8);
76 static void f2 (struct S *s)
78 gz->f = good_target;
79 g2 ((struct Z*) s);
82 static void g3 (struct S *s)
84 s->f (s);
87 static void h3 (struct Z *z)
89 gs->f = good_target_3;
90 g3 ((struct S *) z);
93 static void f3 (struct S *s)
95 h3 ((struct Z*) s);
98 int main (int argc, char **argv)
100 struct S *s = get_s();
101 s->i = 5678;
102 s->f = wrong_target_1;
103 s->j = 1234;
104 gz = (struct Z *) s;
105 f1 (s);
107 s = get_s();
108 gz = (struct Z *) s;
109 s->i = 9999;
110 s->f = wrong_target_1;
111 f2 (s);
113 s = get_s();
114 gs = s;
115 s->i = 9999;
116 s->f = wrong_target_3;
117 f3 (s);
119 return gr;
123 /* { dg-final { scan-ipa-dump-not "wrong_target\[^\\n\]*inline copy in" "inline" } } */
124 /* { dg-final { cleanup-ipa-dump "inline" } } */