<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br></div><div><br>On Oct 11, 2013, at 12:16 AM, Daniel Berlin <<a href="mailto:dberlin@dberlin.org">dberlin@dberlin.org</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Oct 10, 2013 at 9:34 PM, Chris Lattner <span dir="ltr"><<a href="mailto:clattner@apple.com" target="_blank">clattner@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div class="im"><div>On Oct 10, 2013, at 8:53 PM, Daniel Berlin <<a href="mailto:dberlin@dberlin.org" target="_blank">dberlin@dberlin.org</a>> wrote:</div>
<blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><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 style="word-wrap:break-word"><div>The datastructures and algorithms we have are powerful enough to express these sorts of things, and so long as a frontend abided by the rules, there shouldn't be a problem.</div>
</div></blockquote>
<div><br></div><div><br>My concerns are simply that whether designed this way or not, it ends up fairly inconsistent.<br></div><div><br></div><div>For example, what would the plan be when a frontend does something like clang does now for C/C++ (generate type based TBAA), and also wants to do something like Filip is suggesting (which is also doable on C/C++ with simple frontend analysis)?<br>
</div></div></div></div></blockquote><div><br></div></div><div>There are two possible answers here, depending on the constraints:</div><div><br></div><div>1. The frontend author could unify them into one grand tree, like struct field TBAA does.</div>
</div></div></blockquote><div><br></div><div>I would be impressed if you could unify the output of something like andersens, and something like the current nested TBAA structure, without massive loss of precision.</div><div>
 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div>2. The frontend author could model them as two separate TBAA trees, which the TBAA machinery in LLVM handles conservatively.</div>
<div><br></div><div>The conservative handling of different TBAA trees is critical, because you can LTO (for example) Javascript into C++ code in principle, each using their own TBAA structure.  LLVM is already well set for this, and it isn't an accident :-)</div>
<div class="im"><div><br></div><br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>
</div><div>You also run into issues with the existing metadata on loads/stores in this situation. It's again, entirely possible for a load to conflict with both a tbaa type, and a partitioned heap.    In Filip's scheme, there is no way to represent this. </div>
</div></div></div></blockquote><div><br></div></div><div>I'm not sure what you mean. </div></div></div></blockquote><div><br></div><div>I mean it's not possible, in this scheme, to specify both to be used for disambiguation.</div>
<div><br></div><div>Right now, you get *one* tbaa tag on the load.</div><div>So you have to choose which tree you use if you want if you choose option #2 above.</div><div><br>You always have to choose one or the other, or else the lose the disambiguation.</div>
<div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div> The compiler will handle this conservatively.</div>
</div></div></blockquote><div><br></div><div>Only if you drop the tags/disambiguation capability from most things, or i'm seriously confused.</div><div><br></div><div>let's take the following not-quite llvm-ir, but close enough.</div>
<div><br></div><div><br></div><div>!tbaa tree</div><div><br></div><div>0 -> everything</div><div><br></div><div>1 (parent 0) -> int</div></div></div></div></div></blockquote><div><br></div><div>This. </div><div><br></div><div>It's a C-ism, and you'd only have a TBAA tree for it if you lacked any other information.</div><div><br></div><div>Hence if you had abstract heaps (such as ones you get from field names in Java-esque type systems, or tuple entry IDs in ML-esque type systems, etc) you wouldn't be sweating about reconciling that with a tree that talked about types. </div><div><br></div><div>(As an aside, I'm sort of bothered by the implication that abstract heaps aren't types. A type is nothing more than a set of values. For a pointer that means an abstract set of heap locations. So, my use of TBAA corresponds exactly to "types" in *some* language.)</div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>2 (parent 0 -> heap a</div><div><br></div><div>load <whatever> , !tbaa 1</div>
<div><br></div><div>call !tbaa.read 2</div><div><br></div><div><br></div><div>Note: You can't specify tbaa.read 2, 1 (at least as proposed).</div><div>the current machinery will say the call and the load never conflict.</div>
<div><br></div><div>It would seem you have to either make heap tags also children of appropriate type tags, or only ever use one type of tree<br></div><div>What design for a split tree would work here?<br></div><div><br></div>
<div>I also can't think of a combined tree that would work without massive precision loss.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">
<div><div> If you have two different schemas existing in the same application (e.g. due to LTO or due to a language implementing two different non-unified models for some weird reason) then the compiler just doesn't draw any aliasing implications from references using two different schemas.</div>
<div><br></div></div></div></blockquote><div>Which is of course, bad.</div><div>You should in fact, be able to draw implications from both.  If the design essentially only allows one to draw from one, that seems like a pretty big flaw.</div></div></div></div></div></blockquote><div><br></div><div>I agree that TBAA would be more powerful if you could say something like:</div><div><br></div><div>load blah !tbaa.list !42</div><div><br></div><div>42 = (!tbaa !1, !tbaa !2, ...</div><div><br></div><div>But it would probably also be more expensive to process such richer information, particularly if you had it on each load. I'd be inclined to bet that the current TBAA, even with its limitations, is a sensible compromise.</div><div><br></div><div>OTOH, being able to list types that are affected by a call would be great. </div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<div> </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div></div><div>It is possible in principle to allow a load (for example) to have an arbitrary number of TBAA tags on it, which would solve this (allowing a single load to participate in multiple non-overlapping schemas) but I don't think it is worth the complexity at all.</div>
</div></div></blockquote><div><br></div><div>Okay then, we'll agree to disagree. :)</div><div><br></div><div>This actually happens a lot of the time.  Restricting llvm to essentially choosing one tree per load to use for disambiguation, as this scheme will do, when it's not much more work to do better, seems shortsighted to me.</div></div></div></div></div></blockquote><div><br></div><div>If someone hacked up a !tbaa.list, I would definitely try it out!</div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><span class="HOEnZb"><font color="#888888"><br></font></span></div>
<span class="HOEnZb"><font color="#888888"><div>-Chris</div><br></font></span></div></blockquote></div><br></div></div>
</div></blockquote></body></html>