[LLVMdev] C infinite recursion mis-optimized?

Duncan Sands baldrick at free.fr
Sun Feb 28 04:39:16 PST 2010


Hi Isaac,

> For fun, I made a recursive function, but LLVM optimized it wrong (if
> I'm understanding C standards correctly).
>
> "void f() { f(); }"[see llvm-code in footnote 1]
> was optimized to be equivalent to "void f() {}"[also 1].  I believe it
> should either be equivalent in effect to "void f() { while(1){} }"[2],
> which produces an infinite loop, or perhaps lead to a stack overflow (as
> GCC might produce)... it's alright if the infinite loop is written using
> tail-calls. All I expect is that it never actually return when you run it.

this sounds like a manifestation of bug 965, see http://llvm.org/PR965

Ciao,

Duncan.



More information about the llvm-dev mailing list