Inlining Ref Functions

Daniel Keep daniel.keep.lists at gmail.com
Sat May 16 19:07:07 PDT 2009


dsimcha wrote:
> == Quote from grauzone (none at example.net)'s article
>> Of course, this doesn't have to do with DMD's optimizer. That said, if
>> you want heavy optimization, you rather should look at LDC or GDC.
> 
> In general I agree.  There are higher priorities than improving DMD's optimization
> back end.  This is a special case, though, because:
> 
> 1.  Innocent looking code can turn into a significant performance bottleneck.
> 2.  I would guess it's a very low hanging piece of fruit, since ref is just
> syntactic sugar for a pointer and DMD already can inline functions with pointer
> parameters.

Looking at the DMD 2.029 source code, in inline.c around line 1307
(slightly reformatted)...

>    /* If any parameters are Tsarray's (which are passed by reference)
>     * or out parameters (also passed by reference), don't do inlining.
>     */
>    if (parameters)
>    {
>	for (int i = 0; i < parameters->dim; i++)
>	{
>	    VarDeclaration *v = (VarDeclaration *)parameters->data[i];
>	    if (v->isOut() || v->isRef()
>                          || v->type->toBasetype()->ty == Tsarray)
>		goto Lno;
>	}
>    }

  -- Daniel



More information about the Digitalmars-d mailing list