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

            Bug ID: 121567
           Summary: SH4 error: unable to find a register to spill in class
                    ‘R0_REGS’ issue when building Python at O2/O3
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thomas.petazz...@free-electrons.com
  Target Milestone: ---

Created attachment 62126
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62126&action=edit
Pre-processed source file

The Objects/obmalloc.c source file of Python 3.13.5 cannot be compiled for SH4
with GCC 15.2.0 (and older versions as well, but not tested since when the
issue exists) when -O2 or -O3 is used.

The attached pre-processed file allows to reproduce the issue:

$ sh4-buildroot-linux-gnu-gcc -O1 -c Objects/obmalloc.i -o blabla.o
$

Builds fine.

But:

$ sh4-buildroot-linux-gnu-gcc -O2 -c Objects/obmalloc.i -o prout.o
Objects/obmalloc.c: In function ‘_PyMem_SetDefaultAllocator’:
Objects/obmalloc.c:503:1: error: unable to find a register to spill in class
‘R0_REGS’
  503 | }
      | ^
Objects/obmalloc.c:503:1: error: this is the insn:
(insn 18 243 23 2 (parallel [
            (set (subreg:SI (reg:QI 176) 0)
                (unspec_volatile:SI [
                        (mem/v:QI (reg:SI 4 r4 [175]) [-1  S1 A32])
                        (reg:QI 7 r7 [178])
                        (reg:QI 6 r6 [180])
                    ] UNSPECV_CMPXCHG_1))
            (set (mem/v:QI (reg:SI 4 r4 [175]) [-1  S1 A32])
                (unspec_volatile:QI [
                        (const_int 0 [0])
                    ] UNSPECV_CMPXCHG_2))
            (set (reg:SI 147 t)
                (unspec_volatile:SI [
                        (const_int 0 [0])
                    ] UNSPECV_CMPXCHG_3))
            (clobber (scratch:SI))
            (clobber (reg:SI 0 r0))
            (clobber (reg:SI 1 r1))
        ]) "./Include/cpython/pyatomic_gcc.h":105:10 407
{atomic_compare_and_swapqi_soft_gusa}
     (expr_list:REG_DEAD (reg:QI 6 r6 [180])
        (expr_list:REG_DEAD (reg:QI 7 r7 [178])
            (expr_list:REG_UNUSED (reg:QI 176)
                (expr_list:REG_UNUSED (reg:SI 1 r1)
                    (expr_list:REG_UNUSED (reg:SI 0 r0)
                        (nil)))))))
Objects/obmalloc.c:503: confused by earlier errors, bailing out

Reply via email to