As we chatted about offline, i think we all agree this ordering is completely and utterly broken <br>(right now it's BasicAA,ScopedAA, TBAA, CFLAA), and that BasicAA should really be going last.<div>But this is also currently deliberate to "support type punning".[1]</div><div><div><br></div><div>But i'm not in for fixing that right now, and it doesn't change that CFLAA was not delegating properly, and doesn't change how to fix this CFLAA bug :)</div><div><br></div><div>Patch updated to revert ordering changes and attached</div><div><br></div><div>[1] I know you have some ideas on how to fix this, but actually, I wonder if it wouldn't be better to move deliberate type punning into it's own AliasAnalysis, where the behavior will be both obvious and hopefully written well. Then we can just run that at the top of the stack.  Certainly, your way was easier :)</div><div><br></div></div><br><div class="gmail_quote">On Fri Jan 16 2015 at 1:11:46 PM Chandler Carruth <<a href="mailto:chandlerc@google.com">chandlerc@google.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I'm pretty sure I had the ordering of the passes backwards. The previous ordering is correct.  Sorry for the confusion.<div><br></div><div>The last alias analysis created is the first one queried. It delegates to the previous alias analysis created. At least, that is my reading of this (very confusing) code.</div><div><br></div><div>The most frustrating aspect of this is that it means the delegation behavior of CFL shouldn't have mattered at all because BasicAA ran first... However BasicAA does do its own caching, so who knows.</div></div><div class="gmail_extra"><br><div class="gmail_quote"></div></div><div class="gmail_extra"><div class="gmail_quote">On Fri, Jan 16, 2015 at 12:22 PM, Daniel Berlin <span dir="ltr"><<a href="mailto:dberlin@dberlin.org" target="_blank">dberlin@dberlin.org</a>></span> wrote:<br></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Okay, overnight i ran a ton of tests on this patch, and it seems right.<div>Nick, Hal, can you review it?</div><div><br></div><div>I've reattached it for simplicity</div><div><br></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 15, 2015 at 3:05 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>On Thu, Jan 15, 2015 at 1:26 PM, Nick Lewycky <span dir="ltr"><<a href="mailto:nlewycky@google.com" target="_blank">nlewycky@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On 15 January 2015 at 13:10, 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Yes.<div>I've attached an updated patch that does the following:<br><br></div><div>1. Fixes the partialalias of globals/arguments</div><div>2. Enables partialalias for cases where nothing has been unified to a global/argument</div><div>3. Fixes that select was unifying the condition to the other pieces (the condition does not need to be processed :P). This was causing unnecessary aliasing.</div></div></blockquote><div><br></div></span><div>Consider this:<br></div><div><br></div><div>void *p = ...;</div><div>uintptr_t i = p;</div><div>uintptr_t j = 0;</div><div>for (int a = 0; a < sizeof(uintptr_t); ++a) {</div><div>  j = i >> (sizeof(uintptr_t) - a - 1) ? 1 : 0;</div><div>  j <<= 1;</div><div>}</div><div>void *q = j;</div><div><br></div><div>alias(p, q) isn't NoAlias. (Okay, it kinda is in C++, but not in the equivalent LLVM IR. Please don't make me rewrite my example in LLVM IR.)</div><span><font color="#888888"><div><br></div></font></span></div></div></div></blockquote></span><div>Agreed :)</div><div><br></div><div>But after chatting with you, i think we both agree that this change does not affect.</div><div>I probably should not have said "the condition does not need to be processed".  It would be more accurate to say "the reference to a condition in a select instruction, by itself, does not cause aliasing" </div><div><br></div><div>What happens now is:</div><div><br></div><div>given %4 = select %1, %2, %3</div><div><br></div><div>we do</div><div>aliasset(%4) += %1</div><div>aliasset(%4) += %2</div><div>aliasset(%4) += %3</div><div> </div><div>The first one is unnecessary.</div><div>There can be no alias caused simply because it is referenced in condition of the select.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><font color="#888888"></font></span></div></div></div></blockquote><div>We still need to process what %1 refers to (and we do).</div><div><br></div><div><br></div><div>To make this empirical, in your example, we get the right answer in CFL-AA.</div><div><br></div><div>Interestingly, i'll point out that basic-aa says:<br><div>  NoAlias:<span style="white-space:pre-wrap">        </span>i8* %p, i8** %q</div><div>  NoAlias:<span style="white-space:pre-wrap">       </span>i8** %p.addr, i8** %q</div></div><div><br></div><div>(I translated your case as best i can :P)</div><div><br></div><div>So you may want to implement it for real if you think it's supposed to be handled right in basic-aa, because I don't believe it is :)</div><div><br></div></div></div></div>
</blockquote></div><br></div>
</div></div><br></blockquote></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div></div></blockquote></div>