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 backend: 128-bit integers returned in xmm0 registers by windows 64 function cause compiler crash #19498

Open
ominitay opened this issue Mar 31, 2024 · 0 comments
Labels
arch-x86_64 64-bit x86 backend-self-hosted bug Observed behavior contradicts documented or intended behavior os-windows
Milestone

Comments

@ominitay
Copy link
Contributor

This bug specifically affects the x86 backend.

A minimal reproduction is given below:

const assert = @import("std").debug.assert;

fn foo() callconv(.Win64) u128 {
    return 0;
}

pub fn main() void {
    assert(foo() == 0);
}

The Microsoft x64 calling convention specifies that types which don't fit in general purpose registers, such as u128, are to be returned in XMM0. This code example causes the compiler to hit unreachable code in airCmp, as the backend expects that u128 is either in memory or a pair of general purpose registers, not an SSE register.

The solution to this I think would be, in genCall, to move values of this type out of the SSE register into memory. As far as I can tell, this is what LLVM does too.

This issue is currently blocking #18680, from which it was discovered and reduced.

@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior os-windows arch-x86_64 64-bit x86 backend-self-hosted labels Mar 31, 2024
@Vexu Vexu added this to the 0.13.0 milestone Mar 31, 2024
ominitay added a commit to ominitay/zig that referenced this issue Apr 17, 2024
Disables the two behaviour tests which are caused to fail on the x86_64 backend
by ziglang#19498. Fixing the underlying issue is not within the scope of this pull request.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-x86_64 64-bit x86 backend-self-hosted bug Observed behavior contradicts documented or intended behavior os-windows
Projects
None yet
Development

No branches or pull requests

2 participants