Der schöne Günther 316 Posted January 25, 2023 Under Project > Options > Building > Delphi Compiler > Compiling we have the project-widde option Code inlining control. It can also be set in code with something like {$INLINE ON|OFF|AUTO}. How inlining works and when the compiler cannot inline methods is explained in Delphi's Docwiki under Calling Procedures and Functions. It states that the default project setting is that inlining is set to ON which I found to be correct. However, the Help page Compiling states that OFF is the default setting. I am not sure what is the right choice for debug and for release builds. Wouldn't it be Set Inlining to OFF for all debug builds Set Inlining to AUTO for all release builds Or is there no universal recommendation and it depends on the project and its requirements? Many thanks in advance. Share this post Link to post
dummzeuch 1505 Posted January 25, 2023 You might want to turn inlining on for debug builds if what you are trying to debug might be releated to inlining. But in most cases I would also turn it off because it is really annoying if you can't step into a function because it was inlined. 1 Share this post Link to post
Stefan Glienke 2002 Posted January 25, 2023 I would never ever turn it to AUTO because that causes the compiler to inline every function that has a size of 32 bytes or less. The inliner of the Delphi compiler is really bad and while one might think that inlining code usually makes stuff better/faster that is not the case and usually (decent) library developers know where to put inline and where not to put inline. 3 Share this post Link to post
Brandon Staggs 278 Posted January 25, 2023 4 hours ago, Stefan Glienke said: I would never ever turn it to AUTO because that causes the compiler to inline every function that has a size of 32 bytes or less. The inliner of the Delphi compiler is really bad and while one might think that inlining code usually makes stuff better/faster that is not the case and usually (decent) library developers know where to put inline and where not to put inline. Interesting. I certainly would have expected that the (minor) overhead of a function call would cost more than just putting it inline and if the inline code is the same size or smaller, it would make sense to do it that way as a default. Can you point me to a resource that investigates this issue and shows why this is wrong thinking? I'm not saying you are wrong, I just want to learn more. Share this post Link to post
Stefan Glienke 2002 Posted January 25, 2023 (edited) It is from my own experience and analyzing generated code in several different scenarios. I have seen the inliner generating like x times more instructions including ridiculous amounts of mov instructions to and from the stack just to inline a harmless little function which it could way better if the inliner and the register allocator would not have been absolute trash. Plus there are "funny" little issues like this: https://quality.embarcadero.com/browse/RSP-30930 Here is an example where inlining creates some ridiculous amount of instructions: https://quality.embarcadero.com/browse/RSP-31720 (which is not caused by auto but the fact that the getter is being marked as inline) Edited January 25, 2023 by Stefan Glienke 2 Share this post Link to post