| ... | @@ -3726,16 +3726,15 @@ fn airStore(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3726,16 +3726,15 @@ fn airStore(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3726 | | 3726 | |
| 3727 | const ptr_val = try f.resolveInst(bin_op.lhs); | 3727 | const ptr_val = try f.resolveInst(bin_op.lhs); |
| 3728 | const src_ty = f.air.typeOf(bin_op.rhs); | 3728 | const src_ty = f.air.typeOf(bin_op.rhs); |
| 3729 | const src_val = try f.resolveInst(bin_op.rhs); | | |
| 3730 | | | |
| 3731 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | | |
| 3732 | | 3729 | |
| 3733 | // TODO Sema should emit a different instruction when the store should | 3730 | // TODO Sema should emit a different instruction when the store should |
| 3734 | // possibly do the safety 0xaa bytes for undefined. | 3731 | // possibly do the safety 0xaa bytes for undefined. |
| 3735 | const src_val_is_undefined = | 3732 | const src_val_is_undefined = |
| 3736 | if (f.air.value(bin_op.rhs)) |v| v.isUndefDeep() else false; | 3733 | if (f.air.value(bin_op.rhs)) |v| v.isUndefDeep() else false; |
| 3737 | if (src_val_is_undefined) | 3734 | if (src_val_is_undefined) { |
| | 3735 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| 3738 | return try storeUndefined(f, ptr_info.pointee_type, ptr_val); | 3736 | return try storeUndefined(f, ptr_info.pointee_type, ptr_val); |
| | 3737 | } |
| 3739 | | 3738 | |
| 3740 | const target = f.object.dg.module.getTarget(); | 3739 | const target = f.object.dg.module.getTarget(); |
| 3741 | const is_aligned = ptr_info.@"align" == 0 or | 3740 | const is_aligned = ptr_info.@"align" == 0 or |
| ... | @@ -3744,6 +3743,9 @@ fn airStore(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3744,6 +3743,9 @@ fn airStore(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3744 | const need_memcpy = !is_aligned or is_array; | 3743 | const need_memcpy = !is_aligned or is_array; |
| 3745 | const writer = f.object.writer(); | 3744 | const writer = f.object.writer(); |
| 3746 | | 3745 | |
| | 3746 | const src_val = try f.resolveInst(bin_op.rhs); |
| | 3747 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| | 3748 | |
| 3747 | if (need_memcpy) { | 3749 | if (need_memcpy) { |
| 3748 | // For this memcpy to safely work we need the rhs to have the same | 3750 | // For this memcpy to safely work we need the rhs to have the same |
| 3749 | // underlying type as the lhs (i.e. they must both be arrays of the same underlying type). | 3751 | // underlying type as the lhs (i.e. they must both be arrays of the same underlying type). |
| ... | @@ -4344,8 +4346,9 @@ fn airDbgInline(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4344,8 +4346,9 @@ fn airDbgInline(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4344 | fn airDbgVar(f: *Function, inst: Air.Inst.Index) !CValue { | 4346 | fn airDbgVar(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4345 | const pl_op = f.air.instructions.items(.data)[inst].pl_op; | 4347 | const pl_op = f.air.instructions.items(.data)[inst].pl_op; |
| 4346 | const name = f.air.nullTerminatedString(pl_op.payload); | 4348 | const name = f.air.nullTerminatedString(pl_op.payload); |
| 4347 | const operand = try f.resolveInst(pl_op.operand); | 4349 | const operand_is_undef = if (f.air.value(pl_op.operand)) |v| v.isUndefDeep() else false; |
| 4348 | _ = operand; | 4350 | if (!operand_is_undef) _ = try f.resolveInst(pl_op.operand); |
| | 4351 | |
| 4349 | try reap(f, inst, &.{pl_op.operand}); | 4352 | try reap(f, inst, &.{pl_op.operand}); |
| 4350 | const writer = f.object.writer(); | 4353 | const writer = f.object.writer(); |
| 4351 | try writer.print("/* var:{s} */\n", .{name}); | 4354 | try writer.print("/* var:{s} */\n", .{name}); |