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

            Bug ID: 112512
           Summary: GCC: 14: internal compiler error: in
                    lra_split_hard_reg_for, at lra-assigns.cc:1861
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/jG4PfK845

When compiling this program with `gcc-14 -Og`, gcc ICEs:
```
extern int f();

int f1(char *s) {
  return f();
}

int f2(char *s) {
  return (f1(s) / f1(s)) && f1(s);
}

register int v asm("%rax"); // both rax and eax are able to trigger the crash

char *f3(char *s) {}
```

The output of crash log:
```
<source>:11:14: warning: call-clobbered register used for global register
variable
   11 | register int v asm("%rax");
      |              ^
<source>: In function 'f2':
<source>:9:1: error: unable to find a register to spill
    9 | }
      | ^
<source>:9:1: error: this is the insn:
(insn 14 40 37 2 (parallel [
            (set (reg:SI 107 [orig:98 _1 ] [98])
                (div:SI (reg:SI 107 [orig:98 _1 ] [98])
                    (reg:SI 0 ax)))
            (set (reg:SI 103)
                (mod:SI (reg:SI 107 [orig:98 _1 ] [98])
                    (reg:SI 0 ax)))
            (clobber (reg:CC 17 flags))
        ]) "<source>":8:17 discrim 2 539 {*divmodsi4}
     (expr_list:REG_UNUSED (reg:SI 103)
        (expr_list:REG_UNUSED (reg:CC 17 flags)
            (nil))))
during RTL pass: reload
<source>:9:1: internal compiler error: in lra_split_hard_reg_for, at
lra-assigns.cc:1861
0x238b06e internal_error(char const*, ...)
        ???:0
0xa1125c fancy_abort(char const*, int, char const*)
        ???:0
0x827c80 _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
        ???:0
0xf202e5 lra_split_hard_reg_for()
        ???:0
0xf1a459 lra(_IO_FILE*)
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
```

Reply via email to