Reason for not inlining
Original Reporter info from Mantis: okobapatino @OkobaPatino
-
Reporter name: OkobaPatino
Original Reporter info from Mantis: okobapatino @OkobaPatino
- Reporter name: OkobaPatino
Description:
Can FPC report why this code is not inlined?
I May think it is because the implementation of Test1 came after Test2, and I guess somewhere in the compiler, it knows this, so why not report it back? I only think this as I read it somewhere, and no documentation I can link to, so a reason for not inlining a function can be useful. Is it feasible?
unit Unit1;
{$mode objfpc}{$H+}
interface
function Test2(const A: PChar): PChar; inline;
function Test1(const A: PChar): PChar; inline;
implementation
function Test2(const A: PChar): PChar;
begin
Result := Test1(A);
end;
function Test1(const A: PChar): PChar;
begin
Result := A + 1;
end;
end.
Another case is this:
program Project1;
function Test1(A: PChar): PChar; inline;
begin
Result := A + 1;
end;
var
S: String;
P: PChar;
begin
S := 'Test';
P := Pointer(S); //Inlined
P := Test1(P);
P := Test1(Pointer(S)); //Not inlined
end.
I think it is not inlined because I am passing unmanaged type of a managed type, and again I only think this because I read this here:
http://free-pascal-general.1045716.n5.nabble.com/inlining-functions-depending-on-implementation-only-functions-td5732866.html#a5732888
So again, a reason along the hint can be helpful.
Mantis conversion info:
- Mantis ID: 38113
- Monitored by: » @benibela (Benito van der Zander), » @OkobaPatino (OkobaPatino)