authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-31 09:25:16+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-05-12 17:07:50+02:00
log427810f3edea1beba77e3f84dd695dd0a8c35f00
tree3aa1e32ff3770317ba7266fc9713def8e87add72
parente9ae9a5fc45a6ee85d988372a4d150032f52ef4c
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

llvm: Don't set nonnull attribute on pointers in non-generic address spaces.

LLVM considers null pointers to be valid for such address spaces.

1 files changed, 12 insertions(+), 3 deletions(-)

src/codegen/llvm.zig+12-3
......@@ -1341,7 +1341,10 @@ pub const Object = struct {
13411341 try attributes.addParamAttr(llvm_arg_i, .@"noalias", &o.builder);
13421342 }
13431343 }
1344 if (param_ty.zigTypeTag(zcu) != .optional and !ptr_info.flags.is_allowzero) {
1344 if (param_ty.zigTypeTag(zcu) != .optional and
1345 !ptr_info.flags.is_allowzero and
1346 ptr_info.flags.address_space == .generic)
1347 {
13451348 try attributes.addParamAttr(llvm_arg_i, .nonnull, &o.builder);
13461349 }
13471350 if (ptr_info.flags.is_const) {
......@@ -4358,7 +4361,10 @@ pub const Object = struct {
43584361 try attributes.addParamAttr(llvm_arg_i, .@"noalias", &o.builder);
43594362 }
43604363 }
4361 if (!param_ty.isPtrLikeOptional(zcu) and !ptr_info.flags.is_allowzero) {
4364 if (!param_ty.isPtrLikeOptional(zcu) and
4365 !ptr_info.flags.is_allowzero and
4366 ptr_info.flags.address_space == .generic)
4367 {
43624368 try attributes.addParamAttr(llvm_arg_i, .nonnull, &o.builder);
43634369 }
43644370 switch (fn_info.cc) {
......@@ -5410,7 +5416,10 @@ pub const FuncGen = struct {
54105416 try attributes.addParamAttr(llvm_arg_i, .@"noalias", &o.builder);
54115417 }
54125418 }
5413 if (param_ty.zigTypeTag(zcu) != .optional and !ptr_info.flags.is_allowzero) {
5419 if (param_ty.zigTypeTag(zcu) != .optional and
5420 !ptr_info.flags.is_allowzero and
5421 ptr_info.flags.address_space == .generic)
5422 {
54145423 try attributes.addParamAttr(llvm_arg_i, .nonnull, &o.builder);
54155424 }
54165425 if (ptr_info.flags.is_const) {