PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / ipa / ipa-pta-13.c
blob93dd87107cc0a62812fbf2c58f8e0bbae5dfa268
1 /* { dg-do link } */
2 /* { dg-options "-O2 -fipa-pta -fdump-ipa-pta2-details -fdump-tree-fre3 -fno-ipa-icf" } */
4 static int x, y;
6 static __attribute__((noinline,noclone)) void
7 local (int *p)
9 *p = 1;
12 static __attribute__((noinline,noclone)) void
13 local_address_taken (int *p)
15 *p = 1;
18 void *anyfn_global;
20 /* Even though not referenced in this TU we should have added constraints
21 for the initializer. */
22 /* { dg-final { scan-ipa-dump "ex = &local_address_taken" "pta2" } } */
23 void (*ex)(int *) = local_address_taken;
25 extern void link_error (void);
27 int main()
29 void (*anyfn)(int *) = (void (*)(int *))(__SIZE_TYPE__)anyfn_global;
30 /* The following should cause local_address_taken to get &x
31 as argument, but not local. We shouldn't get &x added to
32 arbitrary special sub-vars of local_address_taken though,
33 a missed optimization currently.
34 As local_address_taken escapes the translation unit its
35 argument points-to set needs to include ESCAPED and NONLOCAL.
36 We shouldn't get the functions sub-vars in the ESCAPED solution
37 though, another missed-optimization. This also causes the functions
38 uses to be messed up even further. */
39 /* ??? As we don't expand the ESCAPED solution we either get x printed here
40 or not based on the phase of the moon. */
41 /* { dg-final { scan-ipa-dump "local_address_taken.arg0 = { ESCAPED NONLOCAL y x }" "pta2" { xfail *-*-* } } } */
42 /* { dg-final { scan-ipa-dump "local_address_taken.clobber = { ESCAPED NONLOCAL y x }" "pta2" { xfail *-*-* } } } */
43 /* { dg-final { scan-ipa-dump "local_address_taken.use = { }" "pta2" { xfail *-*-* } } } */
44 /* ??? But make sure x really escaped. */
45 /* { dg-final { scan-ipa-dump "ESCAPED = {\[^\n\}\]* x \[^\n\}\]*}" "pta2" } } */
46 (*anyfn) (&x);
47 x = 0;
48 local (&y);
49 /* Thus we should be able to disambiguate x against the call to local
50 and CSE the stored value. */
51 if (x != 0)
52 link_error ();
53 x = 1;
54 local_address_taken (&y);
55 /* As we are computing flow- and context-insensitive we may not
56 CSE the load of x here. */
57 /* { dg-final { scan-tree-dump " = x;" "fre3" } } */
58 return x;