[LLVMdev] Is infinite empty loop dead code?

Krzysztof Parzyszek kparzysz at codeaurora.org
Wed Nov 14 09:53:10 PST 2012

On 11/14/2012 1:23 AM, Shuxin Yang wrote:
>      Is it legal to delete empty infinite loop like this : "while(1) {}"?

If the loop was reachable, the program will not terminate.  If you 
delete the loop, where is the execution going to go after this point? 
You can't arbitrarily insert a branch to somewhere or instructions to 
execute.  If the loop was unreachable, then it doesn't matter if you 
delete it or not unless you want to reduce code size, but regardless of 
that, if you can prove that it's unreachable then you can delete it as 
such and then it doesn't matter what it does.


Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation

More information about the llvm-dev mailing list