https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97032
Bug ID: 97032
Summary: [8/9/10/11 Regression] ICE output_operand: invalid use
of register 'frame' since r8-1911
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: jakub at gcc dot gnu.org
Target Milestone: ---
Since r8-1911-g35c95658180e67503f9de96567ab4d6e71b10a6e the following testcase
distilled from firefox:
#include <stdarg.h>
extern int *__errno_location (void);
long
sys_socketcall (int op, ...)
{
long int res;
va_list ap;
va_start (ap, op);
asm volatile ("push %%ebx; movl %2, %%ebx; int $0x80; pop %%ebx"
: "=a" (res) : "0" (102), "ri" (16), "c" (ap) : "memory",
"esp");
if (__builtin_expect (res > 4294963200UL, 0))
*__errno_location () = -res;
va_end (ap);
return res;
}
ICEs on x86_64-linux or i686-linux with
-O2 -m32 -mincoming-stack-boundary=2 -fstack-protector-all
test.c: In function ‘sys_socketcall’:
test.c:11:3: warning: listing the stack pointer register ‘esp’ in a clobber
list is deprecated [-Wdeprecated]
11 | asm volatile ("push %%ebx; movl %2, %%ebx; int $0x80; pop %%ebx"
| ^~~
test.c:11:3: note: the value of the stack pointer after an ‘asm’ statement must
be the same as it was before the statement
during RTL pass: final
test.c:17:1: internal compiler error: output_operand: invalid use of register
'frame'
17 | }
| ^
0xd3b872 output_operand_lossage(char const*, ...)
../../gcc/final.c:3609
0x17e0869 print_reg(rtx_def*, int, _IO_FILE*)
../../gcc/config/i386/i386.c:12274
0x17e2fa1 ix86_print_operand_address_as
../../gcc/config/i386/i386.c:13311
0x17e22d2 ix86_print_operand(_IO_FILE*, rtx_def*, int)
../../gcc/config/i386/i386.c:13060
0xd3c92a output_operand(rtx_def*, int)
../../gcc/final.c:4051
0xd3c550 output_asm_insn(char const*, rtx_def**)
../../gcc/final.c:3963
0x1f325e1 output_1129
../../gcc/config/i386/i386.md:20656
0xd38b91 get_insn_template(int, rtx_insn*)
../../gcc/final.c:2070
0xd3a8b6 final_scan_insn_1
../../gcc/final.c:3039
0xd3ad3e final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*)
../../gcc/final.c:3152
0xd389c0 final_1
../../gcc/final.c:2020
0xd3dd0d rest_of_handle_final
../../gcc/final.c:4658
0xd3e06c execute
../../gcc/final.c:4736
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Seems we set crtl->stack_realign_needed, which prevents elimination of frame
register to hard frame pointer, but have the frame register used in the IL and
therefore not eliminated.