[fpc-devel] LLVM

Jonas Maebe jonas.maebe at elis.ugent.be
Thu Dec 15 08:35:47 CET 2016


Michael Schnell wrote:
> I remember that some time ago an LLVM version of fpc was under discussion.
> 
> I'd like to know the state.

If you don't perform control-flow-based LLVM optimizations, almost
everything works on Darwin/x86-64 (and Linux/x86-64, except for safecall
-- the reason for this extra is that safecall is simply ignored on
Darwin). There are currently about 40 testsuite failures left on
Darwin/x86-64 with LLVM, compared to 26 without LLVM.

With such optimizations enabled, everything apart from try/except and
try/finally should work:
* "should" because I did not actually test this, given that exceptions
are pretty common and hence it's not possible to get a baseline
* it's a pretty big "apart from", obviously. I have some ideas on how to
fix this without breaking compatibility with code produced by the
regular code generators, but I'm still working on it.

Note that even once I fix this, exceptions still won't work equally well
as with our regular code generators, due to the points mentioned under
point 3 of "Progress" at http://wiki.freepascal.org/LLVM

> Background: I might be interested in doing a project that runs in the
> browser. It seems that the upcoming technology for this is WebAssembly.
> I found that an LLVM backend for WebAssembly somewhere is under
> construction.

You would also have to write a WebAssembly RTL for FPC, and you would
have to add some FPC code generator support for a WebAssembly target
(see the first FAQ on the wiki page mentioned above). LLVM IR is by
construction architecture- and platform-specific. It's not like Java
bytecode or CIL (or, for that matter, WebAssembly).


Jonas



More information about the fpc-devel mailing list