<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jun 12, 2016 at 9:04 PM, Yichao Yu <span dir="ltr"><<a href="mailto:yyc1992@gmail.com" target="_blank">yyc1992@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Sun, Jun 12, 2016 at 11:48 PM, Daniel Berlin <<a href="mailto:dberlin@dberlin.org">dberlin@dberlin.org</a>> wrote:<br>
><br>
><br>
> On Sun, Jun 12, 2016 at 8:03 PM, Yichao Yu via llvm-commits<br>
> <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
>><br>
>> yuyichao added a comment.<br>
>><br>
>> In another word, IMHO,<br>
>><br>
>>   %v1 = load i64, i64 *%p1, !tbaa !0<br>
>>   %v2 = load i64, i64 *%p1, !tbaa !1<br>
>><br>
>> should be invalid IR (and the optimizer should not be allowed to create<br>
>> this) if `!1` and `!2` are non-aliasing tbaa node.<br>
><br>
> Why?<br>
> It's entirely possible to create a language where this is a valid and useful<br>
> lowering.<br>
> TBAA applies *to the load*, not to the *pointer*, and the langref says<br>
> nothing about it requiring it to assign consistent TBAA nodes to different<br>
> loads of the same pointer.<br>
><br>
<br>
</div></div>My understanding is that the tbaa metadata is used for alias analysis.<br></blockquote><div>Yes </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What should be the result of the alias analysis on the two loads in<br>
this case? </blockquote><div><br></div><div>It is valid to say no alias or must-alias.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Won't<br>
tbaa return no aliasing while some other returns always aliasing for<br>
this case?<br></blockquote><div><br></div><div>Yes.</div><div>This is pretty typical.</div><div><br></div><div><br></div><div>IE in C,</div><div><br></div><div>int * foo;</div><div>float *bar;</div><div><br></div><div>*bar;</div><div>foo = (int *)bar;</div><div>*foo;</div><div><br></div><div>You have two loads, TBAA will say they do not alias, anything else will say they are must-alias.</div><div><br></div><div><br></div><div>In any sane situation, aliasing must be treated as a lattice, and you take the "best" answer.</div><div><br></div><div>Alias analysis results should not be confused with value equivalence (though it is common).  MustAlias or NoAlias implies nothing about the actual pointer value, only the abstract memory location it represents.</div><div><br></div><div>--Dan</div><div><br></div><div><br></div></div></div></div>