Unit at a time C++ again

Jan Hubicka hubicka@ucw.cz
Thu Jun 19 11:48:00 GMT 2003


Hi,
> > OK, dealing with template instantiation should not be too dificult (I
> > think I can simply instantiate all templates with the code I am having
> > right now).  Dealing with at least needed portion of the datastructures
> > should not be impossible, but I would like first to understand what
> > exactly it does buy to us...
> 
> The template instantiation part of the issue is pretty clear: in big C++
> programs many (if not most) of the functions are template
> instantiations.  Trying to make decisions before template instantiation
> is not worth it.

This is what I am partly affraid of - forcing all instantiations to
actually happen (and not only doing the reachable ones) seems to be
problem as we produce a lot of unneeded trees.
Perhaps I can somehow just instantiate the template datastructures and
not produce the actual methods and produce the methods during the
function lowering process (that happens only for reachable functions),
but I am not sure what kind of complications I can hit with this.

Also note that I am not doing any decisions before template
instantiation is done - I am just walking the call dependency graph
expanding any reachable node I visit getting templates instantiated as
needed.
> 
> Data structures are also important because they can trigger template
> instantiations.  A simple example is:
> 
>   template <typename T> void f(T) {}
>   
>   void (*fp)(int) = &f<int>;
> 
> Often, that kind of thing results in the instantiations of lots of
> additional functions, as one function calls another and so forth.

Yes, this is clear to me, however what I don't understand why you
consider the split scheme where reachable datastructures are produced by
frontend and reachable functions maintained by backend major problem.

I am now working on adding variable graph companion to my callgraph code
(for C/objC this seems to be pretty easy).  This will hopefully get the
code closer to what we are shooting for.  For C++ there seems to be
problem with virtual tables as these are not output only via
assemble_variable and do have dependencies in between middle end does
not see.

When I don't want to give up idea of doing the transition in multiple
steps instead of one big that will likely cause inexpected surprises,
perhaps we can attack the C++ problem from the other way around -
finalize all build datastructures, keep middle end on the busyness of
doing reachability analysis... 
I will at least try to do this step in my local tree before trying to
put it all together and lets see how far can I get...

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



More information about the Gcc mailing list