On 10/11/26 4:56 PM, Yongqiang Tian wrote:
When delete_related_insns deletes a CODE_LABEL, it walks backward over
deleted instructions and notes to find a preceding BARRIER.  A
DEBUG_INSN stops the walk, so unreachable code can be retained with -g
but deleted with -g0.

Skip debug insns in the walk.  Add a SPARC regression test.  GCC's
existing gcc.dg/builtin-unreachable-1.c is also a natural trigger on
mips-elf at -Os with -g -fno-var-tracking -fcompare-debug.

This was found during the PR127808 investigation prompted by Jeff's
PR127795 review.  The patch is independently applicable, but is ordered
after patch 1 because delete_related_insns relies on a BARRIER correctly
proving that no path falls through.

Tested at GCC revision a02e2004cb707155d5b9b0a82dd428ded0ee2f6f:

* With patch 1 applied but without this patch, the new SPARC test fails;
   with both patches it passes.
* The existing gcc.dg/builtin-unreachable-1.c fails on baseline mips-elf
   at -Os with -g -fno-var-tracking -fcompare-debug and passes with this
   fix.
* A complete sparc-elf `make -k -j8 check-gcc` comparison has no
   regressions.
* Native x86_64-pc-linux-gnu bootstrap and complete `make -k -j24 check`
   have the same normalized outcomes with and without the two-patch
   series, as reported in patch 1.
* `contrib/check_GNU_style.sh` and `git diff --check` pass.

Assisted-by: OpenAI Codex 5.6 Sol, co-reviewed by Claude and Yongqiang Tian.

        PR rtl-optimization/127809

gcc/ChangeLog:

        * jump.cc (delete_related_insns): Ignore debug insns when looking for
        a BARRIER before a deleted label.

gcc/testsuite/ChangeLog:

        * gcc.target/sparc/delete-related-insns-debug.c: New test.

Signed-off-by: Yongqiang Tian <[email protected]>
THanks.  I've pushed this to the trunk.
Jeff

Reply via email to