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

--- Comment #19 from Siddhesh Poyarekar <siddhesh at gcc dot gnu.org> ---
(In reply to Siddhesh Poyarekar from comment #17)
> (In reply to qinzhao from comment #16)
> > I feel that propagating the size through _5 = *_1 might not be correct in
> > general, we should only limit it to the case when the RHS is a pointer
> > defined by .ACCESS_WITH_SIZE?
> 
> That propagation is not incorrect, but it is incomplete, since (TIL) a
> MEM_REF with zero offset could be the LHS of a valid gimple statement as
> well.  However AFAICT there's no way to directly reach it like in case of an
> SSA, you'll need to walk the function to find the statement with a matching
> LHS.

Actually, I think you may be right; I've been turning this over in my head and
I can't think of any other situation where the propagation is correct, i.e.
other than the .ACCESS_WITH_SIZE case.  In fact, maybe the .ACCESS_WITH_SIZE
handling in objsz probably needs improvement to express it better, but that's
an orthogonal matter.

So it should in fact be just B as far as this issue is concerned.  That is, for
a _n = *_p case, only look at the size of _p if it is a .ACCESS_WITH_SIZE.

There is a use case for A where we should be looking through vdefs to find
memory writes to *_p that allocate memory, but it's an orthogonal case.  I've
filed it as bug 120947 now.

Reply via email to