OSDN Git Service

2010-04-28 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / ipa / ipa-pta-13.c
1 /* { dg-do link } */
2 /* { dg-options "-O2 -fipa-pta -fdump-ipa-pta-details -fdump-tree-fre" } */
3
4 static int x, y;
5
6 static __attribute__((noinline,noclone)) void
7 local (int *p)
8 {
9   *p = 1;
10 }
11
12 static __attribute__((noinline,noclone)) void
13 local_address_taken (int *p)
14 {
15   *p = 1;
16 }
17
18 /* Even though not referenced in this TU we should have added constraints
19    for the initializer.  */
20 /* { dg-final { scan-ipa-dump "ex = &local_address_taken" "pta" } } */
21 void (*ex)(int *) = local_address_taken;
22
23 extern void link_error (void);
24
25 int main()
26 {
27   void (*anyfn)(int *) = (void (*)(int *))(__SIZE_TYPE__)x;
28   /* The following should cause local_address_taken to get &x
29      as argument, but not local.  We shouldn't get &x added to
30      arbitrary special sub-vars of local_address_taken though,
31      a missed optimization currently.
32      As local_address_taken escapes the translation unit its
33      argument points-to set needs to include ESCAPED and NONLOCAL.
34      We shouldn't get the functions sub-vars in the ESCAPED solution
35      though, another missed-optimization.  This also causes the functions
36      uses to be messed up even further.  */
37   /* { dg-final { scan-ipa-dump "local_address_taken.arg0 = { ESCAPED NONLOCAL y x }" "pta" } } */
38   /* { dg-final { scan-ipa-dump "local_address_taken.clobber = { ESCAPED NONLOCAL y x }" "pta" } } */
39   /* { dg-final { scan-ipa-dump "local_address_taken.use = { }" "pta" { xfail *-*-* } } } */
40   (*anyfn) (&x);
41   x = 0;
42   local (&y);
43   /* Thus we should be able to disambiguate x against the call to local
44      and CSE the stored value.  */
45   if (x != 0)
46     link_error ();
47   x = 1;
48   local_address_taken (&y);
49   /* As we are computing flow- and context-insensitive we may not
50      CSE the load of x here.  */
51   /* { dg-final { scan-tree-dump " = x;" "fre" } } */
52   return x;
53 }
54
55 /* { dg-final { cleanup-ipa-dump "pta" } } */
56 /* { dg-final { cleanup-tree-dump "fre" } } */