Comment #0 by thomas.bockman — 2015-12-29T17:40:20Z
module app;
void main() {
import std.stdio;
inlineme1(true);
inlineme2(true); // Error: function app.inlineme2 cannot inline function
}
@safe pragma(inline, true) {
bool inlineme1(bool left)
{
if(left)
return true;
return false;
}
bool inlineme2(bool left)
{
if(left)
return true;
static if(false)
{
/*
Even though it does absolutely nothing,
the mere presence of this block prevents inlining
of this function.
*/
}
return false;
}
}
This issue has been giving me a lot of trouble while working on checkedint, for which inlining is critical to getting good performance.
I keep writing template functions which, if I instantiate the template by hand, will inline fine, but refuse to do so if I let the compiler instantiate it for me. I really don't want to be stuck using string mixins everywhere...
Comment #1 by thomas.bockman — 2015-12-29T17:41:32Z
Comment #2 by thomas.bockman — 2015-12-31T15:35:53Z
It seems to be related to the presence of multiple return statements.
Comment #3 by k.hara.pg — 2016-04-05T13:07:21Z
The root issue is a dup of issue 7625, and it will be fixed by the PR:
https://github.com/D-Programming-Language/dmd/pull/5626
But, original test case would not be compiled yet after the 7625 fix, because there's another inlining restriction. For that I opened a new issue 15878.
*** This issue has been marked as a duplicate of issue 7625 ***