https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122387
Bug ID: 122387
Summary: `-ffixed-x16 -ffixed-x17` will ICE with an indirect
tail call
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: ice-on-invalid-code
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Target: aarch64
Take:
```
int f(int (*a)(void))
{
return a();
}
```
Compile with `-O2 -ffixed-x16 -ffixed-x17` and you will get an ICE:
```
<source>: In function 'int f(int (*)())':
<source>:4:1: error: unable to generate reloads for:
4 | }
| ^
(call_insn/j 7 6 8 2 (parallel [
(set (reg:SI 0 x0)
(call (mem:DI (reg/f:DI 103 [ a ]) [0 *a_1(D) S8 A8])
(const_int 0 [0])))
(unspec:DI [
(const_int 2 [0x2])
] UNSPEC_CALLEE_ABI)
(return)
]) "<source>":3:11 100 {*sibcall_value_insn}
(expr_list:REG_DEAD (reg/f:DI 103 [ a ])
(expr_list:REG_CALL_DECL (nil)
(nil)))
(expr_list (clobber (reg:DI 17 x17))
(expr_list (clobber (reg:DI 16 x16))
(nil))))
during RTL pass: reload
<source>:4:1: internal compiler error: in curr_insn_transform, at
lra-constraints.cc:4373
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
```
The reason is because TAILCALL_ADDR_REGS is restricted to x16/x17 and you just
forced both not to be available.
Most likely we should error out if both x16/x17 are fixed.