authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-06-13 11:40:20+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-06-17 18:57:02+03:00
logffa6f895fff52846bc4b82cc9b449d0f7224d7d9
tree84eb9a9bacbaf6fe077e834658d5f2ad6c624463
parentd506275a06dd5e9ad8be63f9e44abb7d8bea88b3

Sema: validateArrayInit detect bitcast before store


1 files changed, 26 insertions(+), 0 deletions(-)

src/Sema.zig+26
......@@ -3795,6 +3795,32 @@ fn zirValidateArrayInit(
37953795 }
37963796 continue;
37973797 },
3798 .bitcast => {
3799 // %a = bitcast(*arr_ty, %array_base)
3800 // %b = ptr_elem_ptr(%a, %index)
3801 // %c = bitcast(*elem_ty, %b)
3802 // %d = store(%c, %val)
3803 if (air_datas[next_air_inst].ty_op.operand != elem_ptr_air_ref) {
3804 array_is_comptime = false;
3805 continue;
3806 }
3807 const store_inst = block.instructions.items[block_index + 2];
3808 if (air_tags[store_inst] != .store) {
3809 array_is_comptime = false;
3810 continue;
3811 }
3812 const bin_op = air_datas[store_inst].bin_op;
3813 if (bin_op.lhs != Air.indexToRef(next_air_inst)) {
3814 array_is_comptime = false;
3815 continue;
3816 }
3817 if (try sema.resolveMaybeUndefValAllowVariables(block, elem_src, bin_op.rhs)) |val| {
3818 element_vals[i] = val;
3819 } else {
3820 array_is_comptime = false;
3821 }
3822 continue;
3823 },
37983824 else => {
37993825 array_is_comptime = false;
38003826 continue;