[LLVMdev] Is infinite empty loop dead code?

Shuxin Yang shuxin.llvm at gmail.com
Wed Nov 14 11:24:04 PST 2012


Thank you all for the input. Seems that I have to prove a non-countable 
loop is finite before I can delete it.

BTW, I think this draft is not clear as to what  is "constant expr". The 
source code may use symbolic value,
but later on the symbolic value could be proved to be constant. However, 
compiler could mistakenly delete the loop before that
point.

Thank you all for the input again!

Shuxin

On 11/14/12 11:01 AM, Krzysztof Parzyszek wrote:
> On 11/14/2012 12:07 PM, Shuxin Yang wrote:
>>
>> If it is reachable, that is bit difficult to tell. Now that C std
>> already give compiler such permit, perhaps we don't have to keep
> > in sync with gcc.
>
> From the C standard (well, draft):
>
> ----
> 6.8.5 Iteration statements
> [...]
>
> An iteration statement whose controlling expression is not a constant 
> expression, that performs no input/output operations, does not access 
> volatile objects, and performs no synchronization or atomic operations 
> in its body, controlling expression, or (in the case of a "for" 
> statement) its expression-3, may be assumed by the implementation to 
> terminate.
> ----
>
> This still doesn't allow you to remove "while(1) {}", since the 
> controlling expression *is* a constant expression.
>
>
> -Krzysztof
>
>




More information about the llvm-dev mailing list