1/* Verify that indirect inlining can also remove references of the functions it 2 discovers calls for. */ 3/* { dg-do compile } */ 4/* { dg-options "-O3 -fno-early-inlining -fno-ipa-cp -fdump-ipa-inline -fdump-tree-optimized -fno-ipa-icf" } */ 5 6int global; 7 8void __attribute__ ((noinline, noclone, used)) 9stuff (int i) 10{ 11 global = i; 12} 13 14int __attribute__ ((noinline,noclone)) get_input(void) 15{ 16 return 1; 17} 18 19static void 20hooray_1 () 21{ 22 stuff (1); 23} 24 25static inline void 26hip2_1 (void (*g)()) 27{ 28 int i; 29 g (); 30 /* Some stuff to make the function bigger so that hip1_1 gets inlined 31 fiorst. */ 32 for (i = 0; i < get_input (); i++) 33 { 34 stuff (2); 35 stuff (2+2); 36 } 37} 38 39static inline void 40hip1_1 (void (*g)()) 41{ 42 hip2_1 (g); 43} 44 45static void 46hooray_2 () 47{ 48 stuff (1); 49} 50 51static inline void 52hip2_2 (void (*g)()) 53{ 54 g (); 55} 56 57static inline void 58hip1_2 (void (*g)()) 59{ 60 int i; 61 62 hip2_2 (g); 63 64 /* Some stuff to make the function bigger so that hip2_2 gets inlined 65 fiorst. */ 66 for (i = 0; i < get_input (); i++) 67 { 68 stuff (2); 69 stuff (2+2); 70 } 71} 72 73 74int 75main (int argc, int *argv[]) 76{ 77 int i; 78 79 for (i = 0; i < get_input (); i++) 80 { 81 hip1_1 (hooray_1); 82 hip1_2 (hooray_2); 83 } 84 return 0; 85} 86 87/* { dg-final { scan-ipa-dump-times "ipa-prop: Removed a reference" 2 "inline" } } */ 88/* { dg-final { scan-tree-dump-not "hooray" "optimized" } } */ 89/* { dg-final { cleanup-ipa-dump "inline" } } */ 90/* { dg-final { cleanup-tree-dump "optimized" } } */ 91