https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58315
--- Comment #27 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Alexandre Oliva from comment #26) > I had failed to measure peak memory use. It went down from more than 4.8G > to less than 460M (vs 380MB without debug info). Wheee! Wheee! Note that this is exactly what I had in mind (kind of) - we should "DCE" debug stmts when at the given text address the debugger cannot refer to the entity the debug stmt is for - for example if the current scope is simply not nested inside of the scope the debug entity is for. In theory remove_unused_locals could do that - in the walk over have_local_clobbers remove all GIMPLE debug stmts that have an unused BLOCK associated. Note that we still won't remove the actual BLOCKs as we keep BLOCKs live with associated user-vars (but no associated statements), see remove_unused_scope_block_p. Still removing debug statements associated with such block (well, rather debug stmts with a LHS which is associated with an unused BLOCK... - which is not exactly the same) should be possible. Of course this should be done on the RTL level close to var-tracking but it might be what your patch ends up effectively doing as well.