[LLVMdev] fastcc, tail calls, and gcc
Jeff Kuskin
jk500500 at yahoo.com
Thu Feb 12 08:34:54 PST 2009
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? If not, how do I call a LLVM JIT-generated fastcc function
from a function statically compiled by GCC?
(2) Why does the x86-64 JIT backend generate a "ret $0x8" instruction
to return from a fastcc function that is (a) marked as fastcc
(CallingConv::Fast); but (b) takes no arguments and returns 'void'?
The function type is this:
std::vector<const Type*> args; /* empty */
FunctionType *ft = FunctionType::get(Type::VoidTy, args, false);
The fastcc generated code ends with this:
c20800 ret $0x8
However, if I instead mark the very same function to use the usual
CallingConv::C calling convention, then the generated code ends
with this:
c3 ret
I assume the "ret 0x8" is meant to be the "callee pops args" portion
of the fastcc convention, but in this case the function has no
arguments (nor a return value), so why should 8 bytes be popped from
the stack on return?
Thanks for any help.
-- Jeff Kuskin
More information about the llvm-dev
mailing list