[Issue 15483] New: static if prevents inlining
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Dec 29 09:40:20 PST 2015
https://issues.dlang.org/show_bug.cgi?id=15483
Issue ID: 15483
Summary: static if prevents inlining
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: thomas.bockman at gmail.com
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...
--
More information about the Digitalmars-d-bugs
mailing list