[gambit-list] gambit + llvm

Marc Feeley feeley at iro.umontreal.ca
Mon Sep 22 15:19:15 EDT 2008


I haven't looked at LLVM since its first release, and following your  
post I took a new look and see that there has been quite a lot of  
evolution.  I think it would be interesting to have a LLVM back-end  
for Gambit, mainly because it would allow portable native code  
generation.  Going to machine code (through LLVM) would avoid the use  
of trampolines (to implement tail calls), and this could have a  
significant impact on performance of multi-module programs.  It would  
also have a significant impact on the compactness of the machine code  
generated (once again because the trampoline machinery could be  
avoided).

For fun I tried compiling Gambit with llvm-gcc on my Mac OS X machine  
using

    % ./configure CC=llvm-gcc --enable-single-host
    % make

llvm-gcc is the gcc compiler version 4.2.1 with a code generator which  
goes through LLVM version 2.3.

The good news is that this works with the current Gambit v4.2.8 with  
only minor warnings (due to the configure script thinking the standard  
Mac OS X gcc is being used and passing it options that llvm-gcc knows  
nothing about).

The bad news is that the compile time is really high (10 minutes for  
some of the larger C files like lib/_num.c and lib/_io.c) and the  
execution speed if often lower than when using the standard gcc.   
Perhaps that's just because my standard gcc is version 4.0.1 and the  
compiler's optimization algorithms are different.  Also, for an  
unknown reason, I/O is particularly slow.  For your information I have  
made a table of benchmarks comparing the execution time for various  
settings (compiling with standard gcc and -O1, -O2, and -O3, and  
compiling with llvm-gcc).  The table is at http://www.iro.umontreal.ca/~feeley/bench-llvm-gcc.html 
  .

The poor performance obtained with llvm-gcc does not mean that a LLVM  
back-end for Gambit would yield poor performance.  However it does  
point to some aspects which are a source of concern, and need to be  
looked into.

If anyone is interested in contributing to implement an LLVM back-end  
for Gambit, please send me an email.  I can guide you through the  
steps required.

Marc


On 21-Sep-08, at 10:41 AM, Andrew I. Schein wrote:

> Hi all -
>
> I am wondering if there are any efforts underway to port gambit to a  
> llvm back end?  Would this provide opportunity to eliminate a  
> trampoline, at least in certain cases?
>
> -A
>
> -- 
> web: www.andrewschein.com
>
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list




More information about the Gambit-list mailing list