| author | |
| committer | |
| log | 46abf2045476a32b6f4dd939679c0fbc7a639133 |
| tree | 54f3a32f5eee31d36294c503f9cb9ac5dc41d291 |
| parent | 417b92f0852eca8bd47f1964a63a9d1f6f3e6f6b |
prefer marking too few undefined bits, rather than too many that may overwrite nearby values.
partially resolves https://github.com/ziglang/zig/issues/153372 files changed, 9 insertions(+), 1 deletions(-)
src/codegen/llvm.zig+9| ... | ... | @@ -8753,6 +8753,15 @@ pub const FuncGen = struct { |
| 8753 | 8753 | |
| 8754 | 8754 | const val_is_undef = if (try self.air.value(bin_op.rhs, mod)) |val| val.isUndefDeep(mod) else false; |
| 8755 | 8755 | if (val_is_undef) { |
| 8756 | const ptr_info = ptr_ty.ptrInfo(mod); | |
| 8757 | const needs_bitmask = (ptr_info.packed_offset.host_size != 0); | |
| 8758 | if (needs_bitmask) { | |
| 8759 | // TODO: only some bits are to be undef, we cannot write with a simple memset. | |
| 8760 | // meanwhile, ignore the write rather than stomping over valid bits. | |
| 8761 | // https://github.com/ziglang/zig/issues/15337 | |
| 8762 | return .none; | |
| 8763 | } | |
| 8764 | ||
| 8756 | 8765 | // Even if safety is disabled, we still emit a memset to undefined since it conveys |
| 8757 | 8766 | // extra information to LLVM. However, safety makes the difference between using |
| 8758 | 8767 | // 0xaa or actual undefined for the fill byte. |
test/behavior/packed-struct.zig-1| ... | ... | @@ -632,7 +632,6 @@ test "pointer to container level packed struct field" { |
| 632 | 632 | test "store undefined to packed result location" { |
| 633 | 633 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 634 | 634 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 635 | if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; | |
| 636 | 635 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; |
| 637 | 636 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 638 | 637 |