1 |
689 |
jeremybenn |
/* { dg-do link } */
|
2 |
|
|
/* { dg-options "-O2 -fipa-pta -fdump-ipa-pta-details -fdump-tree-fre2" } */
|
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 |
|
|
void *anyfn_global;
|
19 |
|
|
|
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" "pta" } } */
|
23 |
|
|
void (*ex)(int *) = local_address_taken;
|
24 |
|
|
|
25 |
|
|
extern void link_error (void);
|
26 |
|
|
|
27 |
|
|
int main()
|
28 |
|
|
{
|
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 }" "pta" { xfail *-*-* } } } */
|
42 |
|
|
/* { dg-final { scan-ipa-dump "local_address_taken.clobber = { ESCAPED NONLOCAL y x }" "pta" { xfail *-*-* } } } */
|
43 |
|
|
/* { dg-final { scan-ipa-dump "local_address_taken.use = { }" "pta" { xfail *-*-* } } } */
|
44 |
|
|
/* ??? But make sure x really escaped. */
|
45 |
|
|
/* { dg-final { scan-ipa-dump "ESCAPED = {\[^\n\}\]* x \[^\n\}\]*}" "pta" } } */
|
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;" "fre2" } } */
|
58 |
|
|
return x;
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
/* { dg-final { cleanup-ipa-dump "pta" } } */
|
62 |
|
|
/* { dg-final { cleanup-tree-dump "fre2" } } */
|