rjmccall added a comment.

In https://reviews.llvm.org/D31885#755456, @kparzysz wrote:

> In https://reviews.llvm.org/D31885#751164, @rjmccall wrote:
>
> > The right fix is probably just to make sure that EmitLValueForField doesn't 
> > add TBAA information when the base LValue doesn't have it.  That will also 
> > fix problems with recursive member access where the base is may_alias.
>
>
> That won't work for arrays that are member of unions.  We'd need to change 
> EmitArraySubscriptExpr, which at some point calls MakeAddrLValue for the type 
> being loaded/stored. MakeAddrLValue adds TBAAInfo for that type (unsigned 
> short in case of the C testcase) and it does so regardless of any struct 
> paths. This TBAA info must be removed for the testcase to be fixed.  At that 
> point we would have to examine the base expression to see if it refers to a 
> union member, which is not different from the approach in this review.  The 
> LValue construction is done in a piecewise manner where some elements of the 
> previously (recursively) created LValues may or may not be preserved.  This 
> makes me concerned that any more detailed attempt at fixing this may 
> accidentally omit some case.


That is a reasonable concern.

Hmm.  It seems to me that we do already propagate an important semantic 
property from the base l-value in every important case: the alignment source.  
That audit has already been done, and all you really need to do do is 
generalize it: look at all the places that generically propagate an 
AlignmentSource, e.g. EmitPointerWithAlignment and almost everywhere that calls 
LValue::getAlignmentSource(), and make them propagate an LValueBaseInfo (or 
whatever) instead.  You can then make sure that may_alias-ness is stored in an 
LValueBaseInfo along with the alignment source, and then suppress TBAA when a 
base info is known to be may_alias, and then your temporary fix is just to make 
all union accesses unconditionally set may_alias to true.


Repository:
  rL LLVM

https://reviews.llvm.org/D31885



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to