DIP56 - inlining

Mike via Digitalmars-d digitalmars-d at puremagic.com
Tue Feb 3 16:24:23 PST 2015


On Tuesday, 3 February 2015 at 22:30:22 UTC, Walter Bright wrote:
> http://wiki.dlang.org/DIP56
>
> There's been enough discussion, time to make a decision and 
> move on.
>
> I changed the description to:
>
> "If a pragma specifies always inline, and the compiler cannot 
> inline it, a warning will be generated. Implementations will 
> likely vary in their ability to inline."

I think this whole debate could have been avoided if the DIP was 
worded differently.

Instead of...

pragma(inline, true);  // always inline
pragma(inline, false); // never inline
pragma(inline);        // revert to default behavior

...it should read...

pragma(inline, true);  // enable -inline compiler flag
pragma(inline, false); // disable -inline compiler flag
pragma(inline);        // use whatever is passed in on the 
command line

...as that is really the intent of DIP56 as confirmed by Walter 
[1].

Now the problem with this is it is DMD specific, as the compiler 
flags vary greatly between compilers.  So instead it may be 
better to generalize it.

pragma(compile, inline, true)   // enable -inline compiler flag
pragma(compile, inline, false)  // disable -inline compiler flag
pragma(compile, inline)         // use whatever is passed in on 
the command line

Since GDC doesn't have an -inline flag, it may instead choose to 
use any or all of the following...
pragma(compile, finline-small-functions, true|false)
pragma(compile, fno-inline, true|false)
pragma(compile, finline-functions, true|false)

... or choose not to implement it a all since it already has 
`@attribute` mappings to GCC's `__attribute__` syntax [4].

Only the GDC developers can say whether this is feasible or not, 
but it matches much better to the intent of DIP56 [2].  Perhaps 
this is more along the lines of what DIP72 [3] is trying to 
achieve.

Mike

[1] - Walter confirming behavior of pragma(inline) - 
http://forum.dlang.org/post/maq4rp$2f9o$1@digitalmars.com
[2] - DIP56 - http://wiki.dlang.org/DIP56
[3] - DIP72 - http://wiki.dlang.org/DIP72
[4] - GCC's Attribute Syntax - 
https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html


More information about the Digitalmars-d mailing list