[LLVMdev] fastcc, tail calls, and gcc

Jon Harrop jon at ffconsultancy.com
Thu Feb 12 23:26:33 PST 2009


On Thursday 12 February 2009 16:34:54 Jeff Kuskin wrote:
> Two related questions.
>
> This is with LLVM 2.4 doing a JIT compile to x86-64.  (I generate LLVM
> IR using an IRBuilder instance, compile/optimize, and then call
> getPointerToFunction() to get a "native" function pointer.)
>
>
> (1) My reading of various mailing list messages seems to indicate
> that a function marked as using the "fastcc" calling convention
> ("CallingConv::Fast") cannot be called directly from GCC-generated
> code (n.b. -- standalone gcc, not llvm-gcc) because the fastcc calling
> convention is, in general, incompatible with GCC (which I assume uses
> the "CallingConv::C" calling convention).
>
> Correct?

Yes.

> If not, how do I call a LLVM JIT-generated fastcc function 
> from a function statically compiled by GCC?

You also JIT compile a shim function that is exposed with the C calling 
convention but contains a fastcc call to your internal function. Note that 
you may also need to rejig argument passing with things like sret.

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e



More information about the llvm-dev mailing list