[LLVMdev] RFC: Tail call optimization X86

Gordon Henriksen gordonhenriksen at mac.com
Fri Oct 5 14:01:21 PDT 2007


On 2007-10-05, at 13:56, Arnold Schwaighofer wrote:

> On 5 Oct 2007, at 19:41, Evan Cheng wrote:
>
>> In theory, any function can be marked fastcc. But llvm-gcc c / c++  
>> frontend does *not* mark any external functions fastcc. Also, the  
>> optimizer only changes the calling convention of internal  
>> functions to fastcc.
>
> well i hope llvm-gcc won't stay the only front-end (hoping to see  
> some functional languages like ocaml ;)

Just chiming in here since a stated goal is something I'm working on.  
Tail calls and calling conventions aren't yet a problem for me, but  
they're definitely on the radar.

As context, my current goal is to support the existing Ocaml runtime  
with my LLVM-based compiler, despite the peculiarities of the runtime.

Ocaml supports tail calls by never pushing arguments onto the stack.  
On x86, the first five arguments are passed using %eax, %ebx, %ecx, % 
edx, and %esi (left to right) and the sole return value is passed in % 
eax. (Ocaml never performs dynamic allocas, and so always performs  
frame pointer elimination. Floats are passed by reference.) The front- 
end will address the case of additional arguments.

For my implementation of ocamlopt, the most useful LLVM features in  
this area would be would be support for the above cc, and tail calls  
for the inreg case. The former seems to be fairly well trivial;  
hopefully your work could be tweaked to accomplish the latter.

— Gordon



More information about the llvm-dev mailing list