<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br>On Jun 30, 2010, at 9:21 PM, Chris Lattner wrote:<br><br><blockquote type="cite"><blockquote type="cite"><br>Then there's "arguments can't alias allocas" logic. From a non-interprocedural<br></blockquote><blockquote type="cite">perspective, this works. From an interprocedural perspective, consider<br></blockquote><blockquote type="cite">function r0 in the included testcase.<br></blockquote><br>Again, this is only true if AA were a context or path sensitive interface, but it isn't.  GlobalModRef is an example of a context sensitive analysis which is queried with a context insensitive interface.  DSA (in the poolalloc module) is another.  To be able to do context sensitive queries, you have to be able to pass information into the clients.  I am pretty sure that I covered this in my phd thesis if you care.<br></blockquote><br><div>Let me put this a different way.  The AliasAnalysis interface is *really only intended* for context insensitive clients.  DSA provides a series of passes (bottom-up, top-down etc) which context sensitive clients can use to get specific information.  The DSA algorithm captures a bunch of information into various data structures, which aren't directly useful for implementing AA.</div><div><br></div><div>When it comes to actually implementing the AA interface with the DSA information (section 4.2 of <a href="http://llvm.org/pubs/2005-05-04-LattnerPHDThesis.pdf">http://llvm.org/pubs/2005-05-04-LattnerPHDThesis.pdf</a>), the problem comes down to using the information captured by the previous passes to respond to the various queries.</div><div><br></div><div>For example, the alias query (when both pointers are global or within the same function) find the function the pointer is in and devolves to looking in that one graph.  Amusingly, the implementation currently asserts if the pointers are in two different functions:</div><div><br></div><div><a href="http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructureAA.cpp?revision=HEAD&view=markup">http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructureAA.cpp?revision=HEAD&view=markup</a></div><div>...</div><div><br></div><div><span class="Apple-style-span" style="font-family: monospace; white-space: pre; "><pre>AliasAnalysis::AliasResult DSAA::alias(<b><font color="#228B22">const</font></b> Value *V1, <b><font color="#228B22">unsigned</font></b> V1Size,
                                       <b><font color="#228B22">const</font></b> Value *V2, <b><font color="#228B22">unsigned</font></b> V2Size) {
  assert(valid && <b><font color="#BC8F8F">"DSAA invalidated but then queried?!"</font></b>);
  <b><font color="#A020F0">if</font></b> (V1 == V2) <b><font color="#A020F0">return</font></b> MustAlias;

  DSGraph *G1 = getGraphForValue(V1);
  DSGraph *G2 = getGraphForValue(V2);
  assert((!G1 || !G2 || G1 == G2) && <b><font color="#BC8F8F">"Alias query for 2 different functions?"</font></b>);

  <i><font color="#B22222">// Get the graph to use...
</font></i>  DSGraph* G = G1 ? G1 : (G2 ? G2 : TD->getGlobalsGraph());

</pre><pre><span class="Apple-style-span" style="font-family: Helvetica; white-space: normal; ">This is basically saying "get the one functions graph if either pointer is local to a function, otherwise get the globals graph if they are both global".  The assertion will trigger if you have pointers within different functions.  Asserting in this case is lame of course (DSA should just return MayAlias), but we don't have any clients that make that query.</span></pre><pre><span class="Apple-style-span" style="font-family: Helvetica; white-space: normal; ">The DSA information is used in more interesting ways for mod/ref queries.  To answer whether a call to a function modifies an alloca in the caller, for example, it does some heavy graph mapping/manipulation which *is* context sensitive.  However, this is still within the context-sensitive query API.</span></pre><pre><span class="Apple-style-span" style="font-family: Helvetica; white-space: normal; ">I don't think we need the "IP BasicAA" pass: if you agree, please remove it.</span></pre><pre><font class="Apple-style-span" face="Helvetica"><span class="Apple-style-span" style="white-space: normal;">-Chris</span></font></pre></span></div></body></html>