-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
LLVM ERROR: Unsupported expression in static initializer (On macOS) #89225
Copy link
Copy link
Closed
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️O-macosOperating system: macOSOperating system: macOST-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️O-macosOperating system: macOSOperating system: macOST-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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 --releaseInitial investigation
By running
cargo rustc --release -- --emit=llvm-irto 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
mainfunction in a call tomemset_pattern16This 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.