llvm: partial fix of store undefined to packed result location
prefer marking too few undefined bits, rather than too many that may overwrite nearby values. partially resolves https://github.com/ziglang/zig/issues/15337
This commit is contained in:
@@ -8753,6 +8753,15 @@ pub const FuncGen = struct {
|
||||
|
||||
const val_is_undef = if (try self.air.value(bin_op.rhs, mod)) |val| val.isUndefDeep(mod) else false;
|
||||
if (val_is_undef) {
|
||||
const ptr_info = ptr_ty.ptrInfo(mod);
|
||||
const needs_bitmask = (ptr_info.packed_offset.host_size != 0);
|
||||
if (needs_bitmask) {
|
||||
// TODO: only some bits are to be undef, we cannot write with a simple memset.
|
||||
// meanwhile, ignore the write rather than stomping over valid bits.
|
||||
// https://github.com/ziglang/zig/issues/15337
|
||||
return .none;
|
||||
}
|
||||
|
||||
// Even if safety is disabled, we still emit a memset to undefined since it conveys
|
||||
// extra information to LLVM. However, safety makes the difference between using
|
||||
// 0xaa or actual undefined for the fill byte.
|
||||
|
||||
@@ -632,7 +632,6 @@ test "pointer to container level packed struct field" {
|
||||
test "store undefined to packed result location" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user