| 1 |
/* This testcase is to make sure we have i in referenced vars and that we |
| 2 |
properly compute aliasing for the loads and stores. */ |
| 3 |
|
| 4 |
extern void abort (void); |
| 5 |
|
| 6 |
static int i; |
| 7 |
static int *p = &i; |
| 8 |
|
| 9 |
int __attribute__((noinline)) |
| 10 |
foo(int *q) |
| 11 |
{ |
| 12 |
*p = 1; |
| 13 |
*q = 2; |
| 14 |
return *p; |
| 15 |
} |
| 16 |
|
| 17 |
int __attribute__((noinline)) |
| 18 |
bar(int *q) |
| 19 |
{ |
| 20 |
*q = 2; |
| 21 |
*p = 1; |
| 22 |
return *q; |
| 23 |
} |
| 24 |
|
| 25 |
int main() |
| 26 |
{ |
| 27 |
int j = 0; |
| 28 |
|
| 29 |
if (foo(&i) != 2) |
| 30 |
abort (); |
| 31 |
if (bar(&i) != 1) |
| 32 |
abort (); |
| 33 |
if (foo(&j) != 1) |
| 34 |
abort (); |
| 35 |
if (j != 2) |
| 36 |
abort (); |
| 37 |
if (bar(&j) != 2) |
| 38 |
abort (); |
| 39 |
if (j != 2) |
| 40 |
abort (); |
| 41 |
|
| 42 |
return 0; |
| 43 |
} |