|
pub const Asm = struct { |
|
/// Index to the corresponding ZIR instruction. |
|
/// `asm_source`, `outputs_len`, `inputs_len`, `clobbers_len`, `is_volatile`, and |
|
/// clobbers are found via here. |
|
zir_index: u32, |
This is problematic because it causes
thread 345550 panic: access of inactive union field
/home/andy/dev/zig/src/Liveness.zig:434:83: 0x319d323 in Liveness.analyzeInst (zig)
const extended = a.zir.instructions.items(.data)[extra.data.zir_index].extended;
^
Problem is that the ZIR we pass to Liveness analysis (and to codegen later) is for a particular Decl that could have inlined code, causing an assembly ZIR instruction from a different file to be in the AIR for the Decl. This means we are looking up a ZIR instruction index in the wrong ZIR object.
This is the only AIR instruction that references a ZIR instruction.
The solution is pretty straightforward: instead of trying to cut corners, change the AIR encoding to duplicate all the info from the ZIR that it needs, and uphold the property that ZIR is not needed in order to decode AIR.
zig/src/Air.zig
Lines 665 to 669 in 1b6a1e6
This is problematic because it causes
Problem is that the ZIR we pass to Liveness analysis (and to codegen later) is for a particular Decl that could have inlined code, causing an assembly ZIR instruction from a different file to be in the AIR for the Decl. This means we are looking up a ZIR instruction index in the wrong ZIR object.
This is the only AIR instruction that references a ZIR instruction.
The solution is pretty straightforward: instead of trying to cut corners, change the AIR encoding to duplicate all the info from the ZIR that it needs, and uphold the property that ZIR is not needed in order to decode AIR.