]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix miscompilation of function containing __builtin_unreachable
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 29 Oct 2024 20:40:34 +0000 (21:40 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Tue, 29 Oct 2024 20:51:07 +0000 (21:51 +0100)
commit0ea3dca7946a1bce072ae5f732a873ce6f207bee
tree14e0f9d7b40018e7de1e38847d8913d1563ae656
parentab74b2d86471cdb5b8a327e734630f1288125d9e
Fix miscompilation of function containing __builtin_unreachable

This is a wrong-code generation on the SPARC for a function containing
a call to __builtin_unreachable caused by the delay slot scheduling pass,
and more specifically the find_end_label function which has these lines:

  /* Otherwise, see if there is a label at the end of the function. If there
     is, it must be that RETURN insns aren't needed, so that is our return
     label and we don't have to do anything else.  */

The comment was correct 20 years ago but no longer is nowadays in the
presence of RTL epilogues and calls to __builtin_unreachable, so the
patch just removes the associated two lines of code:

  else if (LABEL_P (insn))
    *plabel = as_a <rtx_code_label *> (insn);

and otherwise contains just adjustments to the commentary.

gcc/
PR rtl-optimization/117327
* reorg.cc (find_end_label): Do not return a dangling label at the
end of the function and adjust commentary.

gcc/testsuite/
* gcc.c-torture/execute/20241029-1.c: New test.
gcc/reorg.cc
gcc/testsuite/gcc.c-torture/execute/20241029-1.c [new file with mode: 0644]