On Fri, 2009-08-28 at 06:58 -0700, Ian Lance Taylor wrote: > oliver.kell...@t-online.de (Oliver Kellogg) writes: > > > In multi source compile mode, I ggc_free() the data in dwarf2out.c after > > code generation for a file is done. (I found that I need this because > > otherwise the assembly code generated for file_2 to file_N of a compile > > job will carry leftovers from the code generated for file_1.) > > I believe that as long we have a garbage collector, ggc_free should be > used very very rarely, only when there is clear evidence that it reduces > memory usage. If you just want to stop referring to memory, you should > simply set the pointer to NULL. There is no point to having a garbage > collector if we don't take advantage of it. > > Ian
As mentioned, I'm still struggling with leftovers being carried over from compilation 1 to N-1 into compilation N of a compile job. gcc_free'ing things (in combination with "configure --enable-checking=gc,gcac") helps me track down objects that should have been reset. When the files of a compile job are disjoint (i.e. they do not share common declarations) then IMHO freeing really makes sense. Also I believe that this exercise will help me learn more about GCC internals. Once the multi source compilation is working in this mode, with complete reset of all backend artefacts before compiling a file of a compile job, then I might look at freeing things more intelligently, e.g. freeing only the artefacts that correspond to non-inlined functions and file-local declarations but leaving the trees for globally visible declarations intact for reuse by the compilation of further files of the compile job. A next step after that may be to look at Tom Tromey's incremental- compiler branch and see whether it is possible to integrate my changes there. I would be looking at running the incremental compiler in a serverless mode more similar to the way GCC works now, where trees are constructed and shared only within a single compile job (i.e. the backend is called only once but with many files as the argument list, and the trees are only reused throughout the compilations of these files but do not continue to exist beyond the backend invocation lifetime.) Oliver