[PATCH] D20665: Claim NoAlias if two GEPs index different fields of the same struct

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 1 21:54:21 PDT 2016


Also note: The question of whether two fields at different offsets alias is
pretty much completely unrelated to TBAA, and should not, IMHO, be tied in
any way to strict aliasing, only to language semantics.

I haven't surveyed tons of other compilers here, but I know that GCC
believes this :). It will still disambiguate fields at different offsets
regardless of the setting of strict-aliasing.

This is because the type-based aliasing rules of C are completely unrelated
to the definedness of trying to access a different field member by offset
trickery.
:)



On Wed, Jun 1, 2016 at 8:52 PM, Daniel Berlin <dberlin at dberlin.org> wrote:

>
>
> On Wed, Jun 1, 2016 at 8:35 PM, Ahmed Bougacha <ahmed.bougacha at gmail.com>
> wrote:
>
>> Clang already has this: -fstrict-aliasing, which enables struct-path
>> aware TBAA, via !tbaa metadata.
>>
>
> There are plenty of cases it does not generate good tbaa or struct path
> tbaa. :)
>
>
>>
>> That TBAA isn't sufficient is intentional though: you're probably
>> hitting the return PartialAlias at the end of BasicAAResult::aliasGEP
>> (PR9971).
>>
>
> This is a different case, and easily resolvable with info that says it is
> part of a union or not.
>
> At least, GCC does not pretend to okay non-explicit union accesses.
> See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65892
> and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319
>
>
>
>>
>> -Ahmed
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160601/8fee2db5/attachment.html>


More information about the llvm-commits mailing list