-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Miscompilation in release mode for f32 on 64-bits platforms #13830
Comments
the thing I don't get is I have different results with |
The LLVM IR code emitted is wrong. The struct is a stack allocation of type |
Yes, we are casting between with The pattern I'm seeing here is that we can only cast to something of the same size and alignment, which seems reasonable. If you know a relevant link in LLVM doc I'm interested. I'm going to try to fix this. |
Float structs break for me only when they are smaller than 16 bytes, see #14262. Adding a 4th float to a struct (or more) mitigates the problem for whatever reason. |
Zig Version
0.10.0+4be1bb4aa
Steps to Reproduce and Observed Behavior
https://godbolt.org/z/6cfEPnao3
On debug mode this compiles and runs fine
With -DReleaseFast this compiles on x86_64-linux to:
The same issue also appears for aarch64, I haven't tested with other platforms.
The generated LLVM IR looks correct to me, but I'd like a sanity check before opening a LLVM issue.
The LLVM IR starts to look weird after the "SROA" optimization pass (Scalar Replacement of Aggregates).
Note that I haven't been able to reproduce the issue in Clang because Clang lowers float fields to float.
So is Zig generating invalid LLVM IR here ? Should we only use
float
field in LLVM structs to representsf32
?Expected Behavior
The code should be valid both in -ODebug and -OReleaseFast.
The text was updated successfully, but these errors were encountered: