Bug 24169 - Address (full struct) escapes even though the called function does not cause it to escape
Address (full struct) escapes even though the called function does not cause ...
Status: NEW
Product: gcc
Classification: Unclassified
Component: tree-optimization
4.1.0
: P2 enhancement
: ---
Assigned To: Not yet assigned to anyone
: alias, missed-optimization
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-10-02 20:32 UTC by Andrew Pinski
Modified: 2010-07-16 08:29 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.1.0
Last reconfirmed: 2010-07-16 08:29:05


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2005-10-02 20:32:31 UTC
Just like PR 23134, here is another testcase for the aliasing thinking that the address escapes but this time it has SFT's involved and we should not have a V_MAY_DEF for k.i:
static void f(char *a)
{
  *a = 1;
}

struct g
{
  char i, j;
};

void h(void)
{
  struct g k = {2, 2};
  f(&k.j);
  if (k.i != 2)
    link_error ();
}

Compile with -O2 -fno-inline to force f not to inline.
Comment 1 Andrew Pinski 2006-01-01 00:41:44 UTC
Just a clarification here, I just want the SFT for k.j to be considered call clobbered for this testcase.
Comment 2 Daniel Berlin 2006-01-03 14:58:44 UTC
Subject: Re:  Address (full struct) escapes
	even though the called function does not cause it to escape

On Sun, 2006-01-01 at 00:41 +0000, pinskia at gcc dot gnu dot org wrote:
> 
> ------- Comment #1 from pinskia at gcc dot gnu dot org  2006-01-01 00:41 -------
> Just a clarification here, I just want the SFT for k.j to be considered call
> clobbered for this testcase.
> 
This is not anywhere near as easy as you think it is.

In fact, we used to only call clobber k.j.  Because our standards
experts tell us that doing pointer arithmetic magic to get back to k.i
is legal, we could only consider this function to clobber *just* k.j if
the pointer doesn't escape from f, *and* f does not do any pointer
arithmetic on it's arguments.

This is usually *not* the case, making this testcase more or less "not
interesting at all".


Comment 3 Steven Bosscher 2010-07-15 22:50:25 UTC
Would be quite useful, though, for languages that do not have/allow pointer arithmetic.
Comment 4 Richard Biener 2010-07-16 08:29:05 UTC
IPA-PTA computes the required information (but we do not store sub-field
granular points-to or clobber sets):

h.clobber = { k.8+8 }
h.use = { }
f.clobber = { k.8+8 } same as f.arg0
f.use = { }
f.arg0 = { k.8+8 }
k.0+8 = { }
k.8+8 = { }

<bb 2>:
  k.i = 2;
  k.j = 2;
  # CLB = { k }
  f (&k.j);
  D.2724_1 = k.i;
  if (D.2724_1 != 2)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:
  # USE = nonlocal
  # CLB = nonlocal
  link_error ();

<bb 4>:
  return;