| ... | ... | @@ -17931,23 +17931,14 @@ fn zirAlignCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 17931 | 17931 | const ptr = try sema.resolveInst(extra.rhs); |
| 17932 | 17932 | const ptr_ty = sema.typeOf(ptr); |
| 17933 | 17933 | |
| 17934 | | // TODO in addition to pointers, this instruction is supposed to work for |
| 17935 | | // pointer-like optionals and slices. |
| 17936 | 17934 | try sema.checkPtrOperand(block, ptr_src, ptr_ty); |
| 17937 | 17935 | |
| 17938 | | // TODO compile error if the result pointer is comptime known and would have an |
| 17939 | | // alignment that disagrees with the Decl's alignment. |
| 17940 | | |
| 17941 | | const ptr_info = ptr_ty.ptrInfo().data; |
| 17942 | | const dest_ty = try Type.ptr(sema.arena, sema.mod, .{ |
| 17943 | | .pointee_type = ptr_info.pointee_type, |
| 17944 | | .@"align" = dest_align, |
| 17945 | | .@"addrspace" = ptr_info.@"addrspace", |
| 17946 | | .mutable = ptr_info.mutable, |
| 17947 | | .@"allowzero" = ptr_info.@"allowzero", |
| 17948 | | .@"volatile" = ptr_info.@"volatile", |
| 17949 | | .size = ptr_info.size, |
| 17950 | | }); |
| 17936 | var ptr_info = ptr_ty.ptrInfo().data; |
| 17937 | ptr_info.@"align" = dest_align; |
| 17938 | var dest_ty = try Type.ptr(sema.arena, sema.mod, ptr_info); |
| 17939 | if (ptr_ty.zigTypeTag() == .Optional) { |
| 17940 | dest_ty = try Type.Tag.optional.create(sema.arena, dest_ty); |
| 17941 | } |
| 17951 | 17942 | |
| 17952 | 17943 | if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |val| { |
| 17953 | 17944 | if (try val.getUnsignedIntAdvanced(sema.mod.getTarget(), null)) |addr| { |
| ... | ... | @@ -17960,7 +17951,7 @@ fn zirAlignCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 17960 | 17951 | |
| 17961 | 17952 | try sema.requireRuntimeBlock(block, inst_data.src(), ptr_src); |
| 17962 | 17953 | if (block.wantSafety() and dest_align > 1 and |
| 17963 | | try sema.typeHasRuntimeBits(block, sema.src, dest_ty.elemType2())) |
| 17954 | try sema.typeHasRuntimeBits(block, sema.src, ptr_info.pointee_type)) |
| 17964 | 17955 | { |
| 17965 | 17956 | const val_payload = try sema.arena.create(Value.Payload.U64); |
| 17966 | 17957 | val_payload.* = .{ |
| ... | ... | @@ -17985,7 +17976,7 @@ fn zirAlignCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 17985 | 17976 | } else is_aligned; |
| 17986 | 17977 | try sema.addSafetyCheck(block, ok, .incorrect_alignment); |
| 17987 | 17978 | } |
| 17988 | | return sema.coerceCompatiblePtrs(block, dest_ty, ptr, ptr_src); |
| 17979 | return sema.bitCast(block, dest_ty, ptr, ptr_src); |
| 17989 | 17980 | } |
| 17990 | 17981 | |
| 17991 | 17982 | fn zirBitCount( |