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

--- Comment #10 from Martin Jambor <jamborm at gcc dot gnu.org> ---
Created attachment 32574
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32574&action=edit
WIP patch displaying IPA-CP information aout clones

This is an untested and very much WIP patch that shows how we can
print additional information about clones, at least about those
created by IPA-CP.  Of course eventually it should not be in the
front-end.  It also retains more information in memory, although not
that much.

For the source below, it produces the following output:

mjambor@virgil:~/gcc/mine/tests/pr60761-clonenames$ ~/gcc/mine/inst/bin/g++ -O3
-S -Wall aa.C -fno-inline
aa.C: In function ‘void foo(int, A*) <clone with 4 for s, 10 for data pointed
to by  a at offset 32>’:
aa.C:19:20: warning: iteration 3u invokes undefined behavior
[-Waggressive-loop-optimizations] 
     z[i] = i + a->j;
                    ^
aa.C:18:3: note: containing loop
   for (int i = 0; i < s; i++)
   ^
aa.C:19:8: warning: array subscript is above array bounds [-Warray-bounds]
     z[i] = i + a->j;


the source code is:

extern int sum;

void do_sum (char *p)
{
  for (int i = 0; i < 2; i++)
    sum += p[i];
}

struct A
{
  int i, j, k;
};

void
foo (int s, struct A *a)
{
  char z[3];
  for (int i = 0; i < s; i++)
    z[i] = i + a->j;
  do_sum (z);
}

int
bar (int i)
{
  struct A a;
  a.j = 10;
  foo (4, &a);
  return 0;
}

Reply via email to