[LLVMdev] how to eliminate dead infinite loops?

Frits van Bommel fvbommel at gmail.com
Fri Nov 26 14:52:31 PST 2010


On Fri, Nov 26, 2010 at 11:14 PM, Andrew Clinton <andrew at sidefx.com> wrote:
> I'm thinking a good way to support this feature would be to add a new
> function attribute "AlwaysReturn" that would indicate that a function
> does not contain any infinite loops, so that the LoopDeletion pass and
> others could treat it accordingly.  What do you think?

That's probably the best way to really fix this, yes. I'd go for a
different name though, since 'AlwaysReturn' implies the function
doesn't throw any exceptions, which is a separate issue already
addressed by 'nounwind'.

You'll also want some way to set the attribute. Ideally, some pass
would automatically set it on appropriate functions. For some of the
other attributes -functionattrs does this. It'd probably be a decent
place to set the attribute for simple non-looping functions, but
getting the best results probably requires something like
ScalarEvolution analysis so I'm not sure if this would be appropriate
there.

Eventually llvm-gcc/dragonegg/clang should also have support for an
explicit attribute to set this, but first it should work :).

> What's the best way for me to submit changes back to the LLVM repository?

Assuming the question means you don't have commit access, just send
one or more patches to llvm-commits at cs.uiuc.edu.




More information about the llvm-dev mailing list