https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117359
Bug ID: 117359
Summary: Stack pointer modifications in asm are not flagged in
crtl->sp_is_unchanging
Product: gcc
Version: 14.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: ubizjak at gmail dot com
Target Milestone: ---
Consider the following testcase, derived from x86 linux sources:
--cut here--
register unsigned long current_stack_pointer asm ("sp");
#define ASM_CALL_CONSTRAINT "+r" (current_stack_pointer)
void foo (void)
{
asm volatile ("#" : ASM_CALL_CONSTRAINT);
}
--cut here--
The asm writes to stack pointer, as can be seen from _.final dump:
(insn:TI 5 2 15 2 (parallel [
(set (reg/v:DI 7 sp [ current_stack_pointer ])
(asm_operands/v:DI ("#") ("=r") 0 [
(reg/v:DI 7 sp [ current_stack_pointer ])
]
[
(asm_input:DI ("0") rsp.c:6)
]
[] rsp.c:6))
(clobber (reg:CC 17 flags))
]) "rsp.c":6:3 -1
(expr_list:REG_UNUSED (reg:CC 17 flags)
(nil)))
but middle-end fails to detect this write. This issue can be observed by
putting a breakpoint at ix86_compute_frame_layout and:
Breakpoint 2, ix86_compute_frame_layout () at
../../git/gcc/gcc/config/i386/i386.cc:6876
6876 struct ix86_frame *frame = &cfun->machine->frame;
(gdb) p x_rtl->sp_is_unchanging
$1 = true
The above result should be false.