Thread overview
Separate meaning for "inline" and "force inline"
November 20

Currently if I understand correctly there are two meanings for pragma(inline).

  1. This means "the body of f is public, it is replicated in .di headers":

    pragma(inline, true)
    void f()
    {
    // something
    }

  2. This means "the function will be inlined":

    void f()
    {
    pragma(inline, true);
    // something
    }

Is there any reason why we have those 2 differing semantics using the same syntax? This is similar to C++ inline (which is about visibility) and __force_inline, and in the end it doesn't seem like publishing the bodies has anything to do with te decision to inline.

Currently, LTO can be used to inline things anyway, even things that weren't "external pragma(inline)", just like in C++.

November 21
The pragma itself does not have any additional behavior on it depending upon where it was located.

https://github.com/dlang/dmd/blob/3fa3ac85e2feae47703964d6586231d02974c222/compiler/src/dmd/pragmasem.d#L485

Where it is called:

https://github.com/dlang/dmd/blob/3fa3ac85e2feae47703964d6586231d02974c222/compiler/src/dmd/pragmasem.d#L427

From a quick look it does look like the .di generator does turn on the body dump if its inlined. Where the pragma was placed is unrelated.

https://github.com/dlang/dmd/blob/3fa3ac85e2feae47703964d6586231d02974c222/compiler/src/dmd/hdrgen.d#L1126

Which makes sense, you can't inline a function if you don't have the body.
November 20
On Wednesday, 20 November 2024 at 17:35:48 UTC, Richard (Rikki) Andrew Cattermole wrote:
> https://github.com/dlang/dmd/blob/3fa3ac85e2feae47703964d6586231d02974c222/compiler/src/dmd/hdrgen.d#L1126
>
> Which makes sense, you can't inline a function if you don't have the body.

Perhaps, still you might want to have to have the body in the .di AND let the compiler decide if it's inlined or not, I'm not sure that's possible right now?
November 21
On 21/11/2024 7:21 AM, Guillaume Piolat wrote:
> On Wednesday, 20 November 2024 at 17:35:48 UTC, Richard (Rikki) Andrew Cattermole wrote:
>> https://github.com/dlang/dmd/ blob/3fa3ac85e2feae47703964d6586231d02974c222/compiler/src/dmd/ hdrgen.d#L1126
>>
>> Which makes sense, you can't inline a function if you don't have the body.
> 
> Perhaps, still you might want to have to have the body in the .di AND let the compiler decide if it's inlined or not, I'm not sure that's possible right now?

So an attribute to force output of a body, that the .di generator sees?

Okay sure, that would be a good addition.

November 21
On Wednesday, 20 November 2024 at 18:55:21 UTC, Richard (Rikki) Andrew Cattermole wrote:
>
> So an attribute to force output of a body, that the .di generator sees?
>

Yes.
redub and reggae demand this body output for building things in parallel, but forcing the inlining too in most cases will ensure lower performance by second-guessing the compiler.