Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[X86] stack realignment is incorrect when Spill/restore BP is used #114941

Open
mahesh-attarde opened this issue Nov 5, 2024 · 1 comment
Open

Comments

@mahesh-attarde
Copy link
Contributor

mahesh-attarde commented Nov 5, 2024

Recently PR addressed #81048 as Fix for Issue #17204
We addressed issue regarding "Spill/restore FP/BP around instructions in which they are clobbered"

After merge of PR, We saw runtime fails with general protection fault. It was at vmovdqa64 %zmm19, 0x90(%rsp) where effective address end up unaligned.
Check more details on #114791 discussion.

Repro from @rnk
https://godbolt.org/z/s16MxPME3

#include <immintrin.h>
int f() {
    __m512i aligned{};
    asm volatile ("vmovdqa64 %%zmm0, %0" : "=m"(aligned) : "m"(aligned) : "rbp");
    return aligned[0];
}
---->
f():
        push    rbp
        mov     rbp, rsp
        and     rsp, -64
        sub     rsp, 128
....
        push    rbp
        push    rax
        vmovdqa64       zmmword ptr [rsp], zmm0
        add     rsp, 8
        pop     rbp
        mov     rax, qword ptr [rsp]
        mov     rsp, rbp
        pop     rbp
        ret

This is one of such issues.

@mahesh-attarde mahesh-attarde changed the title X86 stack realignment is incorrect when Spill/restore BP is used [X86] stack realignment is incorrect when Spill/restore BP is used Nov 5, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Nov 5, 2024

@llvm/issue-subscribers-backend-x86

Author: Mahesh-Attarde (mahesh-attarde)

Recently PR addressed https://github.com//pull/81048 as Fix for Issue https://github.com//issues/17204 We addressed issue regarding "Spill/restore FP/BP around instructions in which they are clobbered"

After merge of PR, We saw runtime fails with general protection fault. It was at vmovdqa64 %zmm19, 0x90(%rsp) where effective address end up unaligned.
Check more details on #114791 discussion.

Repro from @rnk
https://godbolt.org/z/s16MxPME3

#include &lt;immintrin.h&gt;
int f() {
    __m512i aligned{};
    asm volatile ("vmovdqa64 %%zmm0, %0" : "=m"(aligned) : "m"(aligned) : "rbp");
    return aligned[0];
}
----&gt;
f():
        push    rbp
        mov     rbp, rsp
        and     rsp, -64
        sub     rsp, 128
....
        push    rbp
        push    rax
        vmovdqa64       zmmword ptr [rsp], zmm0
        add     rsp, 8
        pop     rbp
        mov     rax, qword ptr [rsp]
        mov     rsp, rbp
        pop     rbp
        ret

This is one of such issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants