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.
Just a clarification here, I just want the SFT for k.j to be considered call clobbered for this testcase.
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".
Would be quite useful, though, for languages that do not have/allow pointer arithmetic.
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;
Fixed on the trunk by the IPA modref improvements.