<div class="gmail_quote">On Tue, Jul 6, 2010 at 1:54 PM, Chris Lattner <span dir="ltr"><<a href="mailto:clattner@apple.com">clattner@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div style="word-wrap: break-word;"><div><div class="im"><div>On Jul 6, 2010, at 1:50 PM, Nick Lewycky wrote:</div><blockquote type="cite"><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div>>  * a new pass named HaltingAttr is added to mark up functions with the halting attribute. If necessary, it queries SCEV for an upper bound on the loop trip count. It is not an SCC pass.<br>
<br>
</div>Why can't this be done in the existing bottom-up pass for inferring this?<br></blockquote><div><br>SCC passes can't depend on FunctionPasses like LoopInfo and SCEV.<br></div></div></blockquote><div><br></div>

</div><div>I think that having the existing SCC pass propagate the bit from callee to caller where possible makes sense.  How does a function pass know it is going to visit a callee before a caller?  For a function to be "halting" all called functions also have to be known to halt.</div>

</div></div></blockquote><div><br>I tried that. The problem with splitting it into two passes is that the pass doing the local analysis can't safely mark any non-leaf function since the callees haven't been tagged 'halting' yet, and the SCC pass can't mark anything halting since it doesn't have a local analysis to check for loops inside the function itself. Hence they need to be merged.<br>

</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div style="word-wrap: break-word;"><div><div class="im"><blockquote type="cite"><div class="gmail_quote">

<div>Also, we can't make use of SCC anyhow because two functions that halt locally but also call each other aren't necessarily halting; they could recurse infinitely. However, having the CallGraphNode* is useful to avoid a linear scan looking for CallInst's as it already has the list.<br>

</div></div></blockquote><div><br></div></div><div>Are you saying that you really have to give up on any non-leaf function?</div></div></div></blockquote><div><br>It's still a bottom-up walk of the call graph, it's just that we can't take advantage of SCCs to infer the property.<br>

</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div style="word-wrap: break-word;"><div><div class="im"><blockquote type="cite"><div class="gmail_quote">

<div>Finally, my patch was missing the part where I actually add HaltingAttr to the list of standard passes. I need to think more about where I want to schedule this; I really want it after the loop optimizations but before the inliner makes its decision. A CGSCCPass would be perfect, were it not for the inability to depend on LoopInfo and SCEV.<br>

</div></div></blockquote><div><br></div></div><div>At the high level, this is the part I'm most concerned with.</div></div></div></blockquote><div><br>Likewise, I hadn't realized how bad it was before sending out the original patch. Once I figure this out I'll send out an patch update.<br>

<br>It's possible that there's no good solution here and we just plain need to run the -haltingattr pass before the inliner and loop passes. That would be sad, but not the end of the world. We could deal with the cause of that (undesirable pass manager constraints) separately. Since CallGraph is in lib/Analysis, it's yet another hard problem.<br>

<br>Nick<br></div></div><br>