<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Jun 12, 2016 at 9:31 PM, Yichao Yu <span dir="ltr"><<a href="mailto:yyc1992@gmail.com" target="_blank">yyc1992@gmail.com</a>></span> wrote:<span class=""></span><br><span class=""></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> Alias analysis results should not be confused with value equivalence (though<br>
> it is common).  MustAlias or NoAlias implies nothing about the actual<br>
> pointer value, only the abstract memory location it represents.<br>
<br>
</span>I can understand they are not equivalent but shouldn't not being the<br>
same pointer value be a necessary condition for NoAlias? In another<br>
word, are the following valid?<br>
<br>
```<br>
define i64 @f1(i64 *%p0, i64 *%p1) {<br>
  store i64 0, i64 *%p0, !tbaa !0<br>
<span class="">  %v2 = load i64, i64 *%p1, !tbaa !1<br>
</span>  ret %v2<br>
}<br>
<br>
define i64 @f2(i64 *%p1) {<br>
  store i64 0, i64 *%p1, !tbaa !0<br>
<span class="">  %v2 = load i64, i64 *%p1, !tbaa !1<br>
</span>  ret %v2<br>
}<br>
<br></blockquote><div><br></div><div>It depends on what you mean by "valid"... @f1 passed two identical pointers is basically equivalent to "ret i64 undef".  Whether this is a problem depends on what the caller does.  (LLVM actually special-cases constructs like @f2, but that isn't really relevant to this discussion.)<br><br></div><div>And this is precisely the point: for the sake of simplifying branches and loops, we want to allow hoisting as much as possible, so LLVM is very generous about what is actually undefined behavior compared to C.  So you can load from an uninitialized variable, or load a value using the wrong TBAA tag, or overflow an addition marked nsw, as long as the behavior of the program doesn't actually depend on those results.<br><br></div><div>Given that, there isn't any reason to throw away the TBAA tag when LLVM hoists (or otherwise inserts) a load.<br></div></div><br></div><div class="gmail_extra">-Eli<br></div></div>