https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127809

--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jeff Law <[email protected]>:

https://gcc.gnu.org/g:6db085c8b79ff6fc4265bf8e45605b7992eb85d8

commit r17-5115-g6db085c8b79ff6fc4265bf8e45605b7992eb85d8
Author: Yongqiang Tian <[email protected]>
Date:   Tue Oct 13 07:04:39 2026 -0600

    [PATCH 2/2] jump: Ignore debug insns before BARRIER [PR127809]

    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]>

Reply via email to