[LLVMdev] Tail-calling

Albert Graef Dr.Graef at t-online.de
Fri Sep 12 01:22:50 PDT 2008


Arnold Schwaighofer wrote:
> Take this with a grain of salt or two since i have never done it ;)
> but i guess that setting those globals is what
> cl::ParseCommandLineOptions does in lli/llc.cpp.

I can confirm that this is actually how it works (fastcc on the function 
+ setTailCall on the call instruction + llvm::PerformTailCallOpt = 
true). I might add that of course you also have to make sure that the 
tail call is immediately before a ret instruction. :)

Note that it also depends on the JIT for the target architecture whether 
this is actually supported. I verified that this does work on x86, -64. 
Not sure about the status on other archs, though, it seems that at least 
the LLVM 2.2 JIT didn't do any proper tail calls on ppc yet.

Albert

-- 
Dr. Albert Gr"af
Dept. of Music-Informatics, University of Mainz, Germany
Email:  Dr.Graef at t-online.de, ag at muwiinfa.geschichte.uni-mainz.de
WWW:    http://www.musikinformatik.uni-mainz.de/ag



More information about the llvm-dev mailing list