[LLVMdev] how to eliminate dead infinite loops?

Owen Anderson resistor at mac.com
Wed Nov 24 15:56:25 PST 2010


On Nov 24, 2010, at 12:36 PM, Nick Lewycky wrote:

> Andrew Clinton wrote:
>> Most of my programs contain loops that the LoopDeletion pass is unable
>> to remove.  It appears that the following code in LoopDeletion.cpp:152
>> is the culprit:
>> 
>>    ScalarEvolution&  SE = getAnalysis<ScalarEvolution>();
>>    const SCEV *S = SE.getMaxBackedgeTakenCount(L);
>>    if (isa<SCEVCouldNotCompute>(S))
>>      return Changed;
>> 
>> So, LoopDeletion thinks my loops might be infinite so it does not delete
>> them - even if they do not write to any of the function return values.
>> Is there a way to flag a loop as non-infinite?  Or will I need to create
>> my own modified loop deletion pass that can eliminate potentially
>> infinite loops.  Is it correct just to remove the above code to allow
>> deletion of infinite loops?
> 
> I think what you actually want is the ADCE pass (opt -adce). The reason 
> we turned ADCE off by default is that it kept deleting infinite loops, 
> and the LoopDeletion pass was written as a safe replacement.

This is incorrect.  ADCE does not remove infinite loops either, as doing
so would be semantics-changing transformation.

--Owen



More information about the llvm-dev mailing list