Consider the following code:
class A
{
final double caller(double d)
{
return callee(d);
}
double callee(double d)
{
return 0;
}
}
class B : A
{
final double callee(double d)
{
// do some random math
return (d*d - d/7.5)/d;
}
}
void main()
{
B b = new B;
for(ulong l; l<50000000uL; l++)
b.caller(l);
}
Compile with -O -inline, and the function call to callee() is not inlined. This is because caller() is compiled in the context of class A, where callee() is a virtual function. I suggest that the optimizer should "recompile" caller() in the context of class B, so that B.caller() uses a inlined version while A.caller() does not.
This is useful in eg. a linear algebra system, where a matrix base class has an abstract element() method for accessing elements, and several (final) standard operations that use element().
Comment #1 by dmitry.olsh — 2018-05-15T13:11:00Z
Still not inlined, after 10 years. But then there is LDC/GDC if one wants optimization.
Comment #2 by robert.schadek — 2024-12-13T17:47:49Z