https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87988
--- Comment #10 from rguenther at suse dot de <rguenther at suse dot de> --- On Wed, 28 Nov 2018, hubicka at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87988 > > --- Comment #9 from Jan Hubicka <hubicka at gcc dot gnu.org> --- > We still have: > /* When not generating debug info we can eliminate info on unused > > variables. */ > > else if (!flag_auto_profile && debug_info_level == DINFO_LEVEL_NONE > > && !optinfo_wants_inlining_info_p ()) > > > can we do better here? I think we can do better in the earlier loop over BLOCK_VARS if we make sure to not call remove_unused_scope_block_p before early debug generation. For example we should be able to elide else if (TREE_CODE (*t) == TYPE_DECL || debug_info_level == DINFO_LEVEL_NORMAL || debug_info_level == DINFO_LEVEL_VERBOSE) ; completely. Likewise /* Debug info of nested function refers to the block of the function. We might stil call it even if all statements of function it was nested into was elliminated. TODO: We can actually look into cgraph to see if function will be output to file. */ if (TREE_CODE (*t) == FUNCTION_DECL) unused = false; should not be necessary - that is, after early debug BLOCK_VARS only needs to retain used decls (decls we want to annotate with locations later). The code you quote above is a bit weird indeed.