llvm: Don't set nonnull attribute on allowzero slices.

This commit is contained in:
Alex Rønne Petersen 2024-10-31 09:00:46 +01:00
parent 8e00f47685
commit 9948a093ff
No known key found for this signature in database

View File

@ -1658,7 +1658,7 @@ pub const Object = struct {
try attributes.addParamAttr(llvm_arg_i, .@"noalias", &o.builder);
}
}
if (param_ty.zigTypeTag(zcu) != .optional) {
if (param_ty.zigTypeTag(zcu) != .optional and !ptr_info.flags.is_allowzero) {
try attributes.addParamAttr(llvm_arg_i, .nonnull, &o.builder);
}
if (ptr_info.flags.is_const) {
@ -5756,7 +5756,7 @@ pub const FuncGen = struct {
try attributes.addParamAttr(llvm_arg_i, .@"noalias", &o.builder);
}
}
if (param_ty.zigTypeTag(zcu) != .optional) {
if (param_ty.zigTypeTag(zcu) != .optional and !ptr_info.flags.is_allowzero) {
try attributes.addParamAttr(llvm_arg_i, .nonnull, &o.builder);
}
if (ptr_info.flags.is_const) {