[LLVMdev] opt -std-compile-opts breaks tail calls
overminddl1 at gmail.com
Fri Nov 13 03:40:02 CST 2009
Resent, to the list this time instead of David (sorry for the duplicate)...
On Thu, Nov 12, 2009 at 9:57 PM, David Terei <davidterei at gmail.com> wrote:
> I've run into some issues with tail calls in the past, make sure you
> are doing the following:
> 1. Call should be marked with tail (obviously)
> 2. Next statement after tail call should be 'return void'
> 3. Use fast call convention for tail calls
> 4. Make sure the function you are calling doesn't use the 'noreturn' attribute.
> 5. Turn on tail calls in llc (if using the static compiler), with
> '-tailcallopt' option.
> Point 4 is the one that caused me trouble for some time. Unfortunately
> it causes a bad interaction with the optimiser, specifically the
> 'simplifycfg' pass. What seems to happen is that since the function
> you are calling is marked with 'noreturn', the simplifycfg pass will
> then put a 'unreachable' statement after the tail call to that
> function. This stuffs up the tail call though as the llc compiler
> requires tail calls be followed by a 'return void' statement. In my
> case this caused my compiled programs to segfault if the llvm
> optimiser was run on them.
Just to make sure, but if a tail call function returns a value, can
you not just return that value directly by your function and have tail
calls still work?
More information about the LLVMdev