summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/debug/vta-1.c
blob: 414083a09c019702636585142b6422c62e225d08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* https://bugzilla.redhat.com/show_bug.cgi?id=521991#c5

   Distilled from Linux XFS source code.  foo, inlined into bar, ends
   up with debug stmts referencing the addressable variable b.
   Optimization made it non-addressable, and then completely optimized
   away, before we got a chance to rename (and discard) the occurrence
   in the debug stmt.  When we did, we crashed, attempting to rename
   an unreference variable.  */

/* { dg-do compile } */

static inline int
foo (void *x, unsigned y)
{
  unsigned z = *(unsigned long *) x % y;
  *(unsigned long *) x = *(unsigned long *) x / y;
  return z;
}

struct S
{
  unsigned t;
};

void
bar (struct S *x, int *y)
{
  int a = 0;
  unsigned long b = x->t;
  foo (&b, x->t);
  for (;; a++)
    if (b)
      *y = 1;
}