<div class="gmail_quote">On Tue, Jul 6, 2010 at 1:47 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 class="im"><br>
On Jul 5, 2010, at 9:33 PM, Nick Lewycky wrote:<br>
<br>
> The attached patch adds a function attribute, "halting", which models the assertion that a function does not have the side-effect of looping indefinitely. This is for <a href="http://llvm.org/PR965" target="_blank">llvm.org/PR965</a><br>


<br>
</div>Hi Nick,<br>
<br>
I haven't had a chance to look at the patch yet, some thoughts:<br>
<div class="im"><br>
>  * modifies the asm printer and parser, LangRef and VMCore to support the new bit<br>
>  * all intrinsics are marked with 'halting' as they are with 'nounwind'<br>
>  * the -simplify-libcalls pass now marks certain (non-I/O) library functions as being halting<br>
<br>
</div>Ok.<br>
<div class="im"><br>
>  * 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><br>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>

<br>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>

<br>Nick<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 class="im"><br>
>  * Instruction::mayHaveSideEffects considers not halting to be a side-effect<br>
>  * Instruction::isSafeToSpeculativelyExecute will now return true for some call instructions (only for intrinsics marked 'readnone nounwind halting'). LLVM was audited to make sure this was safe, the only change made for it is in lib/Transforms/Scalar/Sink.cpp.<br>


<br>
</div>Makes sense.<br>
<font color="#888888"><br>
-Chris</font></blockquote></div><br>