https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105346

--- Comment #9 from rguenther at suse dot de <rguenther at suse dot de> ---
On Tue, 26 Apr 2022, jakub at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105346
> 
> --- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> Started with r11-5732-gdce6c58db87ebf7f4477bd3126228e73e4eeee97
> The IL at -O0 -Wall looks during waccess pass like:
> void foo ()
> {
>   char * bufp;
>   char buf[20];
> 
>   <bb 2> :
>   bufp_2 = &buf;
>   if (&buf != bufp_2)
>     goto <bb 3>; [INV]
>   else
>     goto <bb 4>; [INV]
> 
>   <bb 3> :
>   __builtin_free (bufp_2);
> 
>   <bb 4> :
>   buf ={v} {CLOBBER(eol)};
>   return;
> 
> }
> 
> So, I think the waccess pass must be walking SSA_NAME_DEF_STMT to figure out 
> it
> is a free of non-heap.  Either it shouldn't do that at -O0, or it should only
> walk them when they are in the same bb as the free call, or it needs to be 
> able
> to detect also conditionals like the above.

It's using the ptr-query framework which discovers the bufp_2 equivalence
but doesn't notice the conditional "invalidating" it.

Reply via email to