-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Closed
Copy link
Labels
arch-x86_6464-bit x8664-bit x86backend-self-hostedbugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior
Milestone
Description
Zig Version
0.15.0-dev.552+bc2f7c754
Steps to Reproduce and Observed Behavior
const S = struct { x: u32, y: enum { opv } };
export fn foo(x: u32) void {
other(.{ .x = x, .y = .opv });
}
fn other(_: S) void {}$ zig build-obj repro.zig -fno-llvm
error(x86_64_encoder): no encoding found for: none mov m256 imm8s none none
repro.zig:2:8: error: emit MIR failed: InvalidInstruction (Zig compiler bug)
export fn foo(x: u32) void {
~~~~~~~^~~~~~~~~~~~~~~~~~~Note that on a different compiler build this crashes the x86_64 backend instead of emitting a nice error, so it's possible it could crash in some cases.
Expected Behavior
Successful compilation, which does happen with the LLVM backend.
@jacobly0 reports that this happens because the aggregate_init instruction contains the OPV field .y = .opv, which the x86_64 backend does not expect (whereas the LLVM backend does expect it). This is one of many bugs where AIR instructions corresponding to OPV values are wrongly emitted (related: #22419).
Metadata
Metadata
Assignees
Labels
arch-x86_6464-bit x8664-bit x86backend-self-hostedbugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior