[LLVMdev] how to eliminate dead infinite loops?

Chris Lattner clattner at apple.com
Mon Nov 29 10:40:11 PST 2010


>> In addition to being able to delete noop loops that traverse over pointer-based data structures, this will also solve the:
>> 
>>   for (unsigned i = 0; i<= N; ++i)
>> 
>> class of problems.
> 
> Also not relevant to Ada!

Ada?  What's that? ;-)

> Do you have a suggestion for how best to enable this optimization for some
> languages and disable it for others?

Sure, there are two ways to go:

1. Assume that loops are never infinite and add IR support to say that a loop *is*.
2. Assume that loops are possibly infinite and add IR support to say that a loop *isn't*.

I'm just saying I'm in favor of #1.  This could take the form of an intrinsic that gets called in loop headers or something.

-Chris



More information about the llvm-dev mailing list