1/* { dg-do compile } */ 2/* { dg-options "-O3 -fno-ipa-sra -fdump-ipa-cp-details -fdump-tree-optimized-slim -fno-ipa-icf" } */ 3/* { dg-add-options bind_pic_locally } */ 4 5struct S 6{ 7 int a, b, c; 8}; 9 10void *blah(int, void *); 11 12static void __attribute__ ((noinline)) 13foo (struct S *p) 14{ 15 int i, c = p->c; 16 int b = p->b; 17 void *v = (void *) p; 18 19 for (i= 0; i< c; i++) 20 v = blah(b + i, v); 21} 22 23static void __attribute__ ((noinline)) 24bar (struct S *p) 25{ 26 foo (p); 27} 28 29static void __attribute__ ((noinline)) 30bar_2 (struct S *p) 31{ 32 foo (p); 33} 34 35void 36entry1 (int c) 37{ 38 struct S s; 39 int i; 40 41 for (i = 0; i<c; i++) 42 { 43 s.a = 1; 44 s.b = 64; 45 s.c = 32; 46 bar (&s); 47 } 48 s.c = 2; 49 bar (&s); 50} 51 52void 53entry2 (int c) 54{ 55 struct S s; 56 int i; 57 58 for (i = 0; i<c; i++) 59 { 60 s.a = 6; 61 s.b = 64; 62 s.c = 32; 63 bar_2 (&s); 64 } 65 s.c = 2; 66 foo (&s); 67} 68 69/* { dg-final { scan-ipa-dump-times "Creating a specialized node of foo/\[0-9\]*\\." 2 "cp" } } */ 70/* { dg-final { scan-ipa-dump-times "Creating a specialized node of bar/\[0-9\]*\\." 2 "cp" } } */ 71/* { dg-final { scan-ipa-dump "Creating a specialized node of bar_2.*for all known contexts" "cp" } } */ 72/* { dg-final { scan-ipa-dump-times "Aggregate replacements:" 10 "cp" } } */ 73/* { dg-final { cleanup-ipa-dump "cp" } } */ 74/* { dg-final { scan-tree-dump-not "->c;" "optimized" } } */ 75/* { dg-final { cleanup-tree-dump "optimized" } } */ 76