[fpc-pascal] inlining functions

Jonas Maebe jonas at freepascal.org
Wed Jan 2 00:41:01 CET 2019


On 2019-01-02 00:19, Benito van der Zander wrote:

> procedure TStrBuilder.append(const s: RawByteString);
> begin
> append(pchar(pointer(s)), length(s)); //inlinetest.pas(24,3) Note: Call 
> to subroutine "procedure TStrBuilder.append(const p:PChar;const 
> l:Int64);" marked as inline is not inlined
> end;

The compiler does not support inlining calls with parameters that cast a 
managed type to an unmanaged type at this time.

Regarding the reason why something cannot be inlined: sometimes you can 
get more information with -vd, but not always (and even then the reason 
may be vague).

I would personally be in favour of removing all of the inlining hints, 
because they are specific to a particular compiler version and mainly 
cause people to waste time on premature optimisation (or on what they 
think is an optimisation, but in many cases slows down things due to 
increased instruction cache pressure). Especially in this case: there is 
nothing potentially wrong with such a call, nor is the method in general 
not inlinable, so there is no way to get rid of the hint other than by 
removing the inline directive altogether (or by adding a version of that 
routine with a different name that is not declared as "inline"). This 
only promotes complicating code without any potential improvement of 
productivity or clarity of the code/programmer intent.


Jonas



More information about the fpc-pascal mailing list