| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O -fdump-tree-optimized" } */ |
| 3 |
/* { dg-add-options bind_pic_locally } */ |
| 4 |
|
| 5 |
union X { |
| 6 |
int i; |
| 7 |
void *p; |
| 8 |
}; |
| 9 |
void bar (int); |
| 10 |
|
| 11 |
int * __attribute__((noinline,noclone)) |
| 12 |
baz (int *p) { return p; } |
| 13 |
|
| 14 |
void foo (union X *x) |
| 15 |
{ |
| 16 |
struct Y { int i; } ystruct = {}; |
| 17 |
ystruct.i = * baz (&ystruct.i); |
| 18 |
bar (x->i); |
| 19 |
} |
| 20 |
|
| 21 |
/* DSE and then DCE should be able to remove all uses of ystruct. |
| 22 |
Formerly the union access for the parameter to bar let 'anything' |
| 23 |
escape which made the call to bar possibly use ystruct and thus |
| 24 |
prevent the store to ystruct.i from being eliminated. The call to |
| 25 |
baz makes sure that ystruct has its address taken. */ |
| 26 |
|
| 27 |
/* { dg-final { scan-tree-dump-not "ystruct" "optimized" } } */ |