Is there a way to get a list of functions that get inlined by dmd?

Scorn scorn at trash-mail.com
Tue Feb 9 08:05:11 PST 2010


Trass3r schrieb:
> Am 08.02.2010, 16:33 Uhr, schrieb Scorn <scorn at trash-mail.com>:
> 
>> Trass3r schrieb:
>>> Would be interesting.
>>
>>
>> Yes, this would be very interesting indeed. A list of the rules which
>> dmd uses internally for inlining functions and methods would be really
>> nice.
>>
> 
> Well if I read the code correctly the following is not supported:
> - nested inline?
> - variadic functions (T t, ...)
> - synchronized
> - imported functions
> - functions with closure vars
> - virtual functions that aren't final
> - functions with out, ref or static array parameters
> - functions with more than 250 elementary expressions
> 
> 
> Created my own little inline dumping patch:
> 
> 
> Index: inline.c
> ===================================================================
> --- inline.c    (revision 363)
> +++ inline.c    (working copy)
> @@ -1126,6 +1126,7 @@
>      if (fd && fd != iss->fd && fd->canInline(0))
>      {
>          e = fd->doInline(iss, NULL, arguments);
> +        printf("Inlined function %s.\n", fd->toPrettyChars());
>      }
>      }
>      else if (e1->op == TOKdotvar)
> @@ -1145,7 +1146,10 @@
>          ;
>          }
>          else
> -        e = fd->doInline(iss, dve->e1, arguments);
> +        {
> +            e = fd->doInline(iss, dve->e1, arguments);
> +            printf("Inlined method %s.\n", fd->toPrettyChars());
> +        }
>      }
>      }
> 

Thanks for your work. This is very interesting. It would be good to have
this on a separate page regarding optimizations in D.

But a big problem is that inlining seems to be done only inside one
module and not across modules which makes modules with something like
small helper or math functions which are used across different modules
senseless.


More information about the Digitalmars-d-learn mailing list