[Issue 15671] The compiler should take into account inline pragmas when inlining
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 9 12:44:05 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=15671
Stanislav Blinov <stanislav.blinov at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |stanislav.blinov at gmail.com
--- Comment #5 from Stanislav Blinov <stanislav.blinov at gmail.com> ---
(In reply to Walter Bright from comment #1)
> The compiler is using a heuristic of "if the amount of code in a function is
> above a certain threshold, then it is not inlined." The idea is that the
> overhead of a function call becomes small when the size of the function is
> large. Where the code came from is irrelevant.
void foo(alias func)()
{
pragma(inline, true);
func();
x = uniform!int();
}
The "amount of code" in `foo` (which is explicitly marked by a pragma) is two
function calls and a store. After inlining, the
void main()
{
foo!longFunc();
}
should become, at the very least
void main()
{
longFunc();
x = uniform!int();
}
Yet it fails, presumably because the compiler also attempts to inline
`longFunc` and/or `uniform` in `foo` before inlining `foo` itself.
--
More information about the Digitalmars-d-bugs
mailing list