https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93385
--- Comment #29 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to rguent...@suse.de from comment #28) > On Fri, 17 Apr 2020, jakub at gcc dot gnu.org wrote: > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93385 > > > > --- Comment #26 from Jakub Jelinek <jakub at gcc dot gnu.org> --- > > For debug stmts, it would be best if we could use those > > DEBUG D#Y s=> parm > > DEBUG var => D#Y > > added in if (param_body_adjs && MAY_HAVE_DEBUG_BIND_STMTS). > > Though, if we remove already during the copy_bb by not actually creating the > > stmt, I'm afraid that will mean the debug info is lost (debug stmts will be > > reset), unless we for the lhs of to be dced stmts manually create debug > > temporaries and debug stmts when we remap_gimple_stmt those stmts (for > > SSA_NAMEs that are directly (or indirectly!) used in debug stmts). > > If we do what Martin was proposing instead, i.e. copy the stmts and then DCE > > them afterwards, it might work properly (perhaps only if we DCE them in the > > right order). > > It's true that copying everything and then DCEing is easier for debug > stmt generation. I didn't consider this. That also argues for not > remapping anything to error_mark_node. Of course this leaves us with > no automagic verification if we really DCEd everything required > (esp. his handling of call arguments looks expensive and odd to me). We could remap those to error_mark_node for -g0 and for -g to the DEBUG_EXPR_DECLs we'd create and then just during verification make sure we diagnose DEBUG_EXPR_DECLs in non-debug stmts (and error_mark_node). Though, I think even right now the debug side of things even without the DCE is not perfect, we do create a bind to cover the optimized out parameters at the start of the function, but don't do this remapping of the SSA_NAME to that DEBUG_EXPR_DECL, which means that e.g. debug stmts that used to use that SSA_NAME in some expressions are reset. So, I think if Martin comes up with something that just doesn't handle the debug stmts for GCC10, I can try to improve the debug side later.