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" } */ 5 6 struct S 7 { 8 int i; 9 void (*f)(struct S *); 10 unsigned u; 11 }; 12 13 struct U 14 { 15 struct U *next; 16 struct S s; 17 short a[8]; 18 }; 19 20 extern void non_existent(struct S *p, int); 21 22 /* ----- 1 ----- */ 23 hooray1(struct S * p)24static void hooray1 (struct S *p) 25 { 26 non_existent (p, 1); 27 } 28 hiphip1(struct S * p)29static void hiphip1 (struct S *p) 30 { 31 p->f (p); 32 } 33 test1(void)34int test1 (void) 35 { 36 struct S s; 37 s.i = 1234; 38 s.f = hooray1; 39 s.u = 1001; 40 hiphip1 (&s); 41 return 0; 42 } 43 44 /* ----- 2 ----- */ 45 46 struct S *gp; 47 hooray2(struct S * p)48static void hooray2 (struct S *p) 49 { 50 non_existent (p, 2); 51 } 52 hip2(struct S * p)53static void hip2 (struct S *p) 54 { 55 p->f (p); 56 } 57 hiphip2(struct S * p)58static void hiphip2 (struct S *p) 59 { 60 hip2 (p); 61 } 62 test2(void)63int test2 (void) 64 { 65 struct S *p = gp; 66 p->i = 2341; 67 p->f = hooray2; 68 p->u = 1002; 69 hiphip2 (p); 70 return 0; 71 } 72 73 /* ----- 3 ----- */ 74 hooray3(struct S * p)75static void hooray3 (struct S *p) 76 { 77 non_existent (p, 2); 78 } 79 hip3(struct S * p)80static void hip3 (struct S *p) 81 { 82 p->f (p); 83 } 84 hiphip3(struct S * p)85static __attribute__ ((flatten)) void hiphip3 (struct S *p) 86 { 87 hip3 (p); 88 } 89 test3(void)90int test3 (void) 91 { 92 struct S *p = gp; 93 p->i = 2341; 94 p->f = hooray3; 95 p->u = 1003; 96 hiphip3 (p); 97 return 0; 98 } 99 100 /* ----- 4 ----- */ 101 hooray4(struct S * p)102static void hooray4 (struct S *p) 103 { 104 non_existent (p, 3); 105 } 106 hiphip4(struct S s)107static void hiphip4 (struct S s) 108 { 109 s.f (&s); 110 } 111 test4(void)112int test4(void) 113 { 114 struct S s; 115 s.i = 3412; 116 s.f = hooray4; 117 s.u = 1004; 118 hiphip4 (s); 119 return 0; 120 } 121 122 /* ----- 5 ----- */ 123 124 struct U *gu; 125 hooray5(struct S * p)126static void hooray5 (struct S *p) 127 { 128 non_existent (p, 5); 129 } 130 hip5(struct S * p)131static void hip5 (struct S *p) 132 { 133 p->f (p); 134 } 135 hiphip5(struct U * u)136static void hiphip5 (struct U *u) 137 { 138 hip5 (&u->s); 139 } 140 test5(void)141int test5 (void) 142 { 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; 150 } 151 152 /* ----- 6 ----- */ 153 hooray6(struct S * p)154static void hooray6 (struct S *p) 155 { 156 non_existent (p, 6); 157 } 158 hip6(struct S * p)159static void hip6 (struct S *p) 160 { 161 p->f (p); 162 } 163 hiphip6(struct U * u)164static __attribute__ ((flatten)) void hiphip6 (struct U *u) 165 { 166 hip6 (&u->s); 167 } 168 test6(void)169int test6 (void) 170 { 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; 178 } 179 180 /* ----- 7 ----- */ 181 182 struct S **gdp; 183 184 hooray7(struct S * p)185static void hooray7 (struct S *p) 186 { 187 non_existent (p, 7); 188 } 189 hip7(struct S * p)190static void hip7 (struct S *p) 191 { 192 p->f (p); 193 gdp = &p; 194 } 195 hiphip7(struct S * p)196static void hiphip7 (struct S *p) 197 { 198 hip7 (p); 199 gdp = &p; 200 } 201 test7(void)202int test7 (void) 203 { 204 struct S *p = gp; 205 p->i = 7341; 206 p->f = hooray7; 207 p->u = 1007; 208 hiphip7 (p); 209 return 0; 210 } 211 212 213 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" } } */ 221