| ... | @@ -4926,6 +4926,9 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { | ... | @@ -4926,6 +4926,9 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4926 | const result = try func.allocStack(result_ty); | 4926 | const result = try func.allocStack(result_ty); |
| 4927 | const elem_ty = result_ty.childType(); | 4927 | const elem_ty = result_ty.childType(); |
| 4928 | const elem_size = @intCast(u32, elem_ty.abiSize(func.target)); | 4928 | const elem_size = @intCast(u32, elem_ty.abiSize(func.target)); |
| | 4929 | const sentinel = if (result_ty.sentinel()) |sent| blk: { |
| | 4930 | break :blk try func.lowerConstant(sent, elem_ty); |
| | 4931 | } else null; |
| 4929 | | 4932 | |
| 4930 | // When the element type is by reference, we must copy the entire | 4933 | // When the element type is by reference, we must copy the entire |
| 4931 | // value. It is therefore safer to move the offset pointer and store | 4934 | // value. It is therefore safer to move the offset pointer and store |
| ... | @@ -4938,10 +4941,13 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { | ... | @@ -4938,10 +4941,13 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4938 | const elem_val = try func.resolveInst(elem); | 4941 | const elem_val = try func.resolveInst(elem); |
| 4939 | try func.store(offset, elem_val, elem_ty, 0); | 4942 | try func.store(offset, elem_val, elem_ty, 0); |
| 4940 | | 4943 | |
| 4941 | if (elem_index < elements.len - 1) { | 4944 | if (elem_index < elements.len - 1 and sentinel == null) { |
| 4942 | _ = try func.buildPointerOffset(offset, elem_size, .modify); | 4945 | _ = try func.buildPointerOffset(offset, elem_size, .modify); |
| 4943 | } | 4946 | } |
| 4944 | } | 4947 | } |
| | 4948 | if (sentinel) |sent| { |
| | 4949 | try func.store(offset, sent, elem_ty, 0); |
| | 4950 | } |
| 4945 | } else { | 4951 | } else { |
| 4946 | var offset: u32 = 0; | 4952 | var offset: u32 = 0; |
| 4947 | for (elements) |elem| { | 4953 | for (elements) |elem| { |
| ... | @@ -4949,6 +4955,9 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { | ... | @@ -4949,6 +4955,9 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4949 | try func.store(result, elem_val, elem_ty, offset); | 4955 | try func.store(result, elem_val, elem_ty, offset); |
| 4950 | offset += elem_size; | 4956 | offset += elem_size; |
| 4951 | } | 4957 | } |
| | 4958 | if (sentinel) |sent| { |
| | 4959 | try func.store(result, sent, elem_ty, offset); |
| | 4960 | } |
| 4952 | } | 4961 | } |
| 4953 | break :result_value result; | 4962 | break :result_value result; |
| 4954 | }, | 4963 | }, |