<div dir="ltr">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.<div><br></div><div>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.</div><div><br>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.</div><div>:)</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 1, 2016 at 8:52 PM, Daniel Berlin <span dir="ltr"><<a href="mailto:dberlin@dberlin.org" target="_blank">dberlin@dberlin.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Wed, Jun 1, 2016 at 8:35 PM, Ahmed Bougacha <span dir="ltr"><<a href="mailto:ahmed.bougacha@gmail.com" target="_blank">ahmed.bougacha@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Clang already has this: -fstrict-aliasing, which enables struct-path<br>
aware TBAA, via !tbaa metadata.<br></blockquote><div><br></div></span><div>There are plenty of cases it does not generate good tbaa or struct path tbaa. :)</div><span class=""><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>
That TBAA isn't sufficient is intentional though: you're probably<br>
hitting the return PartialAlias at the end of BasicAAResult::aliasGEP<br>
(PR9971).<br></blockquote><div><br></div></span><div>This is a different case, and easily resolvable with info that says it is part of a union or not.</div><div><br></div><div>At least, GCC does not pretend to okay non-explicit union accesses.</div><div>See <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65892" target="_blank">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65892</a></div><div>and <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319" target="_blank">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319</a><br></div><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<span><font color="#888888"><br>
-Ahmed<br></font></span></blockquote><div><br></div></div></div></div>
</blockquote></div><br></div>