Forum > FPC development

How optimized is the FPC compiler

<< < (28/29) > >>

440bx:

--- Quote from: Akira1364 on January 02, 2022, 07:15:19 am ---<snip> no function without the `inline` modifer will ever be inlined, no matter what).

--- End quote ---
I just wanted to say that is a good thing. It makes the resulting code completely predictable which is often useful when debugging.

IOW, a function should never be inlined unless the "inline" modifier is present (and, if present, the compiler has to find it "acceptable")

Akira1364:

--- Quote from: 440bx on January 02, 2022, 08:16:28 am ---
--- Quote from: Akira1364 on January 02, 2022, 07:15:19 am ---<snip> no function without the `inline` modifer will ever be inlined, no matter what).

--- End quote ---
I just wanted to say that is a good thing. It makes the resulting code completely predictable which is often useful when debugging.

IOW, a function should never be inlined unless the "inline" modifier is present (and, if present, the compiler has to find it "acceptable")


--- End quote ---

The current situation has far more downsides than upsides. A proper automatic implementation as is found in compilers for nearly every language I can think of (that could still be turned off per-function if necessary with stuff like the fairly new `noinline` modifier that does the opposite of `inline`, and also would probably just vary in aggressiveness to start with between -O1, -O2, -O3 etc) would be vastly better as the endgame solution overall, as then you wouldn't have to rely on various people who may or may not understand why it's actually important to appropriately set the 'inline' flags themselves in code you don't necessarily have direct control over.

Martin_fr:

--- Quote from: Akira1364 on January 02, 2022, 07:15:19 am ---Obviously it'd be nice if FPC had a more advanced form of the "AutoInline" switch turned on at all times so that you could just rely on it to do the right thing, but as it stands in reality it does the opposite (which is to say, no function without the `inline` modifer will ever be inlined, no matter what).

--- End quote ---

Have you tried?
--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ----OoAUTOINLINE or
--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$OPTIMIZATION AUTOINLINE}https://www.freepascal.org/docs-html/prog/progsu58.html

It's not on by default, but you can add it to your fpc.cfg.

Akira1364:
Yeah, that's what I was referring to in my comment. It works ok-ish as-is, but does not have any impact on pre-compiled units of course.

Martin_fr:

--- Quote from: Akira1364 on January 02, 2022, 11:51:54 am ---Yeah, that's what I was referring to in my comment. It works ok-ish as-is, but does not have any impact on pre-compiled units of course.

--- End quote ---
Well yes.

(Afaik) Inlining, does not just copy the already generated assemble code into the new location (replacing the call).

Inlining, (re-)compiles (partly) the code (from the called proc) in the new location. (Afaik it copies the "nodes" (representing the parsed, and maybe partly processed/compiled code) into the new place. From that the final assembler is generated).

But that is only possible, if those nodes exist. And they only do, if a proc was compiled with the indent to be inlined.


If for example some commercially sold code is released as ppu/o only, then they may not want to distribute such extra info (which could be used to gain insight into their unpublished code).

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version