[dmd-internals] Is there a reason that inlining happens so early?

Jonathan M Davis jmdavisProg at gmx.com
Tue Nov 27 01:59:12 PST 2012


On Tuesday, November 27, 2012 01:44:13 Brad Roberts wrote:
> On 11/27/2012 1:00 AM, Don Clugston wrote:
> > One of the main reasons that implementing CTFE is difficult, is that
> > inlining happens so early.
> > It sometimes happens that CTFE gets run on a function BEFORE it is
> > inlined, and then the same function gets run again AFTER inlining.
> > Then the same function has a different number of variables, and all
> > kinds of evil transformations. This makes it very difficult to
> > pre-anaylze CTFE functions, before running them. (I've done
> > experiments which show that a minimal "compile" which merely allocates
> > variable numbers, can significantly increase CTFE speed).
> > 
> > Is there any reason why all the inlining couldn't be done after the
> > semantic3 pass has completed, instead of happening within it?
> 
> I've heard Walter say that inlining is done in the front end so that other
> users of the backend can benefit from it. Ironically, I don't believe that
> any of the users (other than dmd) of the frontend use the inliner that's in
> the frontend, unless something's changed.

And most people claim that dmd's inliner is quite poor (though I've never 
examined its results in detail, so I don't know how true that is).

- Jonathan M Davis


More information about the dmd-internals mailing list