[LLVMdev] opt -std-compile-opts breaks tail calls

David Terei davidterei at gmail.com
Thu Nov 12 20:57:43 PST 2009


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.

I haven't fully investigated this yet so not really sure if it is
specific to my case or applies universally but it sure did cause me
some pains for a while.

2009/11/12 Paul Davey <plmdvy at gmail.com>:
> tail calls are only implemented for fastcall calling convention if i remeber
> right from my inquiries.
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>




More information about the llvm-dev mailing list