| 1 |
/* https://bugzilla.redhat.com/show_bug.cgi?id=521991#c5 |
| 2 |
|
| 3 |
Distilled from Linux XFS source code. foo, inlined into bar, ends |
| 4 |
up with debug stmts referencing the addressable variable b. |
| 5 |
Optimization made it non-addressable, and then completely optimized |
| 6 |
away, before we got a chance to rename (and discard) the occurrence |
| 7 |
in the debug stmt. When we did, we crashed, attempting to rename |
| 8 |
an unreference variable. */ |
| 9 |
|
| 10 |
/* { dg-do compile } */ |
| 11 |
|
| 12 |
static inline int |
| 13 |
foo (void *x, unsigned y) |
| 14 |
{ |
| 15 |
unsigned z = *(unsigned long *) x % y; |
| 16 |
*(unsigned long *) x = *(unsigned long *) x / y; |
| 17 |
return z; |
| 18 |
} |
| 19 |
|
| 20 |
struct S |
| 21 |
{ |
| 22 |
unsigned t; |
| 23 |
}; |
| 24 |
|
| 25 |
void |
| 26 |
bar (struct S *x, int *y) |
| 27 |
{ |
| 28 |
int a = 0; |
| 29 |
unsigned long b = x->t; |
| 30 |
foo (&b, x->t); |
| 31 |
for (;; a++) |
| 32 |
if (b) |
| 33 |
*y = 1; |
| 34 |
} |