On Thu, 6 Dec 2012, Jakub Jelinek wrote: > Hi! > > This patch fixes both a correctness problem (bootstrap failure in > libgfortran for a couple of targets) and debug info quality issue. > The correctness issue is about the fact that clearing DECL_INITIAL > (well, setting it to error_mark_node is the same) in varpool_remove_node > is changing the decl's bss_initializer_p (decl) status, thus can affect > section flags of it for DWARF2 if an unused decl has > e.g. make_decl_rtl_for_debug called from implicit pointer expansion > before varpool_remove_node and then e.g. during dwarf2out_finish after it. > This function intentionally doesn't remember the RTL, that could affect > code generation. > And for the debug info quality issue see the next patch that actually > improves use of DECL_INITIAL for debug info generation. > > Even if we add some param to limit the size of the initializers we want to > emit into debug info, still the varpool_remove_node clearing of the > initializer would need to be done (if we want to try hard to save compile > time memory) in a way to keep the bss_initializer_p the same as before, > so call it before clearing, if it was set, setting it to error_mark_node > is perhaps fine, if it was set, it needs to be set to some other magic > value and everything that uses DECL_INITIAL afterwards need to be taught > about that (including bss_initializer_p not to treat that other magic value > as bss initializer). > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2012-12-06 Jakub Jelinek <ja...@redhat.com> > > PR fortran/55395 > * varpool.c (varpool_remove_node): Don't drop DECL_INITIAL > if -g and emitting DWARF2+. > > --- gcc/varpool.c.jj 2012-11-19 14:41:27.000000000 +0100 > +++ gcc/varpool.c 2012-12-04 17:42:41.228752645 +0100 > @@ -65,7 +65,10 @@ varpool_remove_node (struct varpool_node > && !DECL_VIRTUAL_P (node->symbol.decl) > /* dbxout output constant initializers for readonly vars. */ > && (!host_integerp (DECL_INITIAL (node->symbol.decl), 0) > - || !TREE_READONLY (node->symbol.decl))) > + || !TREE_READONLY (node->symbol.decl)) > + /* dwarf2out can use most of the initializers. */ > + && write_symbols != DWARF2_DEBUG > + && write_symbols != VMS_AND_DWARF2_DEBUG)
Eh, shouldn't we "abstract" this properly? Like with a bool flag in debug_hooks? Or with a hook? I see now we special-case dbxout and dwarf2out ... (can all dwarf versions express the initializers?) Thanks, Richard.