DIP56[1] proposes to use pragmas to control inlining.
However, AFAIU, you can't override them on the caller-side and it
does not specify how it interacts with header (.di) files and
shared libraries (I guess like C/C++).
The proposal also mentions that these pragmas are not function
attributes because they should not affect the semantics of the
function. However I am not entirely sure that this is correct
because if use alloca, depending on if you inline or not, you can
get a stack overflow. There were two[2, 3] bug fixes in dmd
related to that.
[1]: http://wiki.dlang.org/DIP56
[2]: https://github.com/D-Programming-Language/dmd/pull/3811
[3]: https://github.com/D-Programming-Language/dmd/pull/3961 (fix
of the previous PR)
On Friday, 2 January 2015 at 14:34:39 UTC, Martin Nowak wrote:
I'm currently working on optimizing the GC marking code and I'm
having quite some problems with the inline decisions of the
compiler.
The compiler can't make good decisions here, because it lacks
information about which branches are executed rarely.
Would be nice to have @noinline, @forceinline and
__builtin_expect.