https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121045
--- Comment #16 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <[email protected]>: https://gcc.gnu.org/g:e4f3fc66841af8206177d5dabb40caccfea3dc2f commit r16-6802-ge4f3fc66841af8206177d5dabb40caccfea3dc2f Author: Jakub Jelinek <[email protected]> Date: Thu Jan 15 12:03:34 2026 +0100 compare-debug: Don't print discriminators for -fdump-final-insns= [PR121045] Given the discussions in the PR, seems it is intentional that debug stmts are taken into account when assigning discriminators which is something that is actually never emitted into generated code, only into debug info, so for -g0 we might as well not try to compute them at all. But discriminators are printed in the dumps, including -fdump-final-insns= dump which affect -fcompare-debug. So, the following patch arranges not to print discriminators in that dump (i.e. when TDF_COMPARE_DEBUG is set in flags). I think we should also (but it can be handled incrementally) add some new TDF_* flag and -fdump-{tree,rtl,ipa}-<pass> modifier which will also disable printing discriminators (similar to nouid/TDF_NOUID) so that people can use it e.g. in -fcompare-debug -fdump-tree-all-nodiscrim and don't have to ignore discrim N changes in the dumps. This patch fixes -FAIL: c-c++-common/torture/pr116156-1.c -O1 (test for excess errors) -FAIL: c-c++-common/torture/pr116156-1.c -O2 (test for excess errors) -FAIL: c-c++-common/torture/pr116156-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) -FAIL: c-c++-common/torture/pr116156-1.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess errors) -FAIL: c-c++-common/torture/pr116156-1.c -O3 -g (test for excess errors) -FAIL: c-c++-common/torture/pr116156-1.c -Os (test for excess errors) -FAIL: g++.dg/torture/pr58552.C -O1 (test for excess errors) -FAIL: g++.dg/torture/pr58552.C -O2 (test for excess errors) -FAIL: g++.dg/torture/pr58552.C -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors) -FAIL: g++.dg/torture/pr58552.C -O3 -g (test for excess errors) -FAIL: g++.dg/torture/pr58552.C -Os (test for excess errors) so no testcase added for it. 2026-01-15 Jakub Jelinek <[email protected]> PR debug/121045 * tree-pretty-print.h (dump_location): Add new dump_flags_t argument defaulted to TDF_NONE. * tree-pretty-print.cc (dump_location): Add flags argument. Don't print discriminator if TDF_COMPARE_DEBUG bit is set in flags. (dump_block_node, dump_generic_node): Pass through flags to dump_location. * gimple-pretty-print.cc (dump_gimple_phi, pp_gimple_stmt_1, dump_implicit_edges): Likewise. (gimple_dump_bb_as_sarif_properties): Pass dump_flags to dump_location. * print-rtl.cc (rtx_writer::print_rtx_operand_code_L): If dump_flags has TDF_COMPARE_DEBUG bit set, don't print discriminators.
