| ... | @@ -2753,20 +2753,12 @@ pub const DeclGen = struct { | ... | @@ -2753,20 +2753,12 @@ pub const DeclGen = struct { |
| 2753 | } | 2753 | } |
| 2754 | | 2754 | |
| 2755 | fn airStore(self: *DeclGen, inst: Air.Inst.Index) !void { | 2755 | fn airStore(self: *DeclGen, inst: Air.Inst.Index) !void { |
| 2756 | const mod = self.module; | | |
| 2757 | const bin_op = self.air.instructions.items(.data)[inst].bin_op; | 2756 | const bin_op = self.air.instructions.items(.data)[inst].bin_op; |
| 2758 | const ptr_ty = self.typeOf(bin_op.lhs); | 2757 | const ptr_ty = self.typeOf(bin_op.lhs); |
| 2759 | const ptr = try self.resolve(bin_op.lhs); | 2758 | const ptr = try self.resolve(bin_op.lhs); |
| 2760 | const value = try self.resolve(bin_op.rhs); | 2759 | const value = try self.resolve(bin_op.rhs); |
| 2761 | const ptr_ty_ref = try self.resolveType(ptr_ty, .direct); | | |
| 2762 | | 2760 | |
| 2763 | const val_is_undef = if (try self.air.value(bin_op.rhs, mod)) |val| val.isUndefDeep(mod) else false; | 2761 | try self.store(ptr_ty, ptr, value); |
| 2764 | if (val_is_undef) { | | |
| 2765 | const undef = try self.spv.constUndef(ptr_ty_ref); | | |
| 2766 | try self.store(ptr_ty, ptr, undef); | | |
| 2767 | } else { | | |
| 2768 | try self.store(ptr_ty, ptr, value); | | |
| 2769 | } | | |
| 2770 | } | 2762 | } |
| 2771 | | 2763 | |
| 2772 | fn airLoop(self: *DeclGen, inst: Air.Inst.Index) !void { | 2764 | fn airLoop(self: *DeclGen, inst: Air.Inst.Index) !void { |
| ... | @@ -2790,6 +2782,7 @@ pub const DeclGen = struct { | ... | @@ -2790,6 +2782,7 @@ pub const DeclGen = struct { |
| 2790 | const operand_ty = self.typeOf(operand); | 2782 | const operand_ty = self.typeOf(operand); |
| 2791 | const mod = self.module; | 2783 | const mod = self.module; |
| 2792 | if (operand_ty.hasRuntimeBits(mod)) { | 2784 | if (operand_ty.hasRuntimeBits(mod)) { |
| | 2785 | // TODO: If we return an empty struct, this branch is also hit incorrectly. |
| 2793 | const operand_id = try self.resolve(operand); | 2786 | const operand_id = try self.resolve(operand); |
| 2794 | try self.func.body.emit(self.spv.gpa, .OpReturnValue, .{ .value = operand_id }); | 2787 | try self.func.body.emit(self.spv.gpa, .OpReturnValue, .{ .value = operand_id }); |
| 2795 | } else { | 2788 | } else { |