LLVM ERROR: Unsupported expression in static initializer (On macOS) #89225
Labels
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
C-bug
Category: This is a bug.
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
O-macos
Operating system: macOS
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
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: