Unit at a time C++ again

Jan Hubicka hubicka@ucw.cz
Thu Jun 19 16:06:00 GMT 2003


> > > The C++ standard says which classes/functions are instantiated based on
> > > a particular input program, and our template instantiation model
> > > dictates that you instantiate all of the needed ones in every
> > > translation unit that needs them.
> > 
> > Hmm, I don't follow.  If C++ standard dicates what classes/functions are
> > instantiated and we do exactly that, how exactly do you propose to
> > change the current code?
> 
> I don't.  But I want to make sure that all of this instantiation takes
> place before any heuristic decisions about inlining are made

This part is done by my patch - I do have complette callgraph of
reachable functions before I start any optimizations and no new
functions are inserted into it during the optimization.  On the other
hand, the functions can be removed.

> and before decisions variable emission is done.

This part is not, but I do have patch halfway that can delay emitting of
any variables.  It is stupid at the moment but interfaces are the
important thing right now I guess.

> 
> One reason for the latter is that sometimes, if you can do enough
> optimization, you no longer need to emit the variables.

We don't do any such optimization at the moment (it must be done at tree
level during the unit-at-a-time analysis so this part probably should
wait for tree-SSA), but I am trying to keep this in the mind.
To work well, it will need to created dependency graph that is mixed in
between variables and functions, so when variable requiring function
stops to needed we actually recognize it.  This is not done right now
but can be added with no further modifications to the frontends.

> 
> If we're going to unit-at-a-time, go all the way.  Wait until the entire
> file is processed, all the templates are instantiated, etc., before
> writing out *anything*.

OK, so you don't propose to completely rewrite the finish_file, template
instantiation and all the others?  That sounds promising :)

At the moment I am letting to go trought all static/global variables
output by frontend.  This is changed by patch I am working on, so only
thing that get trought are things assembled directly (not via
rest_of_decl_compilation or cgraph_finalize_function)
> 
> > I was reffering to the following code:
> > static void
> > output_vtable_inherit (tree vars)
> > {
> 
> I don't even know what that code does, I'm afraid. :-)

Hmm, me neither - this is my first journey to the C++ frontend after all :)
> 
> It's for some special stuff that tries to help the linker discard
> unneeded vtables, I think.  It should be postponed until the vtable
> actually gets emitted, via some kind of hook.

Yes, I was considering adding a hook that is called once given variable
is scheduled to be assembled, like I do already have hook for functions
scheduled to be optimized.

Honza
> 
> -- 
> Mark Mitchell
> CodeSourcery, LLC
> mark@codesourcery.com



More information about the Gcc mailing list