[fpc-devel] The 15k bounty: Optimizing executable speed for Linux x86 / LLVM

Jonas Maebe jonas at freepascal.org
Thu Oct 25 18:59:47 CEST 2018


On 20/10/18 16:07, Simon Kissel wrote:
> - Complete the LLVM branch of FPC. It looks like Jonas has stopped
>    working on it two years ago, which is a pity.

I didn't stop working on it, but I didn't make real progress anymore 
either. The current state of the LLVM code generator is that everything 
works on Darwin/x86-64, except for
a) exception handling in general: indeed needs DWARF-EH support in the 
RTL, and also support for the LLVM exception handling intrinsics in the 
code generator. I've worked on and off on this and have some local 
patches, but it's not complete
b) hardware exceptions (null pointer, floating point): the LLVM versions 
I worked with back then did not support support any form of hardware 
exceptions. If a memory access faults, the result is undefined behaviour 
(even with full exception support in the LLVM IR). If a floating point 
instruction  throw an exception, the result is undefined (although they 
have been working a bit on it since then). This is not something that 
can be changed/fixed in FPC, and is quite different from how FPC's 
current code generator works (I don't know how Embarcardero deals with 
it in their LLVM-based code generator).

Additionally, in the current FPC code generator global variables behave 
mostly as volatile variables. With LLVM, that won't be the case (unless 
we mark all of their accesses as volatile, but that would obviously 
inhibit LLVM optimizations). This may break some multithreaded code that 
currently works, and would probably require the introduction of a 
volatile() operatator (similar to the unaligned() one). On the other 
hand, I already added support for tracking the volatile state of 
references in the past, so that should be easy to do.


Jonas



More information about the fpc-devel mailing list