-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
LLVM ERROR: Unsupported expression in static initializer (On macOS) #89225
Comments
@rustbot label +I-ICE +A-llvm +O-macos +E-needs-bisection |
Reproduces on aarch64-apple-darwin as well. Could not find a version which does not reproduce this issue. @rustbot label -E-needs-bisection +A-codegen |
|
I think it is done by the Loop Idiom Recognition optimization pass. |
Triage: Bisection shows that this has been fixed since Details
fetching https://static.rust-lang.org/dist/2022-03-04/channel-rust-nightly-git-commit-hash.txt @rustbot label E-needs-test |
rustc seems to generate invalid/unsupported LLVM IR on macOS for release builds.
Linux and debug builds seem to be unaffected.
Code
Meta
This issue occurs on the stable version
rustc --version --verbose
:as well as the most recent nightly version:
Error output
cargo build --release
Initial investigation
By running
cargo rustc --release -- --emit=llvm-ir
to emit the LLVM, I could narrow the issue down a bit.The faulty initializer belongs to a constant called
@.memset_pattern
:This constant is used inside the
main
function in a call tomemset_pattern16
This function is (as far as I know) not available on Linux which explains why the bug doesn't occur on Linux.
This function seems to replace the initialization loop in the code above which explains why the bug doesn't occur on debug builds.
The optimization seems to be very sensitive: When I removed the second member in the struct, the code compiles, because the compiler unrolls the loop instead of calling memset_pattern16.
The text was updated successfully, but these errors were encountered: