On Fri, Nov 1, 2024 at 2:18 PM Jeff Law <jeffreya...@gmail.com> wrote:
>
>
>
> On 11/1/24 5:34 AM, Uros Bizjak wrote:
> > Stack pointer modifications in asm are currently not flagged in
> > crtl->sp_is_unchanging due to RTX pointer comparison in
> > notice_stack_pointer_modification_1.  Pointer comparison does not detect
> > that "(reg/v:DI 7 sp [ current_stack_pointer ])" and "(reg/f:DI 7 sp)"
> > RTXes actually all correspond to the same stack pointer register.
> >
> > Due to the above omission, the compiler does not detect that asm RTX
> > manipulates stack pointer in the following construct:
> But how did you get two distinct RTXs for the stack pointer?  That's not
> supposed to happen IIRC.

Please see the testcase in the patch:

+register unsigned long current_stack_pointer asm ("%rsp");
+#define ASM_CALL_CONSTRAINT "+r" (current_stack_pointer)

[...]

+  asm volatile ("pushfq; push %1; pop %0; popfq"
+ : "=r" (y), ASM_CALL_CONSTRAINT
+ : "e" (-1));

When compiled for x86_64, the stack pointer RTX that is different from
the generic stack pointer RTX is created.

Uros.

Reply via email to