Fortran and LLVM

Hi all,

I'm looking into using LLVM to do some optimisations of
Fortran code. As part of this, I've been trying to build
the frontend with f95 support. At the moment, I'm trying
to resolve undefined symbol problems for code defined in
c-common.c + elsewhere - I'm taking the temporary approach
of copy-pasting it into a new file, and linking that in. I have no
idea if it will work, but you can't just link c-common.o in, because then
you get multiple definitions of some symbols.

However, judging from past threads on here, it seems that getting
gfortran support will require a lot of work. I've also seen
people who use LLVM and Fortran to compile the SPEC FP benchmarks -
the NAG compiler has been mentioned in this context. I have two
questions here:

1. I know someone previously tried to get gfortran working - did their
changes make it into the SVN mainline?

2. How do you go about hooking LLVM into the NAG compiler? Does
it emit an IR that LLVM recognises?

Cheers,
Warren

NAG compiler does not emit LLVM IR. However you can take longer
route. NAG compiler emits ā€˜cā€™ code that you can feed into llvm-gcc.
I have not tried this myself :slight_smile:

Hi all,

I'm looking into using LLVM to do some optimisations of
Fortran code. As part of this, I've been trying to build
the frontend with f95 support. At the moment, I'm trying
to resolve undefined symbol problems for code defined in
c-common.c + elsewhere - I'm taking the temporary approach
of copy-pasting it into a new file, and linking that in. I have no
idea if it will work, but you can't just link c-common.o in, because then
you get multiple definitions of some symbols.

However, judging from past threads on here, it seems that getting
gfortran support will require a lot of work. I've also seen
people who use LLVM and Fortran to compile the SPEC FP benchmarks -
the NAG compiler has been mentioned in this context. I have two
questions here:

1. I know someone previously tried to get gfortran working - did their
changes make it into the SVN mainline?

Hi Warren, I think here you're referring to me. Some of my changes did
make it into the mainline, to the extent that you can produce an f95
binary that will compile correct LLVM code for some very small set of
toy fortran programs, but it chokes on real code.

The reason I stopped working on it is that the version of gfortran
that is on the LLVM branch is buggy and the latest version is rather
different, and the effort required to reconcile the changes in either
direction was too much to consider seriously.

I'd still like to get gfortran+LLVM working, but at least for my part,
I'm waiting until the LLVM-gcc4 tree is updated to a more current gcc,
with a more stable gfortran to start from.

-mike

Michael McCracken wrote:

FWIW, we use NAG on Darwin/PPC with the fortran programs in SPECCPU2000 and it works fine. It outputs C code which we feed into llvm-gcc.

-Chris