https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93786
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Richard Biener from comment #2) > Hmm, but this destructive modification of something we don't unshare doesn't > work. Either we have to always wrap statement lists but then we're back to > the compare-debug issue or we somehow fix the destructiveness on the > stmt list node itself - like not setting it's type to void or marking it > as having side-effects (why do we do this anyways, in voidify_wrapper_expr? > is that for debugging?), we'd also need to leave the final value in the > stmt list for a possible second gimplification round... > > Maybe the best thing is to kill off the debug stmts when they would cause > a stmt list to appear and revert the previous fix. We might kill them only in one of the two places (say keep in the argument and remove from the OBJ_TYPE_REF operand or vice versa), but we'd need some function that walks the non-TREE_SIDE_EFFECTS tree and looks for such STATEMENT_LISTs, as they might be wrapped in casts/whatever else that doesn't have side-effects. Another possibility would be do that in copy_if_shared_r or so (only handle the !TREE_SIDE_EFFECTS STATEMENT_EXPR that contain only DEBUG_STMTs + one non-debug one), but we wouldn't have control over which of the two or more copies gets to keep the STATEMENT_LIST and which don't (well, it would be whatever we walk_tree first).