diff options
| author | Robin Voetter <robin@voetter.nl> | 2023-04-11 00:04:11 +0200 |
|---|---|---|
| committer | Robin Voetter <robin@voetter.nl> | 2023-05-11 20:31:51 +0200 |
| commit | 435a5660ce62c9c54f8ac9bf0a325811a6b684e6 (patch) | |
| tree | aa930f3bd62b83023dba214df245bcb8f64cc694 /src/codegen/spirv.zig | |
| parent | f62735d98ce9055ca08cff587e438412404818cd (diff) | |
| download | zig-435a5660ce62c9c54f8ac9bf0a325811a6b684e6.tar.gz zig-435a5660ce62c9c54f8ac9bf0a325811a6b684e6.zip | |
spirv: fix invalid code generated by br-with-value
The result-id and result-type-id of the OpPhi used to merge the
break values was not properly emitted, as some of the operands
were not written out. This caused an invalid spir-v module.
Diffstat (limited to 'src/codegen/spirv.zig')
| -rw-r--r-- | src/codegen/spirv.zig | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index 68f64dc353..9b649319d9 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -2291,15 +2291,15 @@ pub const DeclGen = struct { return null; // Combine the result from the blocks using the Phi instruction. - const result_id = self.spv.allocId(); // TODO: OpPhi is limited in the types that it may produce, such as pointers. Figure out which other types // are not allowed to be created from a phi node, and throw an error for those. const result_type_id = try self.resolveTypeId(ty); - _ = result_type_id; try self.func.body.emitRaw(self.spv.gpa, .OpPhi, 2 + @intCast(u16, incoming_blocks.items.len * 2)); // result type + result + variable/parent... + self.func.body.writeOperand(spec.IdResultType, result_type_id); + self.func.body.writeOperand(spec.IdRef, result_id); for (incoming_blocks.items) |incoming| { self.func.body.writeOperand(spec.PairIdRefIdRef, .{ incoming.break_value_id, incoming.src_label_id }); |
