<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000'><br><hr id="zwchr"><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>From: </b>"Chandler Carruth" <chandlerc@gmail.com><br><b>To: </b>"Hal Finkel" <hfinkel@anl.gov><br><b>Cc: </b>"Mehdi Amini" <mehdi.amini@apple.com>, "via llvm-dev" <llvm-dev@lists.llvm.org>, "Xinliang David Li" <davidxl@google.com><br><b>Sent: </b>Monday, April 18, 2016 5:20:59 PM<br><b>Subject: </b>Re: [llvm-dev] Move InlineCost.cpp out of Analysis?<br><br><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Apr 18, 2016 at 3:16 PM Hal Finkel <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: rgb(0, 0, 0);"><br><br><hr><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>From: </b>"Chandler Carruth" <<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>><br><b>To: </b>"Hal Finkel" <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>><br><b>Cc: </b>"Mehdi Amini" <<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>>, "via llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>, "Xinliang David Li" <<a href="mailto:davidxl@google.com" target="_blank">davidxl@google.com</a>><br><b>Sent: </b>Monday, April 18, 2016 4:54:36 PM</blockquote></div></div><div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: rgb(0, 0, 0);"><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><br><b>Subject: </b>Re: [llvm-dev] Move InlineCost.cpp out of Analysis?<br><br><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Apr 18, 2016 at 2:46 PM Hal Finkel <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: rgb(0, 0, 0);"><br><br><hr><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>From: </b>"Chandler Carruth" <<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>><br><b>To: </b>"Xinliang David Li" <<a href="mailto:davidxl@google.com" target="_blank">davidxl@google.com</a>><br><b>Cc: </b>"Mehdi Amini" <<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>>, "Hal Finkel" <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>>, "via llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br><b>Sent: </b>Monday, April 18, 2016 4:31:05 PM<br><b>Subject: </b>Re: [llvm-dev] Move InlineCost.cpp out of Analysis?</blockquote></div></div><div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: rgb(0, 0, 0);"><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><br><br><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Apr 18, 2016 at 2:28 PM Xinliang David Li <<a href="mailto:davidxl@google.com" target="_blank">davidxl@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Apr 18, 2016 at 2:18 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr">The difference between Analysis and Transforms is *not* about passes, but about what the code *does*.<div><br></div><div>Code for mutating the IR should be in Transforms, and code that analyzes the IR without mutating it should be in Analysis. This is why, for example, InstructionSimplify is in Analysis -- it does not mutate the IR in any way.</div><div><br></div><div>So I think InlineCost and similar things should stay in the Analysis library regardless of whether they are passes or not.</div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Is that the only criteria (IR mod or not) ?</div></div></div></div></blockquote><div><br></div><div>Given a public API, yes, that should be the only criteria IMO.</div><div> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> Most of the transformations have pass specific analysis (that are not shared with other clients) -- those code stay with the transformation -- it does not make sense to move those code in to Analysis.</div></div></div></div></blockquote><div><br></div><div>But I would expect these to also not expose public APIs to the analyses. Provided the public API is limited to the transformation, I think the code be closely located makes sense.</div></div></div></blockquote></div></div><div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: rgb(0, 0, 0);"><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"></blockquote>I'm not sure the situation is as clear cut as you make it out to be. We can factor common components out of different transformations (e.g. out of different inliner implementations), including common components that don't modify the IR, without that component forming what I would generally consider an analysis. In this case, we're really talking about the encapsulation of the inliner's cost heuristic, and the generality of this information is questionable. To put it another way, while I'm fine with someone reusing this logic to build a new inliner, I'd be very skeptical of using it for any other purpose. That's why it does not really feel like an analysis to me. This is not a strong feeling, however, and I'm also fine with it staying in Analysis.</div></div></blockquote><div><br></div><div>I don't think that everything that is an analysis needs to be completely general though. Certainly, we need to be very clear and careful in what terms we describe the API to make the quality and nature of the results unsurprising, but I think that the API around the inline cost is reasonably good about that -- it seems to pretty clearly indicate that this is a threshold determining mechanism and not something that provides a holistic view of the impact of a potential inlining decision.</div><div><br></div><div>I actually think it would be good if essentially *everything* we can put a reasonable public API around and which doesn't mutate the IR were moved to the analysis library. As an example of why I think this, without this it is very hard to know what code can be re-used in analysis passes. And the constraint there is really exactly this: it has a public API that can be re-used, and it doesn't mutate the IR. Nothing more or less that I see.</div><div><br></div><div><br></div><div>Naturally, we don't need to go on a campaign to move everything *right now*, and we can even be fairly lazy about it, but I do think that this direction is the correct long-term design of the libraries here.</div></div></div>
</blockquote></div></div><div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: rgb(0, 0, 0);"><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"></blockquote>In general I agree, but the inliner's cost heuristic is a bit special in this regard. It is special because it contains tuned thresholds that are meaningful only in the context of inlining as performed by the current inliner. Were we to change the inliner's overall scheme (e.g. made it more top-down) those would need to change. If someone wanted to build some higher-level analysis that made use of the InlineCost information, the fact that they had to move things from Transforms/Utils to Anslysis would be a good red flag that they're probably using the wrong tool. Obviously it might be the right tool, but it is probably something we'd want to think about. A second inliner, however, might be sufficiently close in design to the current one that the tuned thresholds might be applicable.<br><br>In short, I like your proposal, but I'd further propose that we say that anything that does not mutate the IR and does not make assumptions about its ultimate client should be an analysis.</div></div></blockquote><div><br></div><div>But everything makes assumptions about its client? That's the whole point of having a public API -- you need to be able to document your assumptions well enough to have a reasonable public API. But that's not about analysis vs. transforms, that's really true for *any* public API. For example, I would expect anything in Transforms/Utils to document very clearly what assumptions they make about their callers.</div><div><br></div><div>And I'm not even sure I buy that our inline cost is *that* specialized... It uses TTI, another analysis, for estimating cost. It is essentially a size cost estimation tool. The closest thing to this kind of assumption are the *thresholds* is uses. Those should really be clear input parameters so that callers can customize it.</div><div><br></div><div id="DWT13232">Anyways, all of this is to say that I don't think the inline cost's public API is in great shape, but I don't think it is inherently without a reasonable public API. So I suspect we should be more trying to improve the clarity and configurability of its API rather than moving things around.</div></div></div></blockquote>I don't disagree with any of this. Nevertheless, in its current state, it is essentially a transformation utility (for inlining transformations sufficiently similar to our base inliner). We might be able to improve it to make it more general, in which case it should indeed definitely live in the analysis folder.<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div dir="ltr"><div class="gmail_quote"><div></div><div><br></div><div id="DWT13233">But all of this is a digression. Let's get back to the meat of the subject around ProfileData.</div></div></div></blockquote>Sure ;)<br><br> -Hal<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div dir="ltr"><div class="gmail_quote"><div></div><div><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: rgb(0, 0, 0);"><br><br> -Hal</div></div><div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: rgb(0, 0, 0);"><br><br>-- <br><div><span></span>Hal Finkel<br>Assistant Computational Scientist<br>Leadership Computing Facility<br>Argonne National Laboratory<span></span><br></div></div></div></blockquote></div></div>
</blockquote><br><br><br>-- <br><div><span name="x"></span>Hal Finkel<br>Assistant Computational Scientist<br>Leadership Computing Facility<br>Argonne National Laboratory<span name="x"></span><br></div></div></body></html>