What does 'inline' mean?

kinke kinke at gmx.net
Mon Jun 8 10:27:54 UTC 2020


On Monday, 8 June 2020 at 06:14:44 UTC, Manu wrote:
> D's inline today doesn't do any of those things. It doesn't 
> implement a mechanic that I have ever wanted or known a use for.

We've had this discussion a while back. As of the latest LDC 
beta, `pragma(inline, true)` functions are now properly emitted 
into each referencing CU, and will be inlined in most cases 
(`alwaysinline` LLVM function attribute), even at -O0.

In modules other than the owning one, the function 'copy' is 
emitted as `available_externally`, meaning that it's *only* 
available for inlining at the IR level, it will never make it to 
the assembler and object file.

In its owning module, the function is emitted as a regular 
function, as a fallback for non-inlined cases (and for when 
people take its address etc.). Our opinions diverge wrt. whether 
that's a problem - to me it's clearly no big deal, as the 
function is a) most likely small, and b) subject to linker 
stripping if unreferenced.

Wrt. control of which CUs contain which functions, that's totally 
out of hand anyway due to the way templates are emitted.


More information about the Digitalmars-d mailing list