Aliasing: look through pointer's def stmt

Marc Glisse marc.glisse@inria.fr
Fri Oct 25 10:57:00 GMT 2013


On Fri, 25 Oct 2013, Richard Biener wrote:

> Ah, so you are looking at call_may_clobber_ref_p_1 and its pointer handling
> when special-casing builtins?

Yes.

> Note that fields can only be disambiguated
> if the size of the access is known

TBAA could also help sometimes.

> (not sure what fancy attribute you are going to invent here ...).

That will certainly require quite a bit of discussion...

> Generally the simple alias machinery is written to be cheap,

I wouldn't mind an expensive version ;-)

> walking use-def chains isn't.

Peeking at the defining statement shouldn't be very costly, as long as you 
don't do it recursively.

> no need to look at gimple_has_volatile_ops (stmt).

Ok.

> Also you want to handle
>
> p_2 = p_1 + CST;
> foo (p_2);
>
> which has a related canonical form,
>
> p_2 = &MEM[p_1, CST];

This testcase seems relevant, I'll see if I can handle it:

void f (const char *c, int *i)
{
   *i = 42;
   __builtin_memcpy (i + 1, c, sizeof (int));
   if (*i != 42) __builtin_abort();
}

> The patch is ok with the volatile check removed, you can followup
> with handling POINTER_PLUS_EXPR if you like.

Thanks.

-- 
Marc Glisse



More information about the Gcc-patches mailing list