[llvm-commits] patch: add 'halting' function attribute

Nick Lewycky nicholas at mxc.ca
Tue Jul 6 13:50:50 PDT 2010


On Tue, Jul 6, 2010 at 1:47 PM, Chris Lattner <clattner at apple.com> wrote:

>
> On Jul 5, 2010, at 9:33 PM, Nick Lewycky wrote:
>
> > 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 llvm.org/PR965
>
> Hi Nick,
>
> I haven't had a chance to look at the patch yet, some thoughts:
>
> >  * modifies the asm printer and parser, LangRef and VMCore to support the
> new bit
> >  * all intrinsics are marked with 'halting' as they are with 'nounwind'
> >  * the -simplify-libcalls pass now marks certain (non-I/O) library
> functions as being halting
>
> Ok.
>
> >  * 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.
>
> Why can't this be done in the existing bottom-up pass for inferring this?
>

SCC passes can't depend on FunctionPasses like LoopInfo and SCEV.

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.

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.

Nick


>
> >  * Instruction::mayHaveSideEffects considers not halting to be a
> side-effect
> >  * 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.
>
> Makes sense.
>
> -Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100706/e5ce8e42/attachment.html>


More information about the llvm-commits mailing list