http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54256

             Bug #: 54256
           Summary: IPA-SRA debug info issues
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: ja...@gcc.gnu.org
                CC: jamb...@gcc.gnu.org, jan.kratoch...@redhat.com


struct A
{
#ifdef PAD
  void *c;
#endif
  struct A *a;
  void *b;
};

typedef int FN (struct A *);
extern void *v;
struct A *fn (void);

void
foo (FN *y, int z)
{
  struct A *x = fn ();
  baz (x, y, z);
}

static int
bar (FN *x, struct A *y, int z, int w)
{
  if (v)
    undef (8, v);
  (*x) (y->a);
}

int
baz (struct A *x, FN *y, int z)
{
  bar (y, x, z, 0);
  return 0;
}

at -g -O2 doesn't provide debug info for the foo y parameter, eventhough it
actually is passed.  The reason for that seems to be that IPA-SRA? decides to
not pass struct A *, but actually struct A ** instead (address of the a field
of a, i.e. essentially the exactly same pointer), we generate
DW_OP_GNU_parameter_ref but in the end at the call site the argument isn't
available (it is only available in the called function).
Not sure why IPA-SRA does this change (and with -DPAD it is actually a code
pessimization), supposedly because it hopes for scalarization opportunities in
the caller which at the end don't come though.

I've tried:
struct A { void *c; struct A *a; void *b; };
typedef int FN (struct A *);
extern void *v;
struct A *fn (void);

void
foo (FN *y, int z)
{
  struct A x = { fn (), 0 };
  baz (&x, y, z);
}

static int
bar (FN *x, struct A *y, int z, int w)
{
  if (v)
    undef (8, v);
  (*x) (y->a);
}

int
baz (struct A *x, FN *y, int z)
{
  bar (y, x, z, 0);
  return 0;
}

but even that isn't scalarized in the caller, so I wonder when it is actually
useful this way.

Reply via email to