On Thu, Nov 23, 2017 at 11:30:22AM +0100, Richard Biener wrote:
> FAIL: gcc.c-torture/execute/builtins/memcpy-chk.c execution,  -O2 
> ...
> FAIL: gcc.c-torture/execute/builtins/memmove-chk.c execution,  -O2 
> ...
> FAIL: gcc.c-torture/execute/builtins/strncat-chk.c execution,  -O2 
> ...
> FAIL: gcc.dg/builtin-object-size-4.c execution test
> 
> where I looked into the object-size case.  For
> 
>   r = &a.a[4];
>   r = memset (r, 'a', 2);
>   if (__builtin_object_size (r, 3) != sizeof (a.a) - 4)
>     abort ();
>   r = memset (r + 2, 'b', 2) + 2;
>   if (__builtin_object_size (r, 3) != sizeof (a.a) - 8)
>     abort ();
> 
> FRE now propagates &a.a[4] + CST adjustments through the memsets
> and constant folds the last __builtin_object_size check to false.

That is because it tests a [13] mode which as you know is fragile and
doesn't like any kind of folding into MEM_REFs where the original access
path (&a.a[4] + 4) is lost.  So, if it is match.pd that does this, whatever is
doing it there should be also guarded with cfun->after_inlining.
While mode 3 is probably never used in real-world, mode 1 is used a lot and
so we shouldn't regress that.

BTW, seems pass_through_call could now use ERF_RETURNS_ARG stuff
except for __builtin_assume_aligned which intentionally doesn't have
ret1 because we really don't want to "optimize" it by propagating the
first argument to its uses too early.  I'll handle it.
Though, with your changes perhaps there won't be any pass through calls
anymore except for __builtin_assume_aligned.

        Jakub

Reply via email to