Thread overview
[Issue 16360] DMD fails to inline functions that contain a type
Aug 13, 2016
b2.temp@gmx.com
Aug 14, 2016
ag0aep6g@gmail.com
Jun 27, 2018
Manu
Jun 27, 2018
Basile B.
Nov 08, 2018
Basile B.
Jan 25, 2019
Basile-z
August 13, 2016
https://issues.dlang.org/show_bug.cgi?id=16360

b2.temp@gmx.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code

--- Comment #1 from b2.temp@gmx.com ---
LDC succeeds, so DMD inliner only.

--
August 14, 2016
https://issues.dlang.org/show_bug.cgi?id=16360

ag0aep6g@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|wrong-code                  |
                 CC|                            |ag0aep6g@gmail.com
           Severity|normal                      |enhancement

--- Comment #2 from ag0aep6g@gmail.com ---
I'm removing the "wrong-code" keyword, and downgrading this to an enhancement request.

A wrong-code bug is when incorrect machine code is generated. The test case must compile and link for that, but dmd rejects the test case.

It's only an enhancement request, because the spec explicitly allows the compiler to error out when it can't inline a function that has pragma(inline, true).

--
June 27, 2018
https://issues.dlang.org/show_bug.cgi?id=16360

Manu <turkeyman@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |turkeyman@gmail.com
           Assignee|nobody@puremagic.com        |turkeyman@gmail.com

--- Comment #3 from Manu <turkeyman@gmail.com> ---
This code should obviously inline.

I think rejecting inline should be because there's a reason it can't inline. There's no such reason here, failure to inline is an implementation detail (ie, a bug).

--
June 27, 2018
https://issues.dlang.org/show_bug.cgi?id=16360

--- Comment #4 from Basile B. <b2.temp@gmx.com> ---
(In reply to Basile B. from comment #0)
> When a simple type is nested in the function, e.g as an helper DMD fails to inline:
> 
> °°°°°°°°°°°°°°°°°°°°°°°°°°°°
> #!runnable-flags: -O -inline
> module runnable;
> 
> import std.stdio;
> 
> pragma(inline, true)
> auto foo(int t)
> {
>     struct Bar{}
>     return t;
> }
> 
> void main()
> {
>     auto v = foo(1);
> }
> °°°°°°°°°°°°°°°°°°°°°°°°°°°°
> 
> outputs:
> > /tmp/temp_7FD0A006D9F0.d(7,6): Error: function runnable.foo cannot inline function

Note :

1. this also fails if Bar is a nested static struct, which is more surprising. 2. this case is suspected to be part of the perf problem DMD has with ranges and pipelines (Voldemort types are often nested...)

--
November 08, 2018
https://issues.dlang.org/show_bug.cgi?id=16360

Basile B. <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=19375

--
January 25, 2019
https://issues.dlang.org/show_bug.cgi?id=16360

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
           Hardware|x86_64                      |All
           Assignee|turkeyman@gmail.com         |b2.temp@gmx.com
                 OS|Linux                       |All

--- Comment #5 from Basile-z <b2.temp@gmx.com> ---
pull https://github.com/dlang/dmd/pull/9294

--
January 28, 2019
https://issues.dlang.org/show_bug.cgi?id=16360

--- Comment #6 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/5f9f52d63819e96e5b89365d6d03d18cc3b2b948 fix issue 16360 - DMD fails to inline functions that contain a type

https://github.com/dlang/dmd/commit/f38300766514ecc906904a209a5c2414cee8894f Merge pull request #9294 from Basile-z/static-nested-aggr-inline

fix issue 16360 - DMD fails to inline functions that contain a type merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>

--
January 28, 2019
https://issues.dlang.org/show_bug.cgi?id=16360

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--