From 435a5660ce62c9c54f8ac9bf0a325811a6b684e6 Mon Sep 17 00:00:00 2001 From: Robin Voetter Date: Tue, 11 Apr 2023 00:04:11 +0200 Subject: 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. --- src/codegen/spirv.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/codegen/spirv.zig') 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 }); -- cgit v1.2.3