There should be three modifiers for inlining to have fairly strong control over inlining:
- inline — basic one, compiler decides if inlining is possible and makes sense.
- forceinline — a given routine must be inlined and if not, compiler emits an error and abort compilation.
- noinline — a given routine must not be inlined, even if possible.
I would disagree.
inline means "inline this routine", not "if you could, I hereby permit you to inline this routine, but only if it is not too much trouble for you". inline = inline, that is all. No
forceinline is needed -
inline already says enough: this routine is to be inlined, end of story.
noinline - works.
Routines on branch
devel are auto-inlined fairly aggressively. You can see it by putting a breakpoint in a body: the debugger will not stop there even though the routine has no
inline on it - it was inlined.
These all work and turn it off:
{$optimization autoinline-}
{$inline-}
{$inline off}
Auto-inlining is active from
-O3 up and it is more aggressive than you would expect. Side effects are not fully known yet, I am still testing. The IDE builds and runs, and my fairly large projects build, run, are faster and stable, so it looks OK.
It shows up most on routines doing a lot of calls into small bodies where someone "forgot" to write
inline - hash functions, for instance. Or a wrapper whose body is a single call to another function: such a routine gets auto-inlined and the target is then called directly, instead of two calls.