[PATCH] More precise aliasing for char arrays

Sanjin Sijaric ssijaric at codeaurora.org
Wed Jun 25 14:21:33 PDT 2014


Hi,

 

The following patch aims to address bug #20074, and similar ones.  The
problem is that accesses to elements in constant-sized char arrays end up
annotated with TBAA tags that have base as "omnipotent char", so they'll
alias with pointers other than pointers to char.  This prevents some
optimizations, such as removing redundant loads in bug #20074.  Or in the
case of the attached test cases, it prevents hoisting of loads from loops.
The fix is to change the base type to that of "char" if we know we are
dealing with constant sized char arrays.   In effect, this mimics the
behaviour of aliasing generated for other types of arrays (e.g. the base
type is not the "omnipotent char", but there is a path that eventually leads
to it).  I didn't attempt to address VLAs.

 

Can someone please review?

 

Thanks,

Sanjin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140625/8baefd27/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tbaa-char-arrays.patch
Type: application/octet-stream
Size: 5233 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140625/8baefd27/attachment.obj>


More information about the cfe-commits mailing list